Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -526,8 +526,11 @@ private void InternalNVIDIARender(in DLSSPass.Parameters parameters, UpscalerRes
: parameters.drsSettings.DLSSSharpness;

dlssViewData.inputRes = new UpscalerResolution() { width = (uint)parameters.hdCamera.actualWidth, height = (uint)parameters.hdCamera.actualHeight };
dlssViewData.outputRes = new UpscalerResolution() { width = (uint)DynamicResolutionHandler.instance.finalViewport.x, height = (uint)DynamicResolutionHandler.instance.finalViewport.y };

dlssViewData.outputRes = new UpscalerResolution() {
width = (uint)parameters.hdCamera.finalViewport.width,
height = (uint)parameters.hdCamera.finalViewport.height
};

dlssViewData.jitterX = -parameters.hdCamera.taaJitter.x;
dlssViewData.jitterY = -parameters.hdCamera.taaJitter.y;
dlssViewData.reset = parameters.resetHistory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,10 @@ private void InternalAMDRender(
bool useCameraCustomAttributes = parameters.hdCamera.fidelityFX2SuperResolutionUseCustomAttributes;
var fsr2ViewData = new Fsr2ViewData();
fsr2ViewData.inputRes = new UpscalerResolution() { width = (uint)parameters.hdCamera.actualWidth, height = (uint)parameters.hdCamera.actualHeight };
fsr2ViewData.outputRes = new UpscalerResolution() { width = (uint)DynamicResolutionHandler.instance.finalViewport.x, height = (uint)DynamicResolutionHandler.instance.finalViewport.y };
fsr2ViewData.outputRes = new UpscalerResolution() {
width = (uint)parameters.hdCamera.finalViewport.width,
height = (uint)parameters.hdCamera.finalViewport.height
};
fsr2ViewData.jitterX = parameters.hdCamera.taaJitter.x;
fsr2ViewData.jitterY = parameters.hdCamera.taaJitter.y;
fsr2ViewData.reset = parameters.hdCamera.isFirstFrame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ private RenderPassInputSummary GetRenderPassInputs(UniversalCameraData cameraDat
|| cameraData.cameraTargetDescriptor.msaaSamples > 1 && UniversalRenderer.PlatformRequiresExplicitMsaaResolve()
|| m_Renderer2DData.useCameraSortingLayerTexture
|| !Mathf.Approximately(cameraData.renderScale, 1.0f)
|| (DebugHandler != null && DebugHandler.WriteToDebugScreenTexture(cameraData.resolveFinalTarget));
|| (DebugHandler != null && DebugHandler.WriteToDebugScreenTexture(cameraData.resolveFinalTarget))
|| cameraData.captureActions != null;

return inputSummary;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,18 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
// Early out for preview camera
if (cameraData.cameraType == CameraType.Preview)
isLitView = false;

DebugHandler debugHandler = GetActiveDebugHandler(cameraData);
if (debugHandler != null)
isLitView = debugHandler.IsLightingActive;
#endif

// Preset global light textures for first batch
if (batchIndex == 0)
{
using (var builder = graph.AddRasterRenderPass<SetGlobalPassData>(k_SetLightBlendTexture, out var passData, m_SetLightBlendTextureProfilingSampler))
{
if (layerBatch.lightStats.useLights)
if (layerBatch.lightStats.useLights && isLitView)
{
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
for (var i = 0; i < passData.lightTextures.Length; i++)
Expand Down Expand Up @@ -167,7 +171,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
builder.UseRendererList(passData.rendererList);
}

if (passData.layerUseLights)
if (passData.layerUseLights && isLitView)
{
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
for (var i = 0; i < passData.lightTextures.Length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal sealed partial class Renderer2D : ScriptableRenderer
DrawLight2DPass m_LightPass = new DrawLight2DPass();
DrawShadow2DPass m_ShadowPass = new DrawShadow2DPass();
DrawRenderer2DPass m_RendererPass = new DrawRenderer2DPass();
CapturePass m_CapturePass = new CapturePass(RenderPassEvent.AfterRendering);

LayerBatch[] m_LayerBatches;
int m_BatchCount;
Expand Down Expand Up @@ -792,6 +793,12 @@ private void OnAfterRendering(RenderGraph renderGraph)
var finalBlitTarget = resolveToDebugScreen ? commonResourceData.debugScreenColor : commonResourceData.backBufferColor;
var finalDepthHandle = resolveToDebugScreen ? commonResourceData.debugScreenDepth : commonResourceData.backBufferDepth;

// Capture pass for Unity Recorder
if (hasCaptureActions)
{
m_CapturePass.RecordRenderGraph(renderGraph, frameData);
}

if (applyFinalPostProcessing)
{
postProcessPass.RenderFinalPassRenderGraph(renderGraph, frameData, in finalColorHandle, commonResourceData.overlayUITexture, in finalBlitTarget, needsColorEncoding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
#define DEPTH_TEXTURE_MS(name, samples) Texture2DMSArray<float, samples> name
#define DEPTH_TEXTURE(name) TEXTURE2D_ARRAY_FLOAT(name)
#define LOAD(uv, sampleIndex) LOAD_TEXTURE2D_ARRAY_MSAA(_CameraDepthAttachment, uv, unity_StereoEyeIndex, sampleIndex)
#define SAMPLE(uv) SAMPLE_TEXTURE2D_ARRAY(_CameraDepthAttachment, sampler_CameraDepthAttachment, uv, unity_StereoEyeIndex).r
#define LOAD_MSAA(coord, sampleIndex) LOAD_TEXTURE2D_ARRAY_MSAA(_CameraDepthAttachment, coord, unity_StereoEyeIndex, sampleIndex)
#define LOAD(coord) LOAD_TEXTURE2D_ARRAY(_CameraDepthAttachment, coord, unity_StereoEyeIndex)
#else
#define DEPTH_TEXTURE_MS(name, samples) Texture2DMS<float, samples> name
#define DEPTH_TEXTURE(name) TEXTURE2D_FLOAT(name)
#define LOAD(uv, sampleIndex) LOAD_TEXTURE2D_MSAA(_CameraDepthAttachment, uv, sampleIndex)
#define SAMPLE(uv) SAMPLE_DEPTH_TEXTURE(_CameraDepthAttachment, sampler_CameraDepthAttachment, uv)
#define LOAD_MSAA(coord, sampleIndex) LOAD_TEXTURE2D_MSAA(_CameraDepthAttachment, coord, sampleIndex)
#define LOAD(coord) LOAD_TEXTURE2D(_CameraDepthAttachment, coord)
#endif

#if MSAA_SAMPLES == 1
DEPTH_TEXTURE(_CameraDepthAttachment);
SAMPLER(sampler_CameraDepthAttachment);
#else
DEPTH_TEXTURE_MS(_CameraDepthAttachment, MSAA_SAMPLES);
float4 _CameraDepthAttachment_TexelSize;
#endif

#if UNITY_REVERSED_Z
Expand All @@ -42,17 +40,17 @@
#define DEPTH_OP max
#endif

float SampleDepth(float2 uv)
float SampleDepth(float2 pixelCoords)
{
int2 coord = int2(pixelCoords);
#if MSAA_SAMPLES == 1
return SAMPLE(uv);
return LOAD(coord).r;
#else
int2 coord = int2(uv * _CameraDepthAttachment_TexelSize.zw);
float outDepth = DEPTH_DEFAULT_VALUE;

UNITY_UNROLL
for (int i = 0; i < MSAA_SAMPLES; ++i)
outDepth = DEPTH_OP(LOAD(coord, i), outDepth);
outDepth = DEPTH_OP(LOAD_MSAA(coord, i), outDepth);
return outDepth;
#endif
}
Expand All @@ -64,7 +62,7 @@ float frag(Varyings input) : SV_Target
#endif
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
return SampleDepth(input.texcoord);
return SampleDepth(input.positionCS.xy);
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Returns the result of converting the value of input **In** from one colorspace s
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| From | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert from |
| To | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert to |
| To | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert to. Returns values in the range 0 to 1, or higher if the color space is HDR. |

## Generated Code Example

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
# HD Scene Color Node
# HD Scene Color node

The HD Scene Color Node does the same thing as the Scene Color Node, but allows you to access the mips of the color buffer.
The HD Scene Color node samples the color buffer of the current camera, using the screen space coordinates you input. The node works the same way as the [Scene Color Node](Scene-Color-Node.md) but returns the mipmap levels of the color buffer.

## Render pipeline compatibility
To make sure the HD Scene Color node outputs the correct values, follow these steps:

| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** |
| -------------- | ----------------------------------- | ------------------------------------------ |
| HD Scene Color | No | Yes |
1. Connect the node to the fragment [shader stage](Shader-Stage.md). The HD Scene Color node doesn't support the vertex shader stage.
2. In the **Graph Settings** tab of the [**Graph Inspector**](Internal-inspector.md) window, set **Surface Type** to **Transparent**. Otherwise, the node samples the color buffer before Unity renders all the opaque contents in the scene.

The node uses trilinear clamp mode to sample the color buffer, so it smoothly interpolates between the mipmap levels.

## Render pipeline support

The HD Scene Color node supports the High Definition Render Pipeline (HDRP) only. If you use the node with an unsupported pipeline, it returns 0 (black).

If you use your own custom render pipeline, you must define the behavior of the node yourself. Otherwise, the node returns a value of 0 (black).

## Ports

| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| **UV** | Input | Vector 4 | Screen Position | Sets the normalized screen coordinates to sample. |
| **Lod** | Input | float | None | Sets the mip level that the sampler uses to sample the color buffer. |
| **Output** | Output | Vector 3 | None | Output value |
| Name | Direction | Type | Binding | Description |
|:--|:--|:--|:--|:--|
| **UV** | Input | Vector 4 | Screen position | The normalized screen space coordinates to sample from. |
| **Lod** | Input | float | None | The mipmap level to sample. |
| **Output** | Output | Vector 3 | None | The color value from the color buffer at the coordinates and mipmap level. |

## Properties

## Notes
### Exposure
| **Property** | **Description** |
|-|-|
| **Exposure** | Applies [exposure](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Override-Exposure.html) to the camera color. This property is disabled by default to avoid double exposure. |

You can use the Exposure property to specify if you want to output the Camera color with exposure applied or not. By default, this property is disabled to avoid double exposure.
## Additional resources

The sampler that this Node uses to sample the color buffer is in trilinear clamp mode. This allows the sampler to smoothly interpolate between the mip maps.
- [Scene Color Node](Scene-Color-Node.md)
- [Custom pass buffers and pyramids](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Custom-Pass-buffers-pyramids.html)
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Defines a [Cubemap](https://docs.unity3d.com/Manual/class-Cubemap.html) value. D
<a name="virtual-texture"> </a>
## Virtual Texture

Defines a [Texture Stack](https://docs.unity3d.com/2020.1/Documentation/Manual/svt-use-in-shader-graph.html), which appears as object fields of type [Texture](https://docs.unity3d.com/Manual/class-TextureImporter.html) in the Material Inspector. The number of fields correspond to the number of layers in the property.
Defines a [Texture Stack](https://docs.unity3d.com/Manual/svt-use-in-shader-graph.html), which appears as object fields of type [Texture](https://docs.unity3d.com/Manual/class-TextureImporter.html) in the Material Inspector. The number of fields corresponds to the number of layers in the property.

| Data Type | Modes |
|:----------|-------|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Feature Examples
# Feature Examples sample

The Shader Graph Feature Examples sample content is a collection of Shader Graph assets that demonstrate how to achieve common techniques and effects in Shader Graph. The goal of this sample pack is to help users see what is required to achieve specific effects and provide examples to make it easier for users to learn.

Each sample contains notes that describe what the shader does. Most of the shaders have their core functionality in a subgraph, so you can copy and paste them into your own shader graphs.

The sample content is broken into the following categories:

- **Blending Masks** - these samples generate masks based on characteristics of the surface - such as height, facing angle, or distance from the camera.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Node Reference sample

This set of Shader Graph assets provides reference material for the nodes available in the Shader Graph node library.

Each graph contains a description for a specific node, examples of how it can be used, and useful tips. Some example assets also show a break-down of the math that the node is doing. You can use these samples along with the documentation to learn more about the behavior of individual nodes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Procedural Patterns sample

This collection of Assets showcases various procedural techniques possible with Shader Graph. Use them directly in your Project, or edit them to create other procedural patterns.

This collection includes the following patterns:

* Bacteria
* Brick
* Dots
* Grid
* Herringbone
* Hex Lattice
* Houndstooth
* Smooth Wave
* Spiral
* Stripes
* Truchet
* Whirl
* Zig Zag
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Production Ready Shaders
# Production Ready Shaders sample

The Shader Graph Production Ready Shaders sample is a collection of Shader Graph shader assets that are ready to be used out of the box or modified to suit your needs. You can take them apart and learn from them, or just drop them directly into your project and use them as they are. The sample also includes a step-by-step tutorial for how to combine several of the shaders to create a forest stream environment.

The sample content is broken into the following categories:
The Shader Graph Production Ready Shaders sample is a collection of Shader Graph shader assets that are ready to be used out of the box or modified to suit your needs. You can take them apart and learn from them, or just drop them directly into your project and use them as they are. The sample includes the Shader Graph versions of the HDRP and URP Lit shaders. It also includes a step-by-step tutorial for how to combine several of the shaders to create a forest stream environment.

| Topic | Description |
|:------|:--------------|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# UGUI Shaders
![The Shader Graph UGUI Shaders: A collection of Shader Graph subgraphs that serve as building blocks for building user interface elements.](images/UIToolsSample.png)
# UGUI Shaders sample

The Shader Graph UGUI Shaders sample is a collection of Shader Graph subgraphs that serve as building blocks for building user interface elements. They speed up the process of building widgets, buttons, and backgrounds for the user interface of your project. Using these tools, you can build dynamic, procedural UI elements that don’t require any texture memory and scale correctly for any resolution screen.
The Shader Graph UGUI Shaders sample is a collection of Shader Graph subgraphs that you can use to build user interface elements. They speed up the process of building widgets, buttons, and backgrounds for the user interface of your project. With these tools, you can build dynamic, procedural UI elements that don’t require any texture memory and scale correctly for any resolution screen.

In addition to the subgraphs, the sample also includes example buttons, indicators, and backgrounds built using the subgraphs. The examples show how the subgraphs function in context and help you learn how to use them.

We have two main objectives with this sample set:
This sample set covers two main objectives:


- Demonstrate Shader Graph’s ability to create dynamic, resolution-independent user interface elements in a wide variety of shapes and styles.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Import Shader Graph samples

To import a Shader Graph sample to your project:

1. In the main menu, go to **Window** > **Package Management** > **Package Manager**.

1. Select **Shader Graph** from the list of packages.

1. In the **Samples** section, select **Import** next to a sample.

To open a sample, go to the `Assets/Samples/Shader Graph/<your version>/` folder.

## Additional resources

* [Shader Graph samples](ShaderGraph-Samples.md)
Loading
Loading