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 @@ -23,6 +23,7 @@ struct UnityTexture2D
SAMPLER(samplerstate);
float4 texelSize;
float4 scaleTranslate;
float4 hdrDecode;

// these functions allows users to convert code using Texture2D to UnityTexture2D by simply changing the type of the variable
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
Expand Down Expand Up @@ -61,15 +62,16 @@ float4 tex2D(UnityTexture2D tex, float2 uv) { return SAMPLE_TEXT
float4 tex2Dlod(UnityTexture2D tex, float4 uv0l) { return SAMPLE_TEXTURE2D_LOD(tex.tex, tex.samplerstate, uv0l.xy, uv0l.w); }
float4 tex2Dbias(UnityTexture2D tex, float4 uv0b) { return SAMPLE_TEXTURE2D_BIAS(tex.tex, tex.samplerstate, uv0b.xy, uv0b.w); }

#define UnityBuildTexture2DStruct(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, n##_ST)
#define UnityBuildTexture2DStructNoScale(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, float4(1, 1, 0, 0))
UnityTexture2D UnityBuildTexture2DStructInternal(TEXTURE2D_PARAM(tex, samplerstate), float4 texelSize, float4 scaleTranslate)
#define UnityBuildTexture2DStruct(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, n##_ST, float4(0, 0, 0, 0))
#define UnityBuildTexture2DStructNoScale(n) UnityBuildTexture2DStructInternal(TEXTURE2D_ARGS(n, sampler##n), n##_TexelSize, float4(1, 1, 0, 0), float4(0, 0, 0, 0))
UnityTexture2D UnityBuildTexture2DStructInternal(TEXTURE2D_PARAM(tex, samplerstate), float4 texelSize, float4 scaleTranslate, float4 hdrDecode)
{
UnityTexture2D result;
result.tex = tex;
result.samplerstate = samplerstate;
result.texelSize = texelSize;
result.scaleTranslate = scaleTranslate;
result.hdrDecode = hdrDecode;
return result;
}

Expand All @@ -78,6 +80,7 @@ struct UnityTexture2DArray
{
TEXTURE2D_ARRAY(tex);
SAMPLER(samplerstate);
float4 hdrDecode;

// these functions allows users to convert code using Texture2DArray to UnityTexture2DArray by simply changing the type of the variable
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
Expand All @@ -94,12 +97,13 @@ struct UnityTexture2DArray
float4 Load(int4 pixel) { return LOAD_TEXTURE2D_ARRAY(tex, pixel.xy, pixel.z); }
};

#define UnityBuildTexture2DArrayStruct(n) UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_ARGS(n, sampler##n))
UnityTexture2DArray UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_PARAM(tex, samplerstate))
#define UnityBuildTexture2DArrayStruct(n) UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_ARGS(n, sampler##n), float4(0, 0, 0, 0))
UnityTexture2DArray UnityBuildTexture2DArrayStructInternal(TEXTURE2D_ARRAY_PARAM(tex, samplerstate), float4 hdrDecode)
{
UnityTexture2DArray result;
result.tex = tex;
result.samplerstate = samplerstate;
result.hdrDecode = hdrDecode;
return result;
}

