Is there a way to cull certain objects from a camera's view?
Announcement
Collapse
No announcement yet.
Hiding certain objects from being drawn on a camera or SceneCapture2D object.
Collapse
X
-
I would love to know the answer too.David Hanson
You can follow our FPS development here: https://www.facebook.com/storm.united.mmofps
-
The engine doesn't expose any way to do this right now. The underlying renderer supports it. It's definitely a useful feature, I'll add it to our backlog of features we'd like to add. I can't promise when we will get to it though!
--
For coders out there, if you have a look at the code in FScene::UpdateSceneCaptureContents, it calls a function called CreateSceneRenderer. Inside that function you can see that it creates an FSceneView and adds it to the view family. An FSceneView has a member HiddenPrimitives which is a set of primitive IDs that the renderer should ignore when rendering the scene. If I were to implement this I'd do something like the following:
1) Add a set of UPrimitiveComponents that I want to be hidden to USceneCaptureComponent:
Code:UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=SceneCapture) TSet<TWeakObjectPtr<UPrimitiveComponent> > HiddenComponents
Code:/** Adds the component to our list of hidden components. */ UFUNCTION(BlueprintCallable, Category="Rendering|SceneCapture") ENGINE_API void HideComponent(UPrimitiveComponent* InComponent); /** Adds all primitive components in the actor to our list of hidden components. */ UFUNCTION(BlueprintCallable, Category="Rendering|SceneCapture") ENGINE_API void HideActorComponents(AActor* InComponent);
Code:for (auto It = HiddenComponents.CreateConstIterator(); It; ++It) { // If the primitive component was destroyed, the weak pointer will return NULL. UPrimitiveComponent* PrimitiveComponent = It->Get(); if (PrimitiveComponent) { View->HiddenPrimitives.Add(PrimitiveComponent->ComponentId); } }
Nick Penwarden, Lead Programmer @ Epic Games
Comment
-
Thank you.
Is it possible to say instead of 'hide A and B and Z' to tell the engine 'render only A and B’?
In terms of performance and maintenance wouldn’t it be better?
What I'm trying to achieve here is a way to render my FPS weapon separately (so I can have a different FOV for the world scene and the weapons amongst other advatages)
Would this be a good solution or would you recommend another scheme?David Hanson
You can follow our FPS development here: https://www.facebook.com/storm.united.mmofps
Comment
-
You're right, if you only wish to render a small number of objects it would be better to "whitelist" them. The renderer supports that for debugging but it's not exposed very well. E.g. we can freeze visibility for a view and move the camera around to see how well the occlusion system is working. In code look at the FrozenPrimitives set on the view state.
Adding a similar construct on the FSceneView itself would be the best solution.Nick Penwarden, Lead Programmer @ Epic Games
Comment
-
Thank you Nick, this sounds great!
How will shadows behave?
Say you have an object A casting a shadow on an object B. We have 2 cameras and each of them is hiding a different object (A or B). Will B still get the shadow of A?
If not is there a reasonable way to do that?
Thank for your answers they are very helpful.Last edited by bigzer; 05-06-2014, 08:39 AM.David Hanson
You can follow our FPS development here: https://www.facebook.com/storm.united.mmofps
Comment
-
If a primitive is explicitly hidden for a view it will not cast a shadow. That can be overridden per-primitive such that they will cast a shadow even when hidden:
Code:/** * If true, the primitive will cast shadows even if bHidden is true. * Controls whether the primitive should cast shadows when hidden. * This flag is only used if CastShadow is true. */ UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadOnly, Category=Lighting) uint32 bCastHiddenShadow:1;
Nick Penwarden, Lead Programmer @ Epic Games
Comment
-
ive got a question to throw on this for you guys, finally figured out how to set this capture 2d up and setup the render image, or so i thought, my problem is that my texture on my mesh is throwing a tiled version up (multiple images) is there a good tutorial somewhere on how to set this up properly, ive got an entire level thats going to rely on mirrors of different sizes ? thanks in advance for any help
Comment
-
FYI we've exposed the 'render blacklist' feature both for blueprints and code and have sent a pull request on Github so everyone can enjoy it.
Thank you NickDavid Hanson
You can follow our FPS development here: https://www.facebook.com/storm.united.mmofps
Comment
-
Bump. Also interested in this feature.Post Processing material packs:
ScreenFX Distortions and Blurs Marketplace | Website | Video
ScreenFX Damage and Shield Effects Marketplace | Website | Video
HomePage: deststudio.com
Twitter: devast3d
Comment
-
Just came across this thread, but it looks like this feature was implemented in 4.3. You can use it by dragging off of a Scene Capture actor or component reference in a blueprint, selecting the "Hide Actor Components" or "Hide Components" nodes, and passing a reference to the Actor or Component you want to hide in this Scene Capture:
You can also set the viewport show flags for a Scene Capture component in the advanced section of the scene capture properties:
- 1 like
Comment
Comment