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 @@ -428,24 +428,27 @@ public override void OnInspectorGUI()
}
}

GUIContent m_DisplayTitle;
/// <summary>
/// Sets the label for the component header. Override this method to provide
/// a custom label. If you don't, Unity automatically obtains one from the class name.
/// </summary>
/// <returns>A label to display in the component header.</returns>
public virtual GUIContent GetDisplayTitle()
{
if (m_DisplayTitle != null) return m_DisplayTitle;

var volumeComponentType = volumeComponent.GetType();
var displayInfo = volumeComponentType.GetCustomAttribute<DisplayInfoAttribute>();
if (displayInfo != null && !string.IsNullOrWhiteSpace(displayInfo.name))
return EditorGUIUtility.TrTextContent(displayInfo.name, string.Empty);
return m_DisplayTitle = EditorGUIUtility.TrTextContent(displayInfo.name, string.Empty);

#pragma warning disable CS0618
if (!string.IsNullOrWhiteSpace(volumeComponent.displayName))
return EditorGUIUtility.TrTextContent(volumeComponent.displayName, string.Empty);
return m_DisplayTitle = EditorGUIUtility.TrTextContent(volumeComponent.displayName, string.Empty);
#pragma warning restore CS0618

return EditorGUIUtility.TrTextContent(ObjectNames.NicifyVariableName(volumeComponentType.Name) , string.Empty);
return m_DisplayTitle = EditorGUIUtility.TrTextContent(ObjectNames.NicifyVariableName(volumeComponentType.Name), string.Empty);
}