Expand All @@ -108,6 +112,7 @@ struct UnityTextureCube
{
TEXTURECUBE(tex);
SAMPLER(samplerstate);
float4 hdrDecode;

// these functions allows users to convert code using TextureCube to UnityTextureCube by simply changing the type of the variable
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
Expand All @@ -128,12 +133,13 @@ struct UnityTextureCube
float4 texCUBE(UnityTextureCube tex, float3 dir) { return SAMPLE_TEXTURECUBE(tex.tex, tex.samplerstate, dir); }
float4 texCUBEbias(UnityTextureCube tex, float4 dirBias) { return SAMPLE_TEXTURECUBE_BIAS(tex.tex, tex.samplerstate, dirBias.xyz, dirBias.w); }

#define UnityBuildTextureCubeStruct(n) UnityBuildTextureCubeStructInternal(TEXTURECUBE_ARGS(n, sampler##n))
UnityTextureCube UnityBuildTextureCubeStructInternal(TEXTURECUBE_PARAM(tex, samplerstate))
#define UnityBuildTextureCubeStruct(n) UnityBuildTextureCubeStructInternal(TEXTURECUBE_ARGS(n, sampler##n), float4(0, 0, 0, 0))
UnityTextureCube UnityBuildTextureCubeStructInternal(TEXTURECUBE_PARAM(tex, samplerstate), float4 hdrDecode)
{
UnityTextureCube result;
result.tex = tex;
result.samplerstate = samplerstate;
result.hdrDecode = hdrDecode;
return result;
}

Expand All @@ -142,6 +148,7 @@ struct UnityTexture3D
{
TEXTURE3D(tex);
SAMPLER(samplerstate);
float4 hdrDecode;

// these functions allows users to convert code using Texture3D to UnityTexture3D by simply changing the type of the variable
// the existing texture macros will call these functions, which will forward the call to the texture appropriately
Expand All @@ -155,12 +162,13 @@ struct UnityTexture3D

float4 tex3D(UnityTexture3D tex, float3 uvw) { return SAMPLE_TEXTURE3D(tex.tex, tex.samplerstate, uvw); }

#define UnityBuildTexture3DStruct(n) UnityBuildTexture3DStructInternal(TEXTURE3D_ARGS(n, sampler##n))
UnityTexture3D UnityBuildTexture3DStructInternal(TEXTURE3D_PARAM(tex, samplerstate))
#define UnityBuildTexture3DStruct(n) UnityBuildTexture3DStructInternal(TEXTURE3D_ARGS(n, sampler##n), float4(0, 0, 0, 0))
UnityTexture3D UnityBuildTexture3DStructInternal(TEXTURE3D_PARAM(tex, samplerstate), float4 hdrDecode)
{
UnityTexture3D result;
result.tex = tex;
result.samplerstate = samplerstate;
result.hdrDecode = hdrDecode;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public static void ShowExample()
// Variables used for refresh view
private bool doRefresh;
private int cachedSceneHandle;
private Vector3 cachedCamPos;
private int totalLightCount;
private int totalShadowCount;
private Vector3 cachedCamPos;
private string[] cachedLightNames;
private string[] cachedShadowCasterNames;

ILight2DCullResult lightCullResult
{
Expand Down Expand Up @@ -118,6 +120,9 @@ private VisualElement MakePill(UnityEngine.Object obj)
var bubble = new Button();
bubble.AddToClassList("Pill");
bubble.text = obj.name;
bubble.style.maxWidth = 200;
bubble.style.overflow = Overflow.Hidden;
bubble.style.textOverflow = TextOverflow.Ellipsis;

bubble.clicked += () =>
{
Expand Down Expand Up @@ -469,8 +474,20 @@ private bool IsDirty()

if (lightCullResult.IsGameView())
{
var visibleShadows = lightCullResult.visibleShadows.SelectMany(x => x.GetShadowCasters()).ToList();

isDirty |= totalLightCount != lightCullResult.visibleLights.Count();
isDirty |= totalShadowCount != lightCullResult.visibleShadows.Count();
isDirty |= totalShadowCount != visibleShadows.Count();

// Account for name changes
if (!isDirty)
{
for (int i = 0; i < totalLightCount; ++i)
isDirty |= !lightCullResult.visibleLights.Exists(x => x != null && x.name == cachedLightNames[i]);

for (int i = 0; i < totalShadowCount; ++i)
isDirty |= !visibleShadows.Exists(x => x != null && x.name == cachedShadowCasterNames[i]);
}
}

return isDirty;
Expand All @@ -485,8 +502,27 @@ private void ResetDirty()

if (lightCullResult != null)
{
var visibleShadows = lightCullResult.visibleShadows.SelectMany(x => x.GetShadowCasters());

totalLightCount = lightCullResult.visibleLights.Count();
totalShadowCount = lightCullResult.visibleShadows.Count();
totalShadowCount = visibleShadows.Count();

cachedLightNames = new string[totalLightCount];
cachedShadowCasterNames = new string[totalShadowCount];

for (int i = 0; i < totalLightCount; ++i)
{
var light = lightCullResult.visibleLights[i];
if (light != null)
cachedLightNames[i] = light.name;
}

for (int i = 0; i < totalShadowCount; ++i)
{
var shadowCaster = visibleShadows.ElementAt(i);
if (shadowCaster != null)
cachedShadowCasterNames[i] = shadowCaster.name;
}
}

doRefresh = false;
Expand Down
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 @@ -1954,21 +1954,39 @@ internal enum URPProfileId
internal static class PlatformAutoDetect
{
/// <summary>
/// Detect and cache runtime platform information. This function should only be called once when creating the URP.
/// Detect and cache runtime platform information.
/// Lazy initialized for situations where platform detection is required before URP is initialized (UUM-134298)
/// </summary>
internal static void Initialize()
private sealed class PlatformDetectionCache
{
bool isRunningMobile = false;
#if ENABLE_VR && ENABLE_VR_MODULE
#if PLATFORM_WINRT || PLATFORM_ANDROID
isRunningMobile = IsRunningXRMobile();
public readonly bool isXRMobile;
public readonly bool isShaderAPIMobileDefined;
public readonly bool isSwitch;
public readonly bool isSwitch2;
public readonly bool isRunningOnPowerVRGPU;

public PlatformDetectionCache()
{
bool isRunningMobile = false;
#if ENABLE_VR && ENABLE_VR_MODULE
#if PLATFORM_WINRT || PLATFORM_ANDROID
isRunningMobile = IsRunningXRMobile();
#endif
#endif
#endif

isXRMobile = isRunningMobile;
isShaderAPIMobileDefined = GraphicsSettings.HasShaderDefine(BuiltinShaderDefine.SHADER_API_MOBILE);
isSwitch = Application.platform == RuntimePlatform.Switch;
isSwitch2 = Application.platform == RuntimePlatform.Switch2;
isXRMobile = isRunningMobile;
isShaderAPIMobileDefined = GraphicsSettings.HasShaderDefine(BuiltinShaderDefine.SHADER_API_MOBILE);
isSwitch = Application.platform == RuntimePlatform.Switch;
isSwitch2 = Application.platform == RuntimePlatform.Switch2;
isRunningOnPowerVRGPU = SystemInfo.graphicsDeviceName.Contains("PowerVR");
}
}

private static readonly Lazy<PlatformDetectionCache> platformCache = new(() => new PlatformDetectionCache(), true);

internal static void Initialize()
{
_ = platformCache.Value;
}

#if ENABLE_VR && ENABLE_VR_MODULE
Expand Down Expand Up @@ -1997,19 +2015,21 @@ private static bool IsRunningXRMobile()
/// <summary>
/// If true, the runtime platform is an XR mobile platform.
/// </summary>
internal static bool isXRMobile { get; private set; } = false;
internal static bool isXRMobile => platformCache.Value.isXRMobile;

/// <summary>
/// If true, then SHADER_API_MOBILE has been defined in URP Shaders.
/// </summary>
internal static bool isShaderAPIMobileDefined { get; private set; } = false;
internal static bool isShaderAPIMobileDefined => platformCache.Value.isShaderAPIMobileDefined;

/// <summary>
/// If true, then the runtime platform is set to Switch.
/// </summary>
internal static bool isSwitch { get; private set; } = false;
internal static bool isSwitch => platformCache.Value.isSwitch;

internal static bool isSwitch2 { get; private set; } = false;
internal static bool isSwitch2 => platformCache.Value.isSwitch2;

internal static bool isRunningOnPowerVRGPU => platformCache.Value.isRunningOnPowerVRGPU;

/// <summary>
/// Gives the SH evaluation mode when set to automatically detect.
Expand All @@ -2028,7 +2048,5 @@ internal static ShEvalMode ShAutoDetect(ShEvalMode mode)

return mode;
}

internal static bool isRunningOnPowerVRGPU = SystemInfo.graphicsDeviceName.Contains("PowerVR");
}
}
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
Loading
Loading