Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal/master #8130

Merged
merged 22 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2f25ece
SRP Core Docs: In-Loop Render Requests
Jan 29, 2025
30fd3e1
[6000.1][UUM-90792] Fix camera sorting layer not breaking batch for …
kennytann Jan 29, 2025
8398732
[UUM-92418] Help link color
iTris666 Jan 29, 2025
4b8452b
[VFX][Fix] Fix error when deleting specific blocks
ludovic-theobald Jan 29, 2025
b0f8ac8
Docs feedback fixes January 2025 part 3
markg-unity Jan 29, 2025
7609e85
Fixed the generation of new artifact ID of ShaderGraph on every reimp…
Jan 29, 2025
a2411d7
[UUM-94425] fix: correct #if mismatch for PBRDeferredFragment() funct…
H3idi-X Jan 29, 2025
20a1dd4
DOCG-6227: Make water scripting section outcome-based: Foam
ocarrere Jan 30, 2025
fc7f76e
DOCG-6520: Missing Reference Documentation for Color Checker Tool
ocarrere Jan 30, 2025
2081d87
DOCG-6172 Document bicubic lightmap sampling
fatimah-f Jan 30, 2025
97e0eb0
[VFX][Fix] Ray-tracing shader compilation errors
ludovic-theobald Jan 30, 2025
bdcb755
[VFX] Undoing slider value change not updating float field
julienamsellem Jan 30, 2025
2c0d65b
Docs feedback fixes January 2025 part 4
markg-unity Jan 30, 2025
d0bc8f1
HDRP_Tests: Ref-image optimization step.
amsXYZ Jan 31, 2025
b2d9c3e
[VFX] Template window can be empty because of an exception with packa…
julienamsellem Jan 31, 2025
8ad8e60
UUM-92512: Light Cookie Atlas is leaking
pigselated Jan 31, 2025
31eac92
[UUM-92615] Fix for supercollapse happening with left click then righ…
iTris666 Jan 31, 2025
ef4ac3d
[UUM-92200] Force SafeNormalize when blending DBuffer normals
Jan 31, 2025
5576dbc
[UUM-84357] Fix issues when resizing Main Preview subwindow
dhsavell Jan 31, 2025
43d3d0e
[UUM-92520][UUM-95346][UUM-95620] Various vfx toolbar tweaks
iTris666 Jan 31, 2025
6a2ca0c
[SRPF] Updated camera component help url
kirill-titov-u Jan 31, 2025
931fb72
[HDRP][Fix] Prevent sensor SDK related compilation error on DXR-enabl…
ludovic-theobald Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [Free Camera](Free-Camera.md)
* [Camera Switcher](Camera-Switcher.md)
* [Render Requests](User-Render-Requests.md)
* [Render from another camera inside a camera's rendering loop](in-loop-render-requests.md)
* [Render Graph](render-graph-system.md)
* [Benefits of the render graph system](render-graph-benefits.md)
* [Render graph fundamentals](render-graph-fundamentals.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Render from another camera inside a camera's rendering loop

Render from cameras nested inside the render loop of other cameras.

Attach the provided script to a GameObject with a Camera component to nest multiple cameras, that are rendering with [RenderPipeline.SubmitRenderRequest](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipeline.SubmitRenderRequest.html), inside the render loop of other cameras.

**Note**: If your project uses the [Universal Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest/index.html) (URP), the recommended best practice is to use [UniversalRenderPipeline.SingleCameraRequest](https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.Rendering.Universal.UniversalRenderPipeline.SingleCameraRequest.html) instead of [StandardRequest](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipeline.StandardRequest.html), to make sure you only render the camera provided to the `RenderRequest` API instead of the full stack of cameras.

## Attach the script to nest

Follow these steps:

1. Create a new C# script.
2. Add the `using` statements shown below and the `RequireComponent` attribute with the `Camera` type.

```c#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

[RequireComponent(typeof(Camera))]
public class InLoopRenderRequest : MonoBehaviour
{

}
```

3. Add a property with the type `Camera` to the `InLoopRenderRequest` class.
4. Add a property with the type `RenderTexture` for each callback the camera uses, as shown below:

```c#
[RequireComponent(typeof(Camera))]
public class InLoopRenderRequest : MonoBehaviour
{
public Camera renderRequestCamera;

public RenderTexture onBeginCameraRendering;
public RenderTexture onBeginContextRendering;
public RenderTexture onEndCameraRendering;
public RenderTexture onEndContextRendering;
}
```

## Full code example

The following is an example of the finalized code which you attach to the secondary camera:

```c#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

[RequireComponent(typeof(Camera))]
public class InLoopRenderRequest : MonoBehaviour
{
// Add a reference to the secondary camera that will render the textures
// It's recommended to disable the secondary camera.
public Camera renderRequestCamera;

// Add references to the Render Textures that will contain the rendered image from the secondary camera.
public RenderTexture onBeginCameraRendering;
public RenderTexture onBeginContextRendering;
public RenderTexture onEndCameraRendering;
public RenderTexture onEndContextRendering;

void OnEnable()
{
// Subscribe to the RenderPipelineManager callbacks
RenderPipelineManager.beginCameraRendering += OnBeginCameraRender;
RenderPipelineManager.beginContextRendering += OnBeginContextRendering;
RenderPipelineManager.endCameraRendering += OnEndCameraRender;
RenderPipelineManager.endContextRendering += OnEndContextRendering;
}

public void OnDisable()
{
// Unsubscribe to the callbacks from RenderPipelineManager when we disable the component
RenderPipelineManager.beginCameraRendering -= OnBeginCameraRender;
RenderPipelineManager.beginContextRendering -= OnBeginContextRendering;
RenderPipelineManager.endCameraRendering -= OnEndCameraRender;
RenderPipelineManager.endContextRendering -= OnEndContextRendering;
}

void SubmitStandardRenderRequest(RenderTexture rt, Camera cam)
{
RenderPipeline.StandardRequest request = new();

// Check that the Scriptable Render Pipeline (SRP) we're using supports the given render data.
if (RenderPipeline.SupportsRenderRequest(cam, request))
{
// Set the request RenderTexture
request.destination = rt;

// Render the camera output to the RenderTexture synchronously
// When this is complete, the RenderTexture in renderTextures[i] contains the scene rendered from the point of view of the secondary cameras
RenderPipeline.SubmitRenderRequest(cam, request);
}
}

// StandardRequest and UniversalRenderPipeline.SingleCameraRequest also trigger RenderPipelineManager callbacks.
// Check that the callbacks are from the GameObject's Camera component to avoid a recursive rendering of the same camera.
private void OnBeginContextRendering(ScriptableRenderContext ctx, List<Camera> cams)
{
if (cams.Contains(GetComponent<Camera>()))
{
SubmitStandardRenderRequest(onBeginContextRendering, renderRequestCamera);
}
}

private void OnEndContextRendering(ScriptableRenderContext ctx, List<Camera> cams)
{
if (cams.Contains(GetComponent<Camera>()))
{
SubmitStandardRenderRequest(onEndContextRendering, renderRequestCamera);
}
}

private void OnBeginCameraRender(ScriptableRenderContext ctx, Camera cam)
{
if (cam == GetComponent<Camera>())
{
SubmitStandardRenderRequest(onBeginCameraRendering, renderRequestCamera);
}
}

private void OnEndCameraRender(ScriptableRenderContext ctx, Camera cam)
{
if (cam == GetComponent<Camera>())
{
SubmitStandardRenderRequest(onEndCameraRendering, renderRequestCamera);
}
}
}
```

## Additional resources
- [Render Requests](User-Render-Requests.md)
- [Creating a custom render pipeline](srp-custom.md)

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The section contains the following settings that let you define project-wide set

You can also add your own settings. Refer to [Add custom settings](https://docs.unity3d.com/Packages/[email protected]/manual/add-custom-graphics-settings.html) in the Scriptable Render Pipeline (SRP) Core manual for more information.

## Lightmap Sampling Settings

| **Property** | **Description** |
| --------------------------| ------------------------------------------------------------ |
| **Use Bicubic Lightmap Sampling** | Improves the visual fidelity of lightmaps by smoothening sharp or jagged edges, especially at the edges of shadows. Enabling this property might reduce performance on lower-end platforms. |

## Additional Shader Stripping Settings

| **Property** | **Description** |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ Use HDRP's water system to create and control realistic water surfaces. HDRP's w
- Simulation-based caustics.
- Underwater rendering.
- Deformer.
- Foam Generator.
- Foam.
- Water Excluder.
- A mirrored simulation on the CPU for high-fidelity game interactions.
- A shader graph interaction for advanced visual customization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This sample includes examples on how to create a [Fullscreen Shader](create-a-fu
The Water samples contain the following scenes you can use to learn about HDRP's [Water](water.md) features:

- Pool: Demonstrates ripples and buoyancy.
- Glacier: Demonstrates current, water deformers, floating objects, and a water mask.
- Glacier: Demonstrates current, water deformers, floating objects, and a simulation mask.
- Island: Demonstrates waves, foam, and the water excluder.
- Rain: Demonstrates how to add pertubations to the normals using shader graph.
- Waterline: Demonstrates how to override rendering of the waterline using a [Custom Pass](Custom-Pass.md).
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ To make HDRP calculate ray tracing effects for [Cameras](hdrp-camera-component-r

To enable ray tracing by default:

1. Open the Project Settings window (menu: **Edit > Project Settings**), then select the HDRP Default Settings tab.
2. Select Camera from the Default Frame Settings For drop-down.
3. In the **Rendering** section, enable **Ray Tracing**.
1. From the main menu, select **Edit** &gt; **Project Settings**.
2. In the **Project Settings** window, go to the **Pipeline Specific Settings** section, then select the **HDRP** tab.
3. Under **Frame Settings (Default Values)** &gt; **Camera** &gt; **Rendering**, enable **Ray Tracing**.

To enable ray tracing for a specific Camera:
To enable ray tracing for a specific camera:

1. Click on the Camera in the Scene or Hierarchy to view it in the Inspector.
2. In the **General** section, enable **Custom Frame Settings**. This exposes Frame Settings just for this Camera.
3. in the **Rendering** section, enable **Ray Tracing**.
1. Select the camera in the scene or **Hierarchy** window to view it in the **Inspector** window.
2. In the **Rendering** section, enable **Custom Frame Settings**. This exposes frame settings for this camera only.
3. Use the foldout (triangle) to expand **Rendering**, then enable **Ray Tracing**.

#### Build settings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,13 @@
* [Enable mask and water decals](enable-mask-and-water-decals.md)
* [Configure swell, agitation, or ripples](add-swell-agitation-or-ripples.md)
* [Simulating currents with water decals](simulating-currents-with-water-decals.md)
* [Simulating foam or ripples with masks](simulating-foam-or-ripples-with-masks.md)
* [Simulating ripples with masks](simulating-foam-or-ripples-with-masks.md)
* [Decals and masking in the water system](water-decals-and-masking-in-the-water-system.md)
* [Foam in the Water System](water-foam-in-the-water-system.md)
* [Introduction to foam](introduction-to-foam.md)
* [Create wind-driven foam on the whole water surface](create-wind-driven-foam-on-the-whole-water-surface.md)
* [Create local foam in the wake of a GameObject](create-local-foam-in-the-wake-of-a-gameobject.md)
* [Add foam with a script](add-foam-with-script.md)
* [Caustics in the Water System](water-caustics-in-the-water-system.md)
* [Create a current in the Water System](water-create-a-current-in-the-water-system.md)
* [Deform a water surface](water-deform-a-water-surface.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Add caustics or foam and check waves and ripples
# Add caustics and check waves and ripples

To add caustics or foam, or get information about water surface displacement due to waves and ripples, get buffers from the [`WaterSurface`](xref:UnityEngine.Rendering.HighDefinition.WaterSurface) class:
To add caustics or get information about water surface displacement due to waves and ripples, get buffers from the [`WaterSurface`](xref:UnityEngine.Rendering.HighDefinition.WaterSurface) class:

| Action | API |
|-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Add caustics | [GetCausticsBuffer](../api/UnityEngine.Rendering.HighDefinition.WaterSurface.html#UnityEngine_Rendering_HighDefinition_WaterSurface_GetCausticsBuffer_System_Single__) |
| Add foam | [GetFoamBuffer](../api/UnityEngine.Rendering.HighDefinition.WaterSurface.html#UnityEngine_Rendering_HighDefinition_WaterSurface_GetFoamBuffer_UnityEngine_Vector2__) |
| Check waves and ripples | [GetDeformationBuffer](../api/UnityEngine.Rendering.HighDefinition.WaterSurface.html#UnityEngine_Rendering_HighDefinition_WaterSurface_GetDeformationBuffer) |

## Example: Add caustics
Expand Down Expand Up @@ -44,45 +43,6 @@ public class WaterCausticsExample : MonoBehaviour
}
```

## Example: Add foam

```
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

public class WaterFoamExample : MonoBehaviour
{
// Reference to the water surface component
public WaterSurface waterSurface;

// The area of the water surface where the foam buffer should be queried
public Vector2 foamArea;

// Material to apply the foam effect
public Material waterMaterial;

// Shader property name for foam texture in the water material
private readonly string _foamTextureProperty = "_FoamTex";

void Start()
{
// Get the foam buffer for the specified 2D area on the water surface
Texture foamBuffer = waterSurface.GetFoamBuffer(out foamArea);

if (foamBuffer != null)
{
// Apply the foam buffer as a texture to the water material
waterMaterial.SetTexture(_foamTextureProperty, foamBuffer);
Debug.Log("Foam buffer applied successfully.");
}
else
{
Debug.LogWarning("Foam buffer could not be retrieved.");
}
}
}
```

## Example: Check waves and ripples

```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Add foam with a script

To add caustics or foam, or get information about water surface displacement due to waves and ripples, get buffers from the [GetFoamBuffer](../api/UnityEngine.Rendering.HighDefinition.WaterSurface.html#UnityEngine_Rendering_HighDefinition_WaterSurface_GetFoamBuffer_UnityEngine_Vector2__) API.

## Example: Add foam

```
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

public class WaterFoamExample : MonoBehaviour
{
// Reference to the water surface component
public WaterSurface waterSurface;

// The area of the water surface where the foam buffer should be queried
public Vector2 foamArea;

// Material to apply the foam effect
public Material waterMaterial;

// Shader property name for foam texture in the water material
private readonly string _foamTextureProperty = "_FoamTex";

void Start()
{
// Get the foam buffer for the specified 2D area on the water surface
Texture foamBuffer = waterSurface.GetFoamBuffer(out foamArea);

if (foamBuffer != null)
{
// Apply the foam buffer as a texture to the water material
waterMaterial.SetTexture(_foamTextureProperty, foamBuffer);
Debug.Log("Foam buffer applied successfully.");
}
else
{
Debug.LogWarning("Foam buffer could not be retrieved.");
}
}
}
```
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Configure swell, agitation, or ripples with a water mask
# Configure swell, agitation, or ripples with a simulation mask

To configure swell, agitation or ripples, use a Water Mask to affect the influence the simulation has on specific areas of the water surface.
To configure swell, agitation, or ripples, use a simulation mask to affect the influence the simulation has on specific areas of the water surface.

Masks take into account the Wrap Mode of the texture. For Ocean, Sea, or Lake water surface types, select **Clamp** rather than the default **Repeat** value.

To add a Water Mask:
To add a simulation mask:

1. Create and import a texture where the color channels represent the fluctuations.

Expand All @@ -21,7 +21,7 @@ To add a Water Mask:

The darker the color of a channel, the lesser the effect. For example, use white for 100% intensity and black for 0% intensity.

1. In the Water Volume Inspector window, drag the texture to the **Water Mask** property.
1. In the Water Volume Inspector window, drag the texture to the **Simulation Mask** property.

<table>
<tr>
Expand All @@ -34,7 +34,7 @@ To add a Water Mask:
</tr>
<tr>
<td colspan="2">
In this example, the red channel has a gradient that reduces the first and second simulation bands. The noise on the green channel reduces ripples. For more information, refer to the <a href="settings-and-properties-related-to-the-water-system.md#watermask">Water Mask property description</a>.
In this example, the red channel has a gradient that reduces the first and second simulation bands. The noise on the green channel reduces ripples. For more information, refer to the <a href="settings-and-properties-related-to-the-water-system.md#simulationmask">Simulation Mask property description</a>.
</td>
</tr>
</table>
Loading