void AddToggleState(GUIContent content, bool state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ void CreateEditor(VolumeComponent component, SerializedProperty property, int in
else
m_Editors[index] = editor;

FilterEditorsBySearch();

DocumentationUtils.TryGetHelpURL(component.GetType(), out string helpUrl);
helpUrl ??= string.Empty;
m_VolumeComponentHelpUrls[editor] = helpUrl;
Expand Down Expand Up @@ -222,9 +224,22 @@ public void Clear()
asset = null;
}

readonly HashSet<VolumeComponentEditor> m_CurrentSearchFilteredEditors = new();
void FilterEditorsBySearch()
{
m_CurrentSearchFilteredEditors.Clear();
if (string.IsNullOrEmpty(m_SearchString)) return;

foreach (var editor in m_Editors)
{
if (MatchesSearchString(editor.GetDisplayTitle().text))
m_CurrentSearchFilteredEditors.Add(editor);
}
}
bool EditorIsIncludedInCurrentSearch(VolumeComponentEditor editor) => string.IsNullOrEmpty(m_SearchString) || m_CurrentSearchFilteredEditors.Contains(editor);
bool MatchesSearchString(string title)
{
return m_SearchString.Length == 0 || title.Contains(m_SearchString, StringComparison.OrdinalIgnoreCase);
return string.IsNullOrEmpty(m_SearchString) || title.Contains(m_SearchString, StringComparison.OrdinalIgnoreCase);
}

/// <summary>
Expand Down Expand Up @@ -263,7 +278,7 @@ bool ShouldDrawEditor(VolumeComponentEditor editor)
{
if (!editor.visible)
return false;
return MatchesSearchString(editor.GetDisplayTitle().text);
return EditorIsIncludedInCurrentSearch(editor);
}

void DrawEditor(VolumeComponentEditor editor, int index = -1)
Expand Down Expand Up @@ -310,7 +325,11 @@ void DrawEditor(VolumeComponentEditor editor, int index = -1)
{
Rect searchRect = GUILayoutUtility.GetRect(50, EditorGUIUtility.singleLineHeight);
searchRect.width -= 2;
m_SearchString = m_SearchField.OnGUI(searchRect, m_SearchString);
using (var check = new EditorGUI.ChangeCheckScope())
{
m_SearchString = m_SearchField.OnGUI(searchRect, m_SearchString);
if (check.changed) FilterEditorsBySearch();
}
GUILayout.Space(2);

EditorGUILayout.HelpBox(
Expand Down Expand Up @@ -346,7 +365,6 @@ void DrawEditor(VolumeComponentEditor editor, int index = -1)

for (int i = 0; i < editors.Count; i++)
DrawEditor(editors[i]);

GUILayout.Space(8);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ SAMPLER(sampler_CoatMaskMap);
PROP_DECL_TEX2D(_BaseColorMap);
PROP_DECL_TEX2D(_MaskMap);
PROP_DECL_TEX2D(_BentNormalMap);
PROP_DECL_TEX2D(_BentNormalMapOS);
PROP_DECL_TEX2D(_NormalMap);
PROP_DECL_TEX2D(_NormalMapOS);
PROP_DECL_TEX2D(_DetailMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Human eyeballs are about 25mm in diameter. The shader uses separate diffusion profiles for the <link="IrisDiffusionProfile 25mm.asset">iris</link> and <link="ScleraDiffusionProfile 25mm.asset">sclera</link>. Scaling the eye changes how subsurface scattering looks. To get the same result for eyes of different sizes, duplicate the diffusion profiles and adjust the world scale, as shown in the 100mm eye example.

This <link="SG_Eye.shadergraph">Shader Graph</link> is designed <b>exclusively</b> for this <link="HumanEyeModel.fbx">3D model</link> with an import scale factor of one. When working with different models or scale factors, you'll need to create a separate graph. In this example, we've chosen the <b>'EyeCinematicWithCaustics'</b> type within the Material Type, located under Surface Options in the Graph Inspector.
This <link="Eye.shadergraph">Shader Graph</link> is designed <b>exclusively</b> for this <link="HumanEyeModel.fbx">3D model</link> with an import scale factor of one. When working with different models or scale factors, you'll need to create a separate graph. In this example, we've chosen the <b>'EyeCinematicWithCaustics'</b> type within the Material Type, located under Surface Options in the Graph Inspector.

""",
"samples": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ internal bool IsLit(Light2D light)
{
// Oddly adding and subtracting vectors is expensive here because of the new structures created...
Vector3 deltaPos;
deltaPos.x = light.m_CachedPosition.x - boundingSphere.position.x;
deltaPos.y = light.m_CachedPosition.y - boundingSphere.position.y;
deltaPos.z = light.m_CachedPosition.z - boundingSphere.position.z;
deltaPos.x = light.boundingSphere.position.x - boundingSphere.position.x;
deltaPos.y = light.boundingSphere.position.y - boundingSphere.position.y;
deltaPos.z = light.boundingSphere.position.z - boundingSphere.position.z;

float distanceSq = Vector3.SqrMagnitude(deltaPos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2536,11 +2536,10 @@ public void RenderUberPost(RenderGraph renderGraph, ContextContainer frameData,
if (userLutTexture.IsValid())
builder.UseTexture(userLutTexture, AccessFlags.Read);

if (m_Bloom.IsActive())
{
passData.bloomTexture = bloomTexture; // This can be null if Bloom is not active.
if (bloomTexture.IsValid())
builder.UseTexture(bloomTexture, AccessFlags.Read);
passData.bloomTexture = bloomTexture;
}


if (requireHDROutput && m_EnableColorEncodingIfNeeded && overlayUITexture.IsValid())
builder.UseTexture(overlayUITexture, AccessFlags.Read);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,12 @@ public static void UpgradeAsset(EntityId assetInstanceID)
asset.m_AssetVersion = 8;
}

// URPReflectionProbeSetings is introduced set the values for older projects.
// URPReflectionProbeSettings is introduced; disable rotation for older projects to preserve
// pre-existing behavior (rotation was not supported before this version).
if (asset.m_AssetVersion < 9)
{
if (GraphicsSettings.TryGetRenderPipelineSettings<URPReflectionProbeSettings>(out var reflectionProbeSettings))
{
reflectionProbeSettings.UseReflectionProbeRotation = false;
}
else
{
Debug.LogError("Failed to upgrade global settings for URPReflectionProbeSettings since it doesn't exists.");
}

var reflectionProbeSettings = GetOrCreateGraphicsSettings<URPReflectionProbeSettings>(asset);
reflectionProbeSettings.UseReflectionProbeRotation = false;
asset.m_AssetVersion = 9;
}

Expand Down
20 changes: 15 additions & 5 deletions Packages/com.unity.shadergraph/Documentation~/Lerp-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@

Returns the result of linearly interpolating between input **A** and input **B** by input **T**.

For example, when the value of input **T** is 0 the return value is equal to the value of input **A**, when it is 1 the return value is equal to the value of input **B** and when it is 0.5 the return value is the midpoint of the two inputs **A** and **B**.
Unity calculates the output as:

A + T &times; (B &minus; A)

The value of input **T** acts as a weight factor applied to the difference between **B** and **A**:

- When **T** is `0`, the output equals **A**.
- When **T** is `1`, the output equals **B**.
- When **T** is `0.5`, the output is the midpoint between **A** and **B**.

The Lerp node uses Dynamic Vector slots, so **A**, **B**, and **T** always resolve to the same component count, which matches the smallest connected vector (larger vectors truncate). Scalars promote to the resolved size by duplicating their value across components.

## Ports

| Name | Direction | Type | Description |
|:-----|:----------|:---------------|:------------|
| A | Input | Dynamic Vector | First input value |
| B | Input | Dynamic Vector | Second input value |
| T | Input | Dynamic Vector | Time value. Typical range: 0 to 1. Though you can use values outside of this range they may cause unpredictable results. |
| Out | Output | Dynamic Vector | Output value |
| **A** | Input | Dynamic Vector | First input value |
| **B** | Input | Dynamic Vector | Second input value |
| **T** | Input | Dynamic Vector | Time value. Typical range: 0 to 1. Though you can use values outside of this range they may cause unpredictable results. |
| **Out** | Output | Dynamic Vector | Output value |

## Generated Code Example

Expand Down
2 changes: 2 additions & 0 deletions Packages/com.unity.shadergraph/Documentation~/Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ Right clicking on a **Node** will open a context menu. This menu contains many o
**Nodes** interact with the Shader Graph Window's Color Modes. Colors are displayed on nodes underneath the text on the node title bar. See [Color Modes](Color-Modes.md) for more information on available colors for nodes.

<image>

Unity applies each component of T as a weight factor to each component to A and B. If T has fewer components than A and B, Unity casts T to the required number of components. Unity copies the values of the original components of T to the added components.
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
"m_FunctionName": "AddAdditionalLightsBasic",
"m_FunctionSource": "3beadf505dbc54f4cae878435013d751",
"m_FunctionSourceUsePragmas": true,
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nColor = MainColor * MainDiffuse;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Convert the pixel light index to the light data index\r\n\t\t#if !USE_CLUSTER_LIGHT_LOOP\r\n\t\t\tlightIndex = GetPerObjectLightIndex(lightIndex);\r\n\t\t#endif\r\n\t\tLight light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float thisDiffuse = light.distanceAttenuation * NdotL;\r\n Diffuse += thisDiffuse;\r\n Color += light.color * thisDiffuse;\r\n LIGHT_LOOP_END\r\n float total = Diffuse;\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nColor = MainColor * MainDiffuse;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float thisDiffuse = light.distanceAttenuation * NdotL;\r\n Diffuse += thisDiffuse;\r\n Color += light.color * thisDiffuse;\r\n LIGHT_LOOP_END\r\n float total = Diffuse;\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@
"m_FunctionName": "AddAdditionalLightsColorize",
"m_FunctionSource": "3beadf505dbc54f4cae878435013d751",
"m_FunctionSourceUsePragmas": true,
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\nAtten = 0;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Convert the pixel light index to the light data index\r\n\t\t#if !USE_CLUSTER_LIGHT_LOOP\r\n\t\t\tlightIndex = GetPerObjectLightIndex(lightIndex);\r\n\t\t#endif\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n\t\tAtten += atten;\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\nAtten = 0;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n\t\tAtten += atten;\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
}

{
Expand Down
Loading
Loading