Render and culling render

Hello!

I was wondering if there is an event that fires when actor gets rendered or unrendered or if is there any other option how to do that.
For example I have box moving thought the timeline and i want to stop it when it gets unrendered.

Anyway, thanks for help.

Hi, you could use the “Was Recently Rendered” node. It is not an event, so you would have to call it manually from a timer.

Hi chrudimer,
“Was Recently Rendered” note target is an actor so actor has to be culled, but my culling distance volume works for every actor instead of actors like character, AIs, etc. (“Allow cull distance” is turned on and “Never cull distance” turned off)
One more thing, that using timers for more actors are breaking performance.
Is there any better way than using timers?

Ok, then I would need more information on what you’re trying to achieve, cause I don’t understand what you’re trying to do :slight_smile:

There are different types how the engine checks for culling, distance culling is only one of them (it’s the first step). “Was Recently Rendered” will return false if the actor is getting culled regardless whether it is in the first step by distance culling or in one of the later steps, so I don’t quite understand your point there.

How are you using the timers (so where are setting them, how much logic do you execute there, to what time did you set the timers), how many actors do you have where you use them?
But basically since this is not event driven, then as far as I know, timers are the most performant you can get (the cost of them depends on how many x seconds you call them and how much logic you execute there).

Lets say for example If I would use 1000 timers for 1000 actors to check if they are rendered or not and I would set timers deltas to 1 second it would definitely break performance.
Another problem is with culling volume.

This is without culling volume

This is with it.
The problem as you can see is that my actors are not culled by culling volume.
Everything else like floors and walls are culled.

I am trying to achieve distance render for any actors with best performance.
For example If I am near I want to make my AI moving to the random locations but if I am far away from AI I want to turn off event ticks,remove anim bp and etc. from it to get the best performance.
(I have used sphere collision but the collisions are really bad with performance)

Thanks, for help, but how can I also cull other actors because “Was Recently Rendered” note is “false” when ACTOR gets culled but my culling distance cannot cull actors with my own code.
(Render Desire Distance works only for components and actors like cube,floor etc.)

Lets say for example If I would use
1000 timers for 1000 actors to check
if they are rendered or not and I
would set timers deltas to 1 second it
would definitely break performance.

Nope, I just added a timer with one second and use the “Was Recently Rendered” node inside the timer on 1800 actors and see no difference in performance. If it breaks your performance then it would break it also without the timer (you need to reduce the logic you execute inside the actor and the gpu/draw cost of the actor (especially drawcalls), depending on where your bottleneck is). Even if you don’t add any logic to your actor in the event graph it will still execute some stuff by default, so disable what you don’t need.

As for the cull distance volume, never used them much so I can’t exactly tell you, you might wanna check your actor settings, cause every static mesh you place in the level (the floor and the walls) is an actor.

As for big levels, there are several approaches you could use (basically you would use a combination of those), some of those:

As for AI the way I do it: if you’re far away destroy them, and spawn them again when you get close. So for that you could use a timer and check the distance to the player/players. And I only execute animation logic if the AI is in view (in the bp, in the skeletal mesh, under optimization).

Hmmm, seems to me that you’re trying to remove whole actors. That’s not how culling works. Culling only means that what is getting culled is not getting rendered.

If you want to remove an actor, you could destroy it or use level streaming/world composition to stream actors in and out by distance (basically you stream whole levels) or use the distance to the player to destroy and respawn them.

As for the actor components, seems to me that the cull distance volume is ignoring anything except “Static Mesh Actors”, so I would write an editor script that applies the cull distance for those. Basically you could create a custom event, mark it “Call In Editor”, inside the event get all the actors, for each one use “Get Components By Class” and then you could use something like get bounding box to determine the size and set the appropriate cull distance.

The thing you mentioned to set the cull distance depending on bounding box is only setting the component to unrender and the “Was Recently Rendered” note is working only with actor so nothing will happend.
I tried to get “Visibility” and “Hidden in game” from this component and connect it to the branch, but it seems that this is not connected together.(Visibility was still true when component was unrendered)
(I do not want to remove actor, but I want it to not to be rendered)

