Announcement

Collapse
No announcement yet.

Hiding certain objects from being drawn on a camera or SceneCapture2D object.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hiding certain objects from being drawn on a camera or SceneCapture2D object.

    Is there a way to cull certain objects from a camera's view?

    #2
    I would love to know the answer too.
    David Hanson
    You can follow our FPS development here: https://www.facebook.com/storm.united.mmofps

    Comment


      #3
      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
      2) I'd add some helper functions to USceneComponent exposed to Blueprint that help me add components and actors to it:
      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);
      3) Modify FScene::UpdateSceneCaptureContents / FScene::CreateSceneRenderer to take my list of components and add them to the set of hidden primitives on the view:
      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);
      	}
      }
      If someone here gives it a go, tests it, and it all works add a pull request and you can help us get it in more quickly!
      Nick Penwarden, Lead Programmer @ Epic Games

      Comment


        #4
        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


          #5
          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


            #6
            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


              #7
              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;
              See FPrimitiveSceneProxy::IsShadowCast for the code that decides whether a primitive casts a shadow or not.
              Nick Penwarden, Lead Programmer @ Epic Games

              Comment


                #8
                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


                  #9
                  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 Nick
                  David Hanson
                  You can follow our FPS development here: https://www.facebook.com/storm.united.mmofps

                  Comment


                    #10
                    I've integrated your pull request in to main and it will be in 4.3. Thanks for the submission bigzer!
                    Nick Penwarden, Lead Programmer @ Epic Games

                    Comment


                      #11
                      Was this implemented? I can't find anything about it on 4.5.
                      | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                      Comment


                        #12
                        I'd also be interested in knowing
                        Follow me on Twitter!
                        Developer of Elium - Prison Escape
                        Local Image-Based Lighting for UE4

                        Comment


                          #13
                          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


                            #14
                            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:

                            Click image for larger version

Name:	SceneCaptureHideComponent.png
Views:	2
Size:	71.6 KB
ID:	1072472

                            You can also set the viewport show flags for a Scene Capture component in the advanced section of the scene capture properties:

                            Click image for larger version

Name:	SceneCaptureComponentShowFlags.png
Views:	1
Size:	35.5 KB
ID:	1072473

                            Comment


                              #15
                              How do you get to this advanced panel ? I don't see anything like that on my scenecapture2D component. The last thing from this screenshot I see is Max View Distance Override, and then I see Film right after that, but no advanced props.

                              Comment

                              Working...
                              X