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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal static class RendererLighting
private static readonly int k_LightInvMatrixID = Shader.PropertyToID("_LightInvMatrix");
private static readonly int k_InnerRadiusMultID = Shader.PropertyToID("_InnerRadiusMult");
private static readonly int k_OuterAngleID = Shader.PropertyToID("_OuterAngle");
private static readonly int k_InnerAngleMultID = Shader.PropertyToID("_InnerAngleMult");
private static readonly int k_InnerAngleID = Shader.PropertyToID("_InnerAngle");
private static readonly int k_LightLookupID = Shader.PropertyToID("_LightLookup");
private static readonly int k_IsFullSpotlightID = Shader.PropertyToID("_IsFullSpotlight");
private static readonly int k_LightZDistanceID = Shader.PropertyToID("_LightZDistance");
Expand Down Expand Up @@ -486,7 +486,7 @@ private static void SetPointLightShaderGlobals(IRenderPass2D pass, CommandBuffer
cmd.SetGlobalMatrix(k_LightInvMatrixID, lightInverseMatrix);
cmd.SetGlobalFloat(k_InnerRadiusMultID, innerRadiusMult);
cmd.SetGlobalFloat(k_OuterAngleID, outerAngle);
cmd.SetGlobalFloat(k_InnerAngleMultID, 1 / (outerAngle - innerAngle));
cmd.SetGlobalFloat(k_InnerAngleID, innerAngle);
cmd.SetGlobalTexture(k_LightLookupID, Light2DLookupTexture.GetLightLookupTexture());
cmd.SetGlobalTexture(k_FalloffLookupID, pass.rendererData.fallOffLookup);
cmd.SetGlobalFloat(k_FalloffIntensityID, light.falloffIntensity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Shader "Hidden/Light2d-Point-Volumetric"
float4x4 _LightNoRotInvMatrix;
half _LightZDistance;
half _OuterAngle; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
half _InnerAngleMult; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
half _InnerAngle; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
half _InnerRadiusMult; // 1-0 where 1 is the value at the center and 0 is the value at the outer radius
half _InverseHDREmulationScale;
half _IsFullSpotlight;
Expand Down Expand Up @@ -88,7 +88,7 @@ Shader "Hidden/Light2d-Point-Volumetric"
half attenuation = saturate(_InnerRadiusMult * lookupValue.r); // This is the code to take care of our inner radius

// Spotlight
half spotAttenuation = saturate((_OuterAngle - lookupValue.g + _IsFullSpotlight) * _InnerAngleMult);
half spotAttenuation = saturate((_OuterAngle - lookupValue.g + _IsFullSpotlight) * (1.0f / (_OuterAngle - _InnerAngle)));
attenuation = attenuation * spotAttenuation;

half2 mappedUV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Shader "Hidden/Light2D-Point"
float4x4 _LightInvMatrix;
float4x4 _LightNoRotInvMatrix;
half _OuterAngle; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
half _InnerAngleMult; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
half _InnerAngle; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
half _InnerRadiusMult; // 1-0 where 1 is the value at the center and 0 is the value at the outer radius
half _InverseHDREmulationScale;
half _IsFullSpotlight;
Expand Down Expand Up @@ -97,7 +97,7 @@ Shader "Hidden/Light2D-Point"
half attenuation = saturate(_InnerRadiusMult * lookupValue.r); // This is the code to take care of our inner radius

// Spotlight
half spotAttenuation = saturate((_OuterAngle - lookupValue.g + _IsFullSpotlight) * _InnerAngleMult);
half spotAttenuation = saturate((_OuterAngle - lookupValue.g + _IsFullSpotlight) * (1.0f / (_OuterAngle - _InnerAngle)));
attenuation = attenuation * spotAttenuation;

half2 mappedUV;
Expand Down
34 changes: 13 additions & 21 deletions Packages/com.unity.shadergraph/Documentation~/Position-Node.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
# Position Node
# Position node

## Description

Provides access to the mesh vertex's or fragment's **Position**, depending on the effective [Shader Stage](Shader-Stage.md) of the graph section that the [Node](Node.md) is part of. Use the **Space** drop-down parameter to select the coordinate space of the output value.
The Position node returns the position of a vertex or fragment of a mesh.

## Ports

| Name | Direction | Type | Binding | Description |
| **Name** | **Direction** | **Type** | **Binding** | **Description** |
|:------------ |:-------------|:-----|:---|:---|
| Out | Output | Vector 3 | None | **Position** for the Mesh Vertex/Fragment. |

## Controls

| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| Space | Dropdown | Object, View, World, Tangent, Absolute World | Selects the coordinate space of **Position** to output. |

## World and Absolute World
The Position Node provides drop-down options for both **World** and **Absolute World** space positions. The **Absolute World** option always returns the absolute world position of the object in the Scene for all Scriptable Render Pipelines. The **World** option returns the default world space of the selected Scriptable Render Pipeline.

The [High Definition Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html) uses [Camera Relative](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?preview=1&subfolder=/manual/Camera-Relative-Rendering.html) as its default world space.
| **Out** | Output | Vector 3 | None | Position of the vertex or fragment of the mesh, depending on the [shader stage](Shader-Stage.md) of the graph section. |

The [Universal Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest/index.html) uses **Absolute World** as its default world space.
## Space

### Upgrading from previous versions
If you use a Position Node in **World** space on a graph authored in Shader Graph version 6.7.0 or earlier, it automatically upgrades the selection to **Absolute World**. This ensures that the calculations on your graph remain accurate to your expectations, since the **World** output might change.
The **Space** dropdown determines the coordinate space of the output position.

If you use a Position Node in **World** space in the High Definition Render Pipeline to manually calculate [Camera Relative](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?preview=1&subfolder=/manual/Camera-Relative-Rendering.html) world space, you can now change your node from **Absolute World** to **World**, which lets you use [Camera Relative](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?preview=1&subfolder=/manual/Camera-Relative-Rendering.html) world space out of the box.
| **Options** | **Description** |
|-|-|
| **Object** | Returns the vertex or fragment position relative to the origin of the object. |
| **View** | Returns the vertex or fragment position relative to the camera, in meters. |
| **World** | Returns the vertex or fragment position in the world, in meters. If you use the High Definition Render Pipeline (HDRP), **World** returns the position [relative to the camera](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?preview=1&subfolder=/manual/Camera-Relative-Rendering.html). |
| **Tangent** | Returns the vertex or fragment position relative to the tangent of the surface, in meters. For more information, refer to [Normal maps](https://docs.unity3d.com/6000.3/Documentation/Manual/StandardShaderMaterialParameterNormalMapLanding.html). |
| **Absolute World**| Returns the vertex or fragment position in the world, in meters. |
20 changes: 9 additions & 11 deletions Packages/com.unity.shadergraph/Documentation~/Remap-Node.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# Remap Node
# Remap node

## Description

Returns a value between the x and y components of input **Out Min Max** based on the linear interpolation of the value of input **In** between the x and y components of input **In Min Max**.
The Remap node converts a value from one range to another, which is also known as linear interpolation. For example, you can use the node to convert a value in the range 0 to 1 to the equivalent value in the range 0 to 100.

## Ports

| Name | Direction | Type | Description |
| **Name** | **Direction** | **Type** | **Description** |
|:------------ |:-------------|:-----|:---|
| In | Input | Dynamic Vector | Input value |
| In Min Max | Input | Vector 2 | Minimum and Maximum values for input interpolation |
| Out Min Max | Input | Vector 2 | Minimum and Maximum values for output interpolation |
| Out | Output | Dynamic Vector | Output value |
| **In** | Input | Dynamic Vector | The value to convert. |
| **In Min Max** | Input | Vector 2 | The original minimum and maximum range of **In**. |
| **Out Min Max** | Input | Vector 2 | The new minimum and maximum range to use to interpolate **In**. |
| **Out** | Output | Dynamic Vector | The converted value. |

## Generated Code Example
## Generated code example

The following example code represents one possible outcome of this node.

Expand All @@ -22,4 +20,4 @@ void Unity_Remap_float4(float4 In, float2 InMinMax, float2 OutMinMax, out float4
{
Out = OutMinMax.x + (In - InMinMax.x) * (OutMinMax.y - OutMinMax.x) / (InMinMax.y - InMinMax.x);
}
```
```
Loading