I tried to get “Visibility” and
“Hidden in game” from this component
and connect it to the branch, but it
seems that this is not connected
together

Visibility and hidden in game concerns the game thread, culling happens in the draw thread. If it is invisible or hidden in game, then it will never be rendered but if it gets culled that does not mean that it is invisible or hidden in game.

I do not want to remove actor, but I
want it to not to be rendered

Set the visibility of the root component of the actor to false and propagate to children. If you want that to happen automatically, you could set the cull distance for each component to the same value (my post above).

I think we do not understand each other. (Or I am just stupid :D)
I would like to contact you on discord: Discord
and i will show you my problem.

Never used discord, not sure I wanna start now :slight_smile:

But maybe you could explain here what you’re trying to achieve.

So not with specific nodes but just in plain text what you’re trying to do and what end result you want to have.

One more thing.
“Was Recently Rendered” note is working when actor is not rendered.(Also If I am not looking at it)
I need this to be working only if I am far away from it.
For example if i would be far away from an AI I would like to delete navigation, but with this note, navigation will be deleted also in the situation when I would not facing him.

You would need to do the check based on the distance of the AI to the player/players.


So you could add a timer inside the AI pawn that checks the distance to the player and act based on that distance (so you could get all actors of class “playercontroller” do a for loop on them and inside that get the controlled pawn and check the distance to the AI (self)).

For the AI disable everything, not just animation and movement component (those two use up most of the CPU performance) so also set replicated to false, disable collision, disable physics simulation, set tick to false, pause all timers you have running, can be damaged, hide every visible parts, … or just plain destroy the AI and respawn it when the player gets close again (that’s what I do).


As for the respawn, I have a global blueprint and several “spawner blueprints”. The global blueprint checks in a timer the distance from the players to each “spawner blueprint” and activates/deactivates them based on the distance to the closest player.

Each “spawner blueprint” then holds an list of AI spawn info and if it is active, it checks in a timer the distance from the players to each AI spawn info location and spawns the AI (and a reference to the “spawner blueprint” and the spawn info is saved in the spawned AI) based on distance to the closest player and then removes that AI spawn info of its list.

As long as the AI exists, it checks the distance to each player on a timer and if the distance is beyond a treshold, destroys itself and readds its spawn info to the “spawner blueprint”.


And for creating the “spawner blueprints” with the AI spawn info in the first place, I place all the AI in the editor and created an in editor event inside the global blueprint that creates the “spawner blueprints” and adds the AI spawn info based on the AI placed inside the editor.

And on begin play I remove all the AI placed in editor.

Ok, I found the problem. I had to set Desire Render Distance to all my components like Static meshes ect.
I thought I have already tested it, but was wrong.
Anyway thank you very much
I still have to you use this code, that is using timer.

For example if I would be far away from an AI I would like to delete navigation, but with this note, navigation will be deleted also in the situation when I would not facing him.

So if an AI is far away (meaning out of player’s sight? or also in sight?), then delete navigation. But when not facing AI, navigation is deleted too? even at closer distances from AI? You really need to be more detailed in describing what you’re trying to do with the culling of actors. What is the idea / action involved?

I need to deactivate AI when is far away from a player that is all.

lol, alright.

You could use “Spawner” actors throughout the world. Each “spawner” actor contains a list of AI info for spawning (location, spawn distance, class,…) and checks on a timer the distance from each assigned AI info to each player, if one player is close enough → spawn AI, remove AI info, save reference of this “Spawner” and AI info into the AI.

AI checks on timer distance to all players. If the distance is great enough → destroy AI, readd the AI info to the referenced “Spawner”.

You could have several layers of “spawner”, right now I use only one. So I also have one global blueprint that on a timer checks the distance from each “Spawner” to each player and activates/deactivates the “Spawner” based on that distance (if no player is near the “Spawner”, it does not need to check the distance), I use a distance of 300m for the “Spawner”.

Then you could use an in editor event, to create the “Spawner” and add the AI info to them, based on the AIs you have placed in the editor (iterate over all AI: if AI is closer than 100m to an existent “spawner” → add AI info, if not → create new “spawner” at AI location and add AI info).

So this will result in a max reliable spawn distance of 200m for the AI.