Skip to content

Commit 438e586

Browse files
authored
Merge pull request #8063 from Unity-Technologies/internal/master
Internal/master
2 parents 6ea1d0b + f9f9962 commit 438e586

File tree

268 files changed

+10002
-1084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+10002
-1084
lines changed

Packages/com.unity.render-pipelines.core/Documentation~/TableOfContents.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
* [Add custom graphics settings](add-custom-graphics-settings.md)
2020
* [Get custom graphics settings](get-custom-graphics-settings.md)
2121
* [Include or excude a setting in your build](choose-whether-unity-includes-a-graphics-setting-in-your-build.md)
22-
* [Synchronizing shader code and C#](generating-shader-includes.md)
22+
* [Shaders](shaders.md)
23+
* [Use shader methods from the SRP Core shader library](built-in-shader-methods.md)
24+
* [Synchronizing shader code and C#](generating-shader-includes.md)
2325
* [Look Dev](Look-Dev.md)
2426
* [Environment Library](Look-Dev-Environment-Library.md)
2527
* [Rendering Debugger](Rendering-Debugger.md)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Use shader methods from the SRP Core shader library
2+
3+
SRP Core has a library of High-Level Shader Language (HLSL) shader files that contain helper methods. You can import these files into your custom shader files and use the helper methods.
4+
5+
To use the following methods, add `#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl"` inside the `HLSLPROGRAM` in your shader file.
6+
7+
### Get matrices
8+
9+
| **Method** | **Syntax** | **Description** |
10+
|-|-|-|
11+
| `CreateTangentToWorld` | `real3x3 CreateTangentToWorld(real3 normal, real3 tangent, real flipSign)` | Returns the matrix that converts tangents to world space. |
12+
| `GetObjectToWorldMatrix()` | `float4x4 GetObjectToWorldMatrix()` | Returns the matrix that converts positions in object space to world space. |
13+
| `GetViewToHClipMatrix()` | `float4x4 GetViewToHClipMatrix()` | Returns the matrix that converts positions in view space to clip space. |
14+
| `GetViewToWorldMatrix()` | `float4x4 GetViewToWorldMatrix()` | Returns the matrix that converts positions in view space to world space. |
15+
| `GetWorldToHClipMatrix()` | `float4x4 GetWorldToHClipMatrix()` | Returns the matrix that converts positions in world space to clip space. |
16+
| `GetWorldToObjectMatrix()` | `float4x4 GetWorldToObjectMatrix()` | Returns the matrix that converts positions in world space to object space. |
17+
| `GetWorldToViewMatrix()` | `float4x4 GetWorldToViewMatrix()` | Returns the matrix that converts positions in world space to view space. |
18+
19+
### Transform positions
20+
21+
| **Method** | **Syntax** | **Description** |
22+
|-|-|-|
23+
| `TransformObjectToHClip` | `float4 TransformObjectToHClip(float3 positionInObjectSpace)` | Converts a position in object space to clip space. |
24+
| `TransformObjectToWorld` | `float3 TransformObjectToWorld(float3 positionInObjectSpace)` | Converts a position in object space to world space. |
25+
| `TransformViewToWorld` | `float3 TransformViewToWorld(float3 positionInViewSpace)` | Converts a position in view space to world space. |
26+
| `TransformWorldToHClip` | `float4 TransformWorldToHClip(float3 positionInWorldSpace)` | Converts a position in world space to clip space. |
27+
| `TransformWorldToObject` | `float3 TransformWorldToObject(float3 positionInWorldSpace)` | Converts a position in world space to object space. |
28+
| `TransformWorldToView` | `float3 TransformWorldToView(float3 positionInWorldSpace)` | Converts a position in world space to view space. |
29+
| `TransformWViewToHClip` | `float4 TransformWViewToHClip(float3 positionInViewSpace)` | Converts a position in view space to clip space. |
30+
31+
### Transform directions
32+
33+
| **Method** | **Syntax** | **Description** |
34+
|-|-|-|
35+
| `TransformObjectToTangent` | `real3 TransformObjectToTangent(real3 directionInObjectSpace, real3x3 tangentToWorldMatrix)` | Converts a direction in object space to tangent space, using a tangent-to-world matrix. |
36+
| `TransformObjectToWorldDir` | `float3 TransformObjectToWorldDir(float3 directionInObjectSpace, bool normalize = true)` | Converts a direction in object space to world space. |
37+
| `TransformTangentToObject` | `real3 TransformTangentToObject(real3 dirTS, real3x3 tangentToWorldMatrix)` | Converts a direction in tangent space to object space, using a tangent-to-world matrix. |
38+
| `TransformTangentToWorldDir` | `real3 TransformTangentToWorldDir(real3 directionInWorldSpace, real3x3 tangentToWorldMatrix, bool normalize = false)` | Converts a direction in tangent space to world space, using a tangent-to-world matrix. |
39+
| `TransformViewToWorldDir` | `real3 TransformViewToWorldDir(real3 directionInViewSpace, bool normalize = false)` | Converts a direction in view space to world space. |
40+
| `TransformWorldToHClipDir` | `real3 TransformWorldToHClipDir(real3 directionInWorldSpace, bool normalize = false)` | Converts a direction in world space to clip space. |
41+
| `TransformWorldToObjectDir` | `float3 TransformWorldToObjectDir(float3 directionInWorldSpace, bool normalize = true)` | Converts a direction in world space to object space. |
42+
| `TransformWorldToTangentDir` | `real3 TransformWorldToTangentDir(real3 directionInWorldSpace, real3x3 tangentToWorldMatrix, bool normalize = false)` | Converts a direction in world space to tangent space, using a tangent-to-world matrix. |
43+
| `TransformWorldToViewDir` | `real3 TransformWorldToViewDir(real3 directionInWorldSpace, bool normalize = false)` | Converts a direction in world space to view space. |
44+
45+
### Transform surface normals
46+
47+
| **Method** | **Syntax** | **Description** |
48+
|-|-|-|
49+
| `TransformObjectToWorldNormal` | `float3 TransformObjectToWorldNormal(float3 normalInObjctSpace, bool normalize = true)` | Converts a normal in object space to world space. |
50+
| `TransformTangentToWorld` | `float3 TransformTangentToWorld(float3 normalInTangentSpace, real3x3 tangentToWorldMatrix, bool normalize = false)` | Converts a normal in tangent space to world space, using a tangent-to-world matrix. |
51+
| `TransformViewToWorldNormal` | `real3 TransformViewToWorldNormal(real3 normalInViewSpace, bool normalize = false)` | Converts a normal in view space to world space. |
52+
| `TransformWorldToObjectNormal` | `float3 TransformWorldToObjectNormal(float3 normalInWorldSpace, bool normalize = true)` | Converts a normal in world space to object space. |
53+
| `TransformWorldToTangent` | `float3 TransformWorldToTangent(float3 normalInWorldSpace, real3x3 tangentToWorldMatrix, bool normalize = true)` | Converts a normal in world space to tangent space using a tangent-to-world matrix. |
54+
| `TransformWorldToViewNormal` | `real3 TransformWorldToViewNormal(real3 normalInWorldSpace, bool normalize = false)` | Converts a normal in world space to view space. |
55+
56+
## Additional resources
57+
58+
- [HLSL in Unity](https://docs.unity3d.com/Manual/SL-ShaderPrograms.html)
59+
60+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Shaders
2+
3+
Work with shader code in the Scriptable Render Pipeline (SRP).
4+
5+
|**Page**|**Description**|
6+
|-|-|
7+
|[Use shader methods from the SRP Core shader library](built-in-shader-methods.md)|SRP Core has a library of High-Level Shader Language (HLSL) shader files that contain helper methods. You can import these files into your custom shader files and use the helper methods.|
8+
|[Synchronizing shader code and C#](generating-shader-includes.md)|Generate HLSL code based on C# structs to synchronize data and constants between shaders and C#.|
9+
10+
## Additional resources
11+
12+
- [HLSL in Unity](https://docs.unity3d.com/Manual/SL-ShaderPrograms.html)

Packages/com.unity.render-pipelines.core/Editor/AdditionalPropertiesState.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void RepaintAll()
2222

2323
/// <summary>Get or set the state given the mask.</summary>
2424
/// <param name="mask">The filtering mask</param>
25-
/// <returns>True: All flagged area are expended</returns>
25+
/// <value>True: All flagged area are expended</value>
2626
public bool this[TState mask]
2727
{
2828
get => GetAdditionalPropertiesState(mask);
@@ -67,6 +67,10 @@ internal AnimFloat GetAnimation(TState mask)
6767
return anim;
6868
}
6969

70+
/// <summary>
71+
/// Resets the animation associated with the given mask to a default state with the animated value set to 1.0 and the target value set to 0.0.
72+
/// </summary>
73+
/// <param name="mask">The state mask used to retrieve the associated animation.</param>
7074
protected internal void ResetAnimation(TState mask)
7175
{
7276
AnimFloat anim = GetAnimation(mask);
@@ -100,6 +104,9 @@ public void UnregisterEditor(Editor editor)
100104
public class AdditionalPropertiesState<TState, TTarget> : AdditionalPropertiesStateBase<TState>
101105
where TState : struct, IConvertible
102106
{
107+
/// <summary>
108+
/// Stores the expanded or collapsed state of each section defined by <typeparamref name="TState"/>.
109+
/// </summary>
103110
protected internal EditorPrefBoolFlags<TState> m_State;
104111

105112

Packages/com.unity.render-pipelines.core/Editor/Analytics/AnalyticsUtils.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static string[] ToStringArray(Dictionary<string, string> diff)
231231
/// <param name="current">The current object to obtain the fields and values.</param>
232232
/// <param name="compareAndSimplifyWithDefault">If a comparison against the default value must be done.</param>
233233
/// <returns>The nested columns in form of {key.nestedKey : value} </returns>
234+
/// <exception cref="ArgumentNullException">Throws an exception if current parameter is null.</exception>
234235
public static string[] ToNestedColumn<T>([DisallowNull] this T current, bool compareAndSimplifyWithDefault = false)
235236
where T : new()
236237
{
@@ -269,6 +270,7 @@ public static string[] ToNestedColumn<T>([DisallowNull] this T current, bool com
269270
/// <param name="current">The current object to obtain the fields and values.</param>
270271
/// <param name="defaultInstance">The default instance to compare values</param>
271272
/// <returns>The nested columns in form of {key.nestedKey : value} </returns>
273+
/// <exception cref="ArgumentNullException">Throws an exception if the current or defaultInstance parameters are null.</exception>
272274
public static string[] ToNestedColumn<T>([DisallowNull] this T current, T defaultInstance)
273275
{
274276
if (current == null)
@@ -293,7 +295,7 @@ public static string[] ToNestedColumn<T>([DisallowNull] this T current, T defaul
293295
/// <param name="defaultObject">The default object</param>
294296
/// <param name="compareAndSimplifyWithDefault">If a comparison against the default value must be done.</param>
295297
/// <returns>The nested columns in form of {key.nestedKey : value} </returns>
296-
/// <exception cref="ArgumentNullException"></exception>
298+
/// <exception cref="ArgumentNullException">Throws an exception if the current parameter is null.</exception>
297299
public static string[] ToNestedColumnWithDefault<T>([DisallowNull] this T current, [DisallowNull] T defaultObject, bool compareAndSimplifyWithDefault = false)
298300
{
299301
if (current == null)

Packages/com.unity.render-pipelines.core/Editor/Camera/CameraUI.Environment.Drawers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace UnityEditor.Rendering
22
{
3-
/// <summary> Camera UI Shared Properties among SRP</summary>
43
public static partial class CameraUI
54
{
65
/// <summary>

Packages/com.unity.render-pipelines.core/Editor/Camera/CameraUI.Environment.Skin.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
namespace UnityEditor.Rendering
44
{
5-
/// <summary> Camera UI Shared Properties among SRP</summary>
65
public static partial class CameraUI
76
{
8-
/// <summary>
9-
/// Environment section
10-
/// </summary>
117
public static partial class Environment
128
{
139
/// <summary>

Packages/com.unity.render-pipelines.core/Editor/Camera/CameraUI.Output.Drawers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace UnityEditor.Rendering
44
{
5-
/// <summary> Camera UI Shared Properties among SRP</summary>
65
public static partial class CameraUI
76
{
87
/// <summary>

Packages/com.unity.render-pipelines.core/Editor/Camera/CameraUI.Output.Skin.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
namespace UnityEditor.Rendering
44
{
5-
/// <summary> Camera UI Shared Properties among SRP</summary>
65
public static partial class CameraUI
76
{
8-
/// <summary>
9-
/// Output section
10-
/// </summary>
117
public static partial class Output
128
{
139
/// <summary>

Packages/com.unity.render-pipelines.core/Editor/Camera/CameraUI.PhysicalCamera.Drawers.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
namespace UnityEditor.Rendering
66
{
7-
8-
using CED = CoreEditorDrawer<ISerializedCamera>;
9-
10-
/// <summary> Camera UI Shared Properties among SRP</summary>
117
public static partial class CameraUI
128
{
139
/// <summary>

0 commit comments

Comments
 (0)