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 @@ -11,7 +11,6 @@

UNIFIED_RT_DECLARE_ACCEL_STRUCT(_AccelStruct);


int _SampleCount;
int _SampleId;
int _MaxBounces;
Expand All @@ -34,11 +33,13 @@ void RayGenExecute(UnifiedRT::DispatchInfo dispatchInfo)
QrngSobol rngState;
rngState.Init(uint2((uint)probeId, 0), _SampleId);

if (_SampleId==0)
float4 skyOcclusionEstimate = 0;
float3 skyShadingEstimate = 0;
if (_SampleId != 0)
{
_SkyOcclusionOut[probeId] = float4(0,0,0,0);
skyOcclusionEstimate = _SkyOcclusionOut[probeId];
if (_BakeSkyShadingDirection > 0)
_SkyShadingOut[probeId] = float3(0,0,0);
skyShadingEstimate = _SkyShadingOut[probeId];
}

UnifiedRT::RayTracingAccelStruct accelStruct = UNIFIED_RT_GET_ACCEL_STRUCT(_AccelStruct);
Expand Down Expand Up @@ -107,47 +108,50 @@ void RayGenExecute(UnifiedRT::DispatchInfo dispatchInfo)
rayFirstDirection.y * norm * kSHBasis1,
rayFirstDirection.z * norm * kSHBasis1);

_SkyOcclusionOut[probeId] += tempSH;
skyOcclusionEstimate += tempSH;

if(_BakeSkyShadingDirection > 0)
_SkyShadingOut[probeId] += ray.direction / _SampleCount;
skyShadingEstimate += ray.direction / _SampleCount;

// break the loop;
bounceIndex = _MaxBounces + 2;
break;
}
}

// Last sample
if (_SampleId == _SampleCount - 1)
{
// Window L1 coefficients to make sure no value is negative when sampling SH, layout is DC, x, y, z
float4 SHData = _SkyOcclusionOut[probeId];
// find main direction for light
float3 mainDir;
mainDir.x = SHData.y;
mainDir.y = SHData.z;
mainDir.z = SHData.w;
mainDir.x = skyOcclusionEstimate.y;
mainDir.y = skyOcclusionEstimate.z;
mainDir.z = skyOcclusionEstimate.w;
mainDir = normalize(mainDir);

// find the value in the opposite direction, which is the lowest value in the SH
float4 temp2 = float4(kSHBasis0, kSHBasis1 * -mainDir.x, kSHBasis1 * -mainDir.y, kSHBasis1 * -mainDir.z);
float value = dot(temp2, SHData);
float value = dot(temp2, skyOcclusionEstimate);
float windowL1 = 1.0f;

if (value < 0.0f)
{
// find the L1 factor for this value to be null instead of negative
windowL1 = -(temp2.x * SHData.x) / dot(temp2.yzw, SHData.yzw);
windowL1 = -(temp2.x * skyOcclusionEstimate.x) / dot(temp2.yzw, skyOcclusionEstimate.yzw);
windowL1 = saturate(windowL1);
}

_SkyOcclusionOut[probeId].yzw *= windowL1;
skyOcclusionEstimate.yzw *= windowL1;

float radianceToIrradianceFactor = 2.0f / 3.0f;
// This is a hacky solution for mitigating the radianceToIrradianceFactor based on the previous windowing operation.
// The 1.125f exponent comes from experimental testing. It's the value that works the best when trying to match a bake and deringing done with the lightmapper, but it has no theoretical explanation.
// In the future, we should replace these custom windowing and deringing operations with the ones used in the lightmapper to implement a more academical solution.
_SkyOcclusionOut[probeId].yzw *= lerp(1.0f, radianceToIrradianceFactor, pow(windowL1, 1.125f));
skyOcclusionEstimate.yzw *= lerp(1.0f, radianceToIrradianceFactor, pow(windowL1, 1.125f));
}

_SkyOcclusionOut[probeId] = skyOcclusionEstimate;
if(_BakeSkyShadingDirection > 0)
_SkyShadingOut[probeId] = skyShadingEstimate;
}

#ifdef UNIFIED_RT_BACKEND_COMPUTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ struct APVResources

