In unreal engine 5's composure, how would I isolate hair groom and then render it as a…
- User
In unreal engine 5's composure, how would I isolate hair groom and then render it as a separate alpha matte but including the shadows from the objects (which are hidden)
- Assistant
To achieve isolation of the hair groom and render it as a separate alpha matte while including shadows from hidden objects in Unreal Engine 5's Composure, you need to manipulate object visibility and rendering settings strategically. Here's a step-by-step guide to accomplish this:
1. Hide Objects but Enable Their Shadows
Firstly, you need to hide the objects in the scene that you don't want to appear in the render but still want their shadows to affect the hair groom.
For each object you want to hide but retain shadows:
-
Select the Object(s):
- In the World Outliner, select the object(s) you wish to hide.
-
Modify Rendering Properties:
- In the Details panel, locate the Rendering category.
- Uncheck the Visible property. This will hide the object from rendering.
- Enable "Cast Hidden Shadow":
- Still within the Rendering category, check the Cast Hidden Shadow option. This allows the object to cast shadows even when it's not visible.
2. Ensure Hair Groom Receives Shadows
Make sure that the hair groom is set up to receive shadows from the hidden objects.
-
Select the Hair Groom Actor:
- In the World Outliner, select your hair groom actor.
-
Verify Shadow Settings:
- In the Details panel, under Rendering, ensure that Receive Shadows is checked.
- Also, confirm that Cast Shadows is enabled so the hair can cast shadows if necessary.
3. Enable Alpha Channel Support
To render an alpha matte, you need to ensure that Unreal Engine is set up to support outputting alpha channels.
- Project Settings Configuration:
- Go to Edit > Project Settings > Rendering.
- Scroll down to the Postprocessing section.
- Enable Alpha Channel (Export Through Compositing, HDR Output).
- Note: In UE5, this setting allows rendering of alpha channels in rendered frames.
4. Set Up Composure Compositing Elements
Now, set up Composure to isolate and render the hair groom with the alpha matte.
-
Add a Composure Compositing Element:
- In the Content Browser, create a new Compositing > Compositing Shot or Compositing Element.
-
Configure the Compositing Layer:
- Double-click the compositing element to open it.
- Add a CG Layer Element to the compositing element.
- **Set the Layer Name to something recognizable, like "HairGroomLayer".
-
Assign the Hair Groom to the Layer:
- Within the compositing element, select the HairGroomLayer.
- In the Details panel, under Input, assign the Actor to your hair groom actor.
- This ensures only the hair groom is rendered in this layer.
5. Utilize Custom Stencil for Alpha Matte
To generate an alpha matte of the hair groom, utilize the Custom Stencil buffer.
-
Enable Custom Depth and Stencil Passes in Project Settings:
- Go to Edit > Project Settings > Rendering.
- Under Postprocessing, set Custom Depth-Stencil Pass to Enabled with Stencil.
- Ensure that Allow Custom Depth Writes is enabled.
-
Configure the Hair Groom for Custom Stencil:
- Select the hair groom actor in your scene.
- In the Details panel, under Rendering, do the following:
- Enable Render CustomDepth Pass.
- Set the CustomDepth Stencil Value to an unused integer between 0 and 255 (e.g., 1).
6. Capture the Custom Stencil Buffer in Composure
Within Composure, set up a Material Pass to use the Custom Stencil buffer as an alpha matte.
-
Add a Material Pass to the Compositing Layer:
- In the compositing element for the hair groom, add a Material Pass after the CG Layer.
-
Create a Material for the Alpha Matte:
- In the Content Browser, create a new Material (e.g., "M_AlphaMatte").
- Set Material Domain to Post Process.
- Set Blendable Location to After Tonemapping.
-
Material Setup:
- In the material's Graph Editor, set up the nodes as follows:
- Scene Texture Node:
- Add a SceneTexture node.
- Set Scene Texture Id to SceneStencil.
- Compare Stencil Value:
- Add an Equal (Integer) node.
- Connect the SceneTexture output to one input.
- Set the other input to the Stencil Value you assigned earlier (e.g., 1).
- Convert to Float:
- Add a Float conversion if necessary (using a Multiply node with 1.0).
- Output to Opacity:
- Connect the result to the Opacity output of the material.
- Scene Texture Node:
- In the material's Graph Editor, set up the nodes as follows:
-
Assign Material to Material Pass:
- Back in the compositing element, assign the M_AlphaMatte material to the Material Pass.
7. Adjust Composure Output for Alpha
-
Set Output Settings:
- In the compositing element's Output settings, ensure that the output format supports alpha channels (e.g., RGBA8).
-
Preview the Result:
- In the Composure editor viewport, you should now see only the hair groom with an alpha matte, including the shadows from the hidden objects.
8. Render the Compositing Shot
- Render Sequence:
- Use the Sequencer to render out the compositing shot.
- Ensure that the rendering settings are set to output formats that include alpha channels (e.g., PNG sequence with RGBA).
Additional Tips:
-
Lighting Considerations:
- Ensure your lighting setup is such that shadows from the hidden objects are correctly cast onto the hair groom.
- For dynamic lighting, verify that Dynamic Shadows are enabled and properly configured.
-
Hair Material Opacity:
- If the hair groom material doesn't support alpha blending by default, you might need to adjust the material's blend mode.
- Open the hair material instance used by the groom.
- Ensure that Blend Mode is set to Masked or Translucent if necessary.
- If the hair groom material doesn't support alpha blending by default, you might need to adjust the material's blend mode.
-
Testing:
- It might be helpful to test the alpha matte with a simple object before applying it to the hair groom to ensure the setup works correctly.
By following these steps, you should be able to isolate the hair groom in Unreal Engine 5's Composure and render it as a separate alpha matte, including the shadows from objects that are hidden in the scene.
-