struct APVResourcesRW
{
#ifdef SHADER_API_METAL
// We need to use float4 on Metal, since HLSLcc will generate invalid MSL otherwise.
// See https://jira.unity3d.com/browse/UUM-127198
RWTexture3D<float4> L0_L1Rx;
#else
RWTexture3D<half4> L0_L1Rx;
#endif
RWTexture3D<unorm float4> L1G_L1Ry;
RWTexture3D<unorm float4> L1B_L1Rz;
RWTexture3D<unorm float4> L2_0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ Texture3D<float4> _State1_L0_L1Rx;
Texture3D<float4> _State1_L1G_L1Ry;
Texture3D<float4> _State1_L1B_L1Rz;

#ifdef SHADER_API_METAL
// We need to use float4 on Metal, since HLSLcc will generate invalid MSL otherwise.
// See https://jira.unity3d.com/browse/UUM-127198
RWTexture3D<float4> _Out_L0_L1Rx;
#else
RWTexture3D<half4> _Out_L0_L1Rx;
#endif
RWTexture3D<unorm float4> _Out_L1G_L1Ry;
RWTexture3D<unorm float4> _Out_L1B_L1Rz;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
#pragma multi_compile_local _ PROBE_VOLUMES_SKY_SHADING_DIRECTION
#pragma multi_compile_local _ PROBE_VOLUMES_PROBE_OCCLUSION

#ifdef SHADER_API_METAL
// We need to use float4 on Metal, since HLSLcc will generate invalid MSL otherwise.
// See https://jira.unity3d.com/browse/UUM-127198
RWTexture3D<float4> _Out_L0_L1Rx;
#else
RWTexture3D<half4> _Out_L0_L1Rx;
#endif
RWTexture3D<unorm float4> _Out_L1G_L1Ry;
RWTexture3D<unorm float4> _Out_L1B_L1Rz;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ Set up a project to use the High Definition Render Pipeline (HDRP), and use Volu
## Additional resources

- [HDRP overview](HDRP-Features.md)
- [Achieving High Fidelity Graphics for Games with HDRP](https://resources.unity.com/unitenow/onlinesessions/achieving-high-fidelity-graphics-for-games-with-hdrp)
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ internal static class Styles
public static readonly GUIContent lightProbeSystemContent = EditorGUIUtility.TrTextContent("Light Probe System", "What system to use for Light Probes.");
public static readonly GUIContent probeVolumeMemoryBudget = EditorGUIUtility.TrTextContent("Memory Budget", "Determines the width and height of the 3D textures used to store lighting data from probes. Depth is fixed.");
public static readonly GUIContent probeVolumeBlendingMemoryBudget = EditorGUIUtility.TrTextContent("Blending Memory Budget", "Determines the width and height of the 3D textures used to store light scenario blending data from probes. Depth is fixed.");
public static readonly GUIContent supportProbeVolumeGPUStreaming = EditorGUIUtility.TrTextContent("Enable GPU Streaming", "Enable steaming of Cells for Adaptive Probe Volumes.");
public static readonly GUIContent supportProbeVolumeDiskStreaming = EditorGUIUtility.TrTextContent("Enable Disk Streaming", "Enable steaming of Cells from disk for Adaptive Probe Volumes.");
public static readonly GUIContent supportProbeVolumeGPUStreaming = EditorGUIUtility.TrTextContent("Enable GPU Streaming", "Enable streaming of Cells for Adaptive Probe Volumes.");
public static readonly GUIContent supportProbeVolumeDiskStreaming = EditorGUIUtility.TrTextContent("Enable Disk Streaming", "Enable streaming of Cells from disk for Adaptive Probe Volumes.");
public static readonly GUIContent supportProbeVolumeScenarios = EditorGUIUtility.TrTextContent("Enable Lighting Scenarios", "Enable Lighting Scenario Baking for Adaptive Probe Volumes.");
public static readonly GUIContent supportProbeVolumeScenarioBlending = EditorGUIUtility.TrTextContent("Enable Lighting Scenario Blending", "Enable Lighting Scenario Blending for Adaptive Probe Volumes.\nNote: Lighting Scenario Blending requires Compute Shader support.");
public static readonly GUIContent probeVolumeSHBands = EditorGUIUtility.TrTextContent("SH Bands", "The number of Spherical Harmonic bands used by Adaptive Probe Volumes to store lighting data. Choosing L2 provides better quality but with higher memory and runtime costs.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public sealed class TextureResources : IRenderPipelineResources
/// <summary>
/// Pre-baked Blue noise textures.
/// </summary>
// [ResourceFormattedPaths("Textures/BlueNoise16/L/LDR_LLL1_{0}.png", 0, 32)]
[ResourceFormattedPaths("Textures/BlueNoise16/L/LDR_LLL1_{0}.png", 0, 32)]
public Texture2D[] blueNoise16LTex;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class URPReflectionProbeSettings : IRenderPipelineGraphicsSettings
[SerializeField, HideInInspector] private int version = 1;

int IRenderPipelineGraphicsSettings.version => version;
bool IRenderPipelineGraphicsSettings.isAvailableInPlayerBuild => true;

[SerializeField, Tooltip("Use ReflectionProbe rotation. Enabling this will improve the appearance of reflections when the ReflectionProbe isn't axis aligned, but may worsen performance on lower end platforms.")]
private bool useReflectionProbeRotation = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ uint Select4(uint4 v, uint i)
(((v.y & mask0) | (v.x & ~mask0)) & ~mask1);
}

#if SHADER_TARGET < 45
#if SHADER_TARGET < 45 && !defined UNITY_COMPILER_DXC
// Workaround is only technically required for GL Core <4.0 and GLES <3.1
uint URP_FirstBitLow(uint m)
{
// http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightFloatCast
Expand Down
7 changes: 1 addition & 6 deletions Packages/com.unity.shadergraph/Documentation~/Blackboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Description
You can use the Blackboard to define, order, and categorize the [Properties](Property-Types.md) and [Keywords](Keywords.md) in a graph. From the Blackboard, you can also edit the path for the selected Shader Graph Asset or Sub Graph.

![image](images/blackboardcategories1.png)
![The blackboard layout with properties, keywords, and categories.](images/blackboardcategories1.png)

## Accessing the Blackboard
The Blackboard is visible by default, and you cannot drag it off the graph and lose it. However, you are able to position it anywhere in the [Shader Graph Window](Shader-Graph-Window.md). It always maintains the same distance from the nearest corner, even if you resize the window.
Expand Down Expand Up @@ -42,8 +42,6 @@ To make the properties in your shader more discoverable, organize them into cate
### Adding, removing, and reordering properties and keywords
* To add a property or keyword to a category, expand the category with the foldout (⌄) symbol, then drag and drop the property or keyword onto the expanded category.

![image](images/blackboardcategories2.png)

* To remove a property or keyword, select it and press **Delete**, or right-click and select **Delete**.
* To re-order properties or keywords, drag and drop them within a category or move them into other categories.

Expand All @@ -66,9 +64,6 @@ To copy a specific set of properties:
### Using categories in the Material Inspector
To modify a material you have created with a Shader Graph, you can adjust specific property or keyword values in the Material Inspector, or edit the graph itself.

![image](images/blackboardcategories3.png)


#### Working with Streaming Virtual Textures
[Streaming Virtual Texture Properties](https://docs.unity3d.com/Documentation/Manual/svt-use-in-shader-graph.html) sample texture layers. To access these layers in the Material Inspector, expand the relevant **Virtual Texture** section with the ⌄ symbol next to its name. You can add and remove layers via the Inspector.

Expand Down
2 changes: 0 additions & 2 deletions Packages/com.unity.shadergraph/Documentation~/Block-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ If you disable **Automatically Add or Remove Blocks**, Shader Graph doesn't auto

Active Block nodes are Blocks that contribute to the final shader. Inactive Block nodes are Blocks that are present in the Shader Graph, but don't contribute to the final shader.

![image](images/Active-Inactive-Blocks.png)

When you change the graph settings, certain Blocks might become active or inactive. Inactive Block nodes and any node streams that are connected only to Inactive Block nodes appear grayed out.
12 changes: 6 additions & 6 deletions Packages/com.unity.shadergraph/Documentation~/Boolean-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Defines a constant **Boolean** value in the [Shader Graph](index.md), although i

## Ports

| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Boolean | None | Output value |
| Name | Direction | Type | Binding | Description |
|:--- |:---|:---|:---|:---|
| Out | Output | Boolean | None | Output value |

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Toggle | | Defines the output value. |
| Control | Description |
|:---|:---|
| (Checkbox) | Defines the output value. |

## Generated Code Example

Expand Down
20 changes: 10 additions & 10 deletions Packages/com.unity.shadergraph/Documentation~/Channel-Mixer-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ Controls the amount each of the channels of input **In** contribute to each of t

## Ports

| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| In | Input | Vector 3 | None | Input value |
| Out | Output | Vector 3 | None | Output value |
| Name | Direction | Type | Binding | Description |
|:---|:---|:---|:---|:---|
| In | Input | Vector 3 | None | Input value |
| Out | Output | Vector 3 | None | Output value |

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Toggle Button Array | R, G, B | Selects the output channel to edit. |
| R | Slider | | Controls contribution of input red channel to selected output channel. |
| G | Slider | | Controls contribution of input green channel to selected output channel. |
| B | Slider | | Controls contribution of input blue channel to selected output channel. |
| Control | Description |
|:---|:---|
| **R**, **G**, **B** (toggle buttons) | Selects the output channel to edit with the sliders. |
| **R** (slider) | Controls the contribution of the input red channel to the selected output channel. |
| **G** (slider) | Controls the contribution of the input green channel to the selected output channel. |
| **B** (slider) | Controls the contribution of the input blue channel to the selected output channel. |

## Shader Function

Expand Down
14 changes: 7 additions & 7 deletions Packages/com.unity.shadergraph/Documentation~/Color-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ NOTE: In versions prior to 10.0, Shader Graph assumed that HDR colors from the C

## Ports

| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Vector 4 | None | Output value |
| Name | Direction | Type | Binding | Description |
|:--- |:---|:---|:---|:---|
| Out | Output | Vector 4 | None | Output value |

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Color | | Defines the output value. |
| Mode | Dropdown | Default, HDR | Sets properties of the Color field |
| Control | Description |
|:---|:---|
| (Color) | Defines the output value. |
| **Mode** | Sets properties of the Color field. The options are:<ul><li>**Default**</li><li>**HDR**</li></ul> |

## Generated Code Example

Expand Down
16 changes: 8 additions & 8 deletions Packages/com.unity.shadergraph/Documentation~/Comparison-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ Compares the two input values **A** and **B** based on the condition selected on

## Ports

| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| A | Input | Float | None | First input value |
| B | Input | Float | None | Second input value |
| Out | Output | Boolean | None | Output value |
| Name | Direction | Type | Binding | Description |
|:--- |:---|:---|:---|:---|
| A | Input | Float | None | First input value |
| B | Input | Float | None | Second input value |
| Out | Output | Boolean | None | Output value |

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Dropdown | Equal, NotEqual, Less, LessOrEqual, Greater, GreaterOrEqual | Condition for comparison |
| Control | Description |
|:---|:---|
| (Dropdown) | Select the condition for comparison between A and B. The options are:<ul><li>**Equal**</li><li>**NotEqual**</li><li>**Less**</li><li>**LessOrEqual**</li><li>**Greater**</li><li>**GreaterOrEqual**</li></ul> |

## Generated Code Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Defines a constant **Cubemap Asset** for use in the shader. To sample the **Cube

## Ports

| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Cubemap | None | Output value |
| Name | Direction | Type | Binding | Description |
|:--- |:---|:---|:---|:---|
| Out | Output | Cubemap | None | Output value |

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| | Object Field (Cubemap) | | Defines the cubemap asset from the project. |
| Control | Description |
|:--- |:---|
| (Cubemap)| Defines the cubemap asset from the project. |
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ You can use **Custom** material type to define your own physically based materia

## Ports

| Name | Direction | Type | Binding | Description |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Float | None | Output value |
| Name | Direction | Type | Binding | Description |
|:--- |:---|:---|:---|:---|
| Out | Output | Float | None | Output value |

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Material | Dropdown | Common, RustedMetal, Water, Ice, Glass, Custom | Selects the material value to output. |
| Range | Slider | | Controls output value for **Common** material type. |
| IOR | Slider | | Controls index of refraction for **Custom** material type. |
| Control | Description |
|:---|:---|
| **Material** | Selects the material value to output. The options are:<ul><li>**Common**</li><li>**RustedMetal**</li><li>**Water**</li><li>**Ice**</li><li>**Glass**</li><li>**Custom**</li></ul> |
| **Range** | Controls the output value for a **Common** material type. |
| **IOR** | Controls the index of refraction for a **Custom** material type. |

## Generated Code Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ You can find Numerical values of refractive indices at [refractiveindex.info](ht

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Mode | Dropdown | &#8226; **Schlick**: This mode produces an approximation based on [Schlick's Approximation](https://en.wikipedia.org/wiki/Schlick%27s_approximation). Use the Schlick mode for interactions between air and dielectric materials. <br/>&#8226; **Dielectric**: Use this mode for interactions between two dielectric Materials. For example, air to glass, glass to water, or water to air.<br/>&#8226; **DielectricGeneric**: This mode computes a [Fresnel equation](https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations) for interactions between a dielectric and a metal. For example, clear-coat- to metal, glass to metal, or water to metal. <br/>**Note:** if the **IORMediumK** value is 0, **DielectricGeneric** behaves in the same way as the **Dielectric** mode. ||
| Control | Description |
|:---|:---|
| **Mode** | Select an equation mode to affect Material interactions to the Fresnel Component. The options are:<ul><li>**Schlick**: This mode produces an approximation based on [Schlick's Approximation](https://en.wikipedia.org/wiki/Schlick%27s_approximation). Use the Schlick mode for interactions between air and dielectric materials.</li><li>**Dielectric**: Use this mode for interactions between two dielectric Materials. For example, air to glass, glass to water, or water to air.</li><li>**DielectricGeneric**: This mode computes a [Fresnel equation](https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations) for interactions between a dielectric and a metal. For example, clear-coat- to metal, glass to metal, or water to metal.</li></ul>**Note:** if the **IORMediumK** value is 0, **DielectricGeneric** behaves in the same way as the **Dielectric** mode. |

## Generated Code Example

Expand Down
Loading