From f1b394f01f8d945a0238a1c42270611029a3084f Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Wed, 7 Jul 2021 13:42:43 +0200 Subject: [PATCH 1/8] Added a Sun light direction SG node --- .../CHANGELOG.md | 2 + .../SGNode-HD-Sun-Light-Direction.md | 10 +++ .../Nodes/HDSunLightDirectionNode.cs | 62 +++++++++++++++++++ .../Nodes/HDSunLightDirectionNode.cs.meta | 11 ++++ .../Runtime/Lighting/LightLoop/LightLoop.cs | 9 ++- .../HDRenderPipeline.VolumetricClouds.cs | 4 +- ...DRenderPipeline.VolumetricCloudsShadows.cs | 4 +- .../HDRenderPipeline.RenderGraph.cs | 4 +- .../RenderPipeline/HDRenderPipeline.cs | 2 +- .../RenderPipeline/PathTracing/PathTracing.cs | 2 +- .../CloudLayer/CloudLayerRenderer.cs | 2 +- 11 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index c5ee349f42b..cbd349b9b22 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -77,6 +77,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added support for reflection probes as a fallback for ray traced reflections (case 1338644). - Added a minimum motion vector length to the motion vector debug view. - Added a better support for LODs in the ray tracing acceleration structure. +- Added a SG node to get the main directional light direction. +- Added a function to get the main directional light from script. ### Fixed - Fixed Intensity Multiplier not affecting realtime global illumination. diff --git a/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md b/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md new file mode 100644 index 00000000000..44da3685d85 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md @@ -0,0 +1,10 @@ +# HD Sun Light Direction Node + +Provides access to the direction of the main directional light used by HDRP. +The main directional light is the one casting shadows if there is any. Otherwise, it fallbacks to the first non shadow casting directional light. + +### Available Ports + +| Name | Direction | Type | Description | +| :------------ | :-------- | :------------- | :-------------------------------------------------------- | +| **Output** | Output | Vector3 | The normalized direction of the sun light in world space. | diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs new file mode 100644 index 00000000000..7ffbfd838a6 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using System; +using UnityEngine; +using UnityEditor.Graphing; +using UnityEditor.ShaderGraph; +using UnityEditor.ShaderGraph.Drawing.Controls; +using UnityEditor.ShaderGraph.Internal; +using UnityEngine.Rendering.HighDefinition; + +namespace UnityEditor.Rendering.HighDefinition +{ + [SRPFilter(typeof(HDRenderPipeline))] + [Title("Input", "High Definition Render Pipeline", "HD Sun Light Direction")] + class HDSunLightDirection : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction + { + public HDSunLightDirection() + { + name = "HD Sun Light Direction"; + UpdateNodeAfterDeserialization(); + } + + public override string documentationURL => Documentation.GetPageLink("SGNode-HD-Sun-Light-Direction"); + + public const int OutputSlotId = 0; + const string kOutputSlotName = "Output"; + + public override bool hasPreview { get { return false; } } + + public sealed override void UpdateNodeAfterDeserialization() + { + AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName , SlotType.Output, Vector3.zero)); + + RemoveSlotsNameNotMatching(new[] { OutputSlotId }); + } + + string GetFunctionName() => $"Unity_HDRP_GetSunLightDirection_$precision"; + + public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) + { + registry.ProvideFunction(GetFunctionName(), s => + { + s.AppendLine("$precision3 {0}()", GetFunctionName()); + using (s.BlockScope()) + { + s.AppendLine("#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT)"); + s.AppendLine("if (_DirectionalLightCount > 0)"); + s.AppendLine(" return _DirectionalLightDatas[0].forward;"); + s.AppendLine("#endif"); + s.AppendLine("return $precision3(0.0f, 0.0f, 0.0f);"); + } + }); + } + + public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode) + { + sb.AppendLine("$precision3 {0} = {1}();", + GetVariableNameForSlot(OutputSlotId), + GetFunctionName() + ); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta new file mode 100644 index 00000000000..c58edde5858 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 81c6363ccdb77054e82ed296876ff09c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index c6f1441f74e..436dc1606fe 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -640,7 +640,12 @@ enum ClusterDepthSource : int int m_CurrentShadowSortedSunLightIndex = -1; HDAdditionalLightData m_CurrentSunLightAdditionalLightData; DirectionalLightData m_CurrentSunLightDirectionalLightData; - internal Light GetCurrentSunLight() { return m_CurrentSunLight; } + + /// + /// Main directional Light for the HD Render Pipeline. + /// + /// The main directional Light. + public Light GetMainDirectionalLight() => m_CurrentSunLight; // Screen space shadow data struct ScreenSpaceShadowData @@ -1182,7 +1187,7 @@ internal void GetDirectionalLightData(CommandBuffer cmd, HDCamera hdCamera, Visi size = new Vector2(additionalLightData.shapeWidth, additionalLightData.shapeHeight), position = light.GetPosition() }; - if (lightComponent == GetCurrentSunLight()) + if (lightComponent == GetMainDirectionalLight()) { // If this is the current sun light and volumetric cloud shadows are enabled we need to render the shadows if (HasVolumetricCloudsShadows_IgnoreSun(hdCamera)) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs index e4c5da98958..3ca5b955b5f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs @@ -397,7 +397,7 @@ void UpdateShaderVariableslClouds(ref ShaderVariablesClouds cb, HDCamera hdCamer // PB Sun/Sky settings var visualEnvironment = hdCamera.volumeStack.GetComponent(); cb._PhysicallyBasedSun = visualEnvironment.skyType.value == (int)SkyType.PhysicallyBased ? 1 : 0; - Light currentSun = GetCurrentSunLight(); + Light currentSun = GetMainDirectionalLight(); if (currentSun != null) { // Grab the target sun additional data @@ -611,7 +611,7 @@ VolumetricCloudsParameters PrepareVolumetricCloudsParameters(HDCamera hdCamera, parameters.worley32RGB = m_Asset.renderPipelineResources.textures.worleyNoise32RGB; BlueNoise blueNoise = GetBlueNoiseManager(); parameters.ditheredTextureSet = blueNoise.DitheredTextureSet8SPP(); - parameters.sunLight = GetCurrentSunLight(); + parameters.sunLight = GetMainDirectionalLight(); parameters.enableExposureControl = hdCamera.exposureControlFS; // MSAA support diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs index c9e1ebf6984..71dd96d39d3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs @@ -30,7 +30,7 @@ void ReleaseVolumetricCloudsShadows() bool HasVolumetricCloudsShadows(HDCamera hdCamera, in VolumetricClouds settings) { return (HasVolumetricClouds(hdCamera, in settings) - && GetCurrentSunLight() != null + && GetMainDirectionalLight() != null && settings.shadows.value); } @@ -133,7 +133,7 @@ CookieParameters RenderVolumetricCloudsShadows(CommandBuffer cmd, HDCamera hdCam TraceVolumetricCloudShadow(cmd, parameters, currentHandle); // Grab the current sun light - Light sunLight = GetCurrentSunLight(); + Light sunLight = GetMainDirectionalLight(); // Compute the shadow size float groundShadowSize = settings.shadowDistance.value * 2.0f; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 533cc10b386..728493ea71d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -1381,7 +1381,7 @@ void PreRenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colo using (var builder = renderGraph.AddRenderPass("Pre Render Sky", out var passData)) { - passData.sunLight = GetCurrentSunLight(); + passData.sunLight = GetMainDirectionalLight(); passData.hdCamera = hdCamera; passData.colorBuffer = builder.WriteTexture(colorBuffer); passData.depthStencilBuffer = builder.WriteTexture(depthStencilBuffer); @@ -1419,7 +1419,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu using (var builder = renderGraph.AddRenderPass("Render Sky And Fog", out var passData)) { passData.visualEnvironment = hdCamera.volumeStack.GetComponent(); - passData.sunLight = GetCurrentSunLight(); + passData.sunLight = GetMainDirectionalLight(); passData.hdCamera = hdCamera; passData.volumetricLighting = builder.ReadTexture(volumetricLighting); passData.colorBuffer = builder.WriteTexture(colorBuffer); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index db2b781170c..24c51c3f682 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2504,7 +2504,7 @@ void RenderWireFrame(CullingResults cull, HDCamera hdCamera, RenderTargetIdentif void UpdateSkyEnvironment(HDCamera hdCamera, ScriptableRenderContext renderContext, CommandBuffer cmd) { - m_SkyManager.UpdateEnvironment(hdCamera, renderContext, GetCurrentSunLight(), cmd); + m_SkyManager.UpdateEnvironment(hdCamera, renderContext, GetMainDirectionalLight(), cmd); } /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs index 04b5344d64c..c133972b3ee 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs @@ -334,7 +334,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle skyBuff using (var builder = renderGraph.AddRenderPass("Render Sky for Path Tracing", out var passData)) { passData.visualEnvironment = hdCamera.volumeStack.GetComponent(); - passData.sunLight = GetCurrentSunLight(); + passData.sunLight = GetMainDirectionalLight(); passData.hdCamera = hdCamera; passData.colorBuffer = builder.WriteTexture(skyBuffer); passData.depthTexture = builder.WriteTexture(CreateDepthBuffer(renderGraph, true, MSAASamples.None)); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs index 5b72053c317..b4f49dd459a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs @@ -73,7 +73,7 @@ public override bool GetSunLightCookieParameters(CloudSettings settings, ref Coo if (cloudLayer.CastShadows) { if (m_PrecomputedData == null || m_PrecomputedData.cloudShadowsRT == null) - UpdateCache(cloudLayer, HDRenderPipeline.currentPipeline.GetCurrentSunLight()); + UpdateCache(cloudLayer, HDRenderPipeline.currentPipeline.GetMainDirectionalLight()); cookieParams.texture = m_PrecomputedData.cloudShadowsRT; cookieParams.size = new Vector2(cloudLayer.shadowSize.value, cloudLayer.shadowSize.value); From 83a29cc991ab190b53e7ec3301db192def9dfc04 Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Wed, 7 Jul 2021 13:51:52 +0200 Subject: [PATCH 2/8] add precision in doc --- .../Documentation~/SGNode-HD-Sun-Light-Direction.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md b/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md index 44da3685d85..a5ac1e4a2cf 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md @@ -3,6 +3,8 @@ Provides access to the direction of the main directional light used by HDRP. The main directional light is the one casting shadows if there is any. Otherwise, it fallbacks to the first non shadow casting directional light. +If no directional light is available, the output is zero. + ### Available Ports | Name | Direction | Type | Description | From 4654d10d61f7ae846b0917b1f91ab8ee9d9ee9c8 Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Wed, 7 Jul 2021 17:31:48 +0200 Subject: [PATCH 3/8] Make node available in URP and HDRP --- .../Nodes/HDSunLightDirectionNode.cs | 62 ------------------- .../ShaderLibrary/ShaderGraphFunctions.hlsl | 19 ++++++ .../ShaderLibrary/ShaderGraphFunctions.hlsl | 9 +++ .../Documentation~/GetSunLight-Node.md | 13 ++-- .../Nodes/Input/Lighting/GetSunLightNode.cs | 40 ++++++++++++ .../Input/Lighting/GetSunLightNode.cs.meta | 2 +- 6 files changed, 76 insertions(+), 69 deletions(-) delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs rename com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md => com.unity.shadergraph/Documentation~/GetSunLight-Node.md (58%) create mode 100644 com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs rename com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta => com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs.meta (83%) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs deleted file mode 100644 index 7ffbfd838a6..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Collections.Generic; -using System; -using UnityEngine; -using UnityEditor.Graphing; -using UnityEditor.ShaderGraph; -using UnityEditor.ShaderGraph.Drawing.Controls; -using UnityEditor.ShaderGraph.Internal; -using UnityEngine.Rendering.HighDefinition; - -namespace UnityEditor.Rendering.HighDefinition -{ - [SRPFilter(typeof(HDRenderPipeline))] - [Title("Input", "High Definition Render Pipeline", "HD Sun Light Direction")] - class HDSunLightDirection : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction - { - public HDSunLightDirection() - { - name = "HD Sun Light Direction"; - UpdateNodeAfterDeserialization(); - } - - public override string documentationURL => Documentation.GetPageLink("SGNode-HD-Sun-Light-Direction"); - - public const int OutputSlotId = 0; - const string kOutputSlotName = "Output"; - - public override bool hasPreview { get { return false; } } - - public sealed override void UpdateNodeAfterDeserialization() - { - AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName , SlotType.Output, Vector3.zero)); - - RemoveSlotsNameNotMatching(new[] { OutputSlotId }); - } - - string GetFunctionName() => $"Unity_HDRP_GetSunLightDirection_$precision"; - - public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) - { - registry.ProvideFunction(GetFunctionName(), s => - { - s.AppendLine("$precision3 {0}()", GetFunctionName()); - using (s.BlockScope()) - { - s.AppendLine("#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT)"); - s.AppendLine("if (_DirectionalLightCount > 0)"); - s.AppendLine(" return _DirectionalLightDatas[0].forward;"); - s.AppendLine("#endif"); - s.AppendLine("return $precision3(0.0f, 0.0f, 0.0f);"); - } - }); - } - - public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode) - { - sb.AppendLine("$precision3 {0} = {1}();", - GetVariableNameForSlot(OutputSlotId), - GetFunctionName() - ); - } - } -} diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl index 86080b58668..58be3a009cb 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -27,6 +27,19 @@ float3 shadergraph_HDBakedGI(float3 positionWS, float3 normalWS, float2 uvStatic return SampleBakedGI(positionRWS, normalWS, uvStaticLightmap, uvDynamicLightmap); } +void shadergraph_HDGetSunLight(out float3 direction, out float3 color) +{ + direction = 0.0f; + color = 0.0f; +#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT) + if (_DirectionalLightCount > 0) + { + direction = -_DirectionalLightDatas[0].forward; + color = _DirectionalLightDatas[0].color; + } +#endif +} + // If we already defined the Macro, now we need to redefine them given that HDRP functions are now defined. #ifdef SHADERGRAPH_SAMPLE_SCENE_DEPTH @@ -46,4 +59,10 @@ float3 shadergraph_HDBakedGI(float3 positionWS, float3 normalWS, float2 uvStatic #define SHADERGRAPH_BAKED_GI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_HDBakedGI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) +#ifdef SHADERGRAPH_GET_SUN_LIGHT +#undef SHADERGRAPH_GET_SUN_LIGHT +#endif +#define SHADERGRAPH_GET_SUN_LIGHT shadergraph_HDGetSunLight + + #endif // UNITY_GRAPHFUNCTIONS_HD_INCLUDED diff --git a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl index c6b96ffada4..5f58e4323ad 100644 --- a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -9,6 +9,8 @@ #define SHADERGRAPH_AMBIENT_SKY unity_AmbientSky #define SHADERGRAPH_AMBIENT_EQUATOR unity_AmbientEquator #define SHADERGRAPH_AMBIENT_GROUND unity_AmbientGround +#define SHADERGRAPH_GET_SUN_LIGHT shadergraph_URPGetSunLight + #if defined(REQUIRE_DEPTH_TEXTURE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" @@ -90,6 +92,13 @@ float3x3 BuildTangentToWorld(float4 tangentWS, float3 normalWS) return tangentToWorld; } +void shadergraph_URPGetSunLight(out float3 direction, out float3 color) +{ + Light light = GetMainLight(); + direction = light.direction; + color = light.color; +} + // Always include Shader Graph version // Always include last to avoid double macros #include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md b/com.unity.shadergraph/Documentation~/GetSunLight-Node.md similarity index 58% rename from com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md rename to com.unity.shadergraph/Documentation~/GetSunLight-Node.md index a5ac1e4a2cf..703561810bf 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/SGNode-HD-Sun-Light-Direction.md +++ b/com.unity.shadergraph/Documentation~/GetSunLight-Node.md @@ -1,12 +1,13 @@ -# HD Sun Light Direction Node +# Get Sun Light Node -Provides access to the direction of the main directional light used by HDRP. -The main directional light is the one casting shadows if there is any. Otherwise, it fallbacks to the first non shadow casting directional light. +## Description -If no directional light is available, the output is zero. +Provides access to the direction and color of the main directional light. +The main directional light is the one casting shadows if there is any. Otherwise, it fallbacks to the first non shadow casting directional light. -### Available Ports +### Ports | Name | Direction | Type | Description | | :------------ | :-------- | :------------- | :-------------------------------------------------------- | -| **Output** | Output | Vector3 | The normalized direction of the sun light in world space. | +| **Direction** | Output | Vector3 | The normalized direction of the sun light in world space. | +| **Color** | Output | Vector3 | The light color multiplied by the light intensity. | diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs new file mode 100644 index 00000000000..d6907f54f33 --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs @@ -0,0 +1,40 @@ +using System.Reflection; +using UnityEngine; + +namespace UnityEditor.ShaderGraph +{ + [Title("Input", "Lighting", "Sun Light")] + class GetSunLightNode : CodeFunctionNode + { + public GetSunLightNode() + { + name = "GetSunLight"; + } + + public override bool hasPreview { get { return false; } } + + protected override MethodInfo GetFunctionToConvert() + { + return GetType().GetMethod("GetSunLight", BindingFlags.Static | BindingFlags.NonPublic); + } + + static string GetSunLight( + [Slot(0, Binding.None)] out Vector3 Direction, + [Slot(1, Binding.None)] out Vector3 Color) + { + Direction = Vector3.one; + Color = Vector3.one; + return +@" +{ + #if SHADERGRAPH_PREVIEW + Direction = half3(0.5, 0.5, 0); + Color = 1; + #else + SHADERGRAPH_GET_SUN_LIGHT(Direction, Color); + #endif +} +"; + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs.meta similarity index 83% rename from com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta rename to com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs.meta index c58edde5858..347f5e84bbe 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/HDSunLightDirectionNode.cs.meta +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 81c6363ccdb77054e82ed296876ff09c +guid: 237285c961caaa04dbef3bf0a425fb42 MonoImporter: externalObjects: {} serializedVersion: 2 From ba81228fd348ecc7c38b5da0e8e3a0490138b069 Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Tue, 13 Jul 2021 11:40:10 +0200 Subject: [PATCH 4/8] Review fixes --- .../CHANGELOG.md | 1 - .../Runtime/Lighting/LightLoop/LightLoop.cs | 9 ++------- .../HDRenderPipeline.VolumetricClouds.cs | 4 ++-- ...HDRenderPipeline.VolumetricCloudsShadows.cs | 4 ++-- .../HDRenderPipeline.RenderGraph.cs | 4 ++-- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 2 +- .../RenderPipeline/PathTracing/PathTracing.cs | 2 +- .../ShaderLibrary/ShaderGraphFunctions.hlsl | 18 +++++++++++------- .../CloudLayer/CloudLayerRenderer.cs | 2 +- .../ShaderLibrary/ShaderGraphFunctions.hlsl | 4 ++-- ...{GetSunLight-Node.md => Main-Light-Node.md} | 4 ++-- ...{GetSunLightNode.cs => GetMainLightNode.cs} | 14 +++++++------- ...htNode.cs.meta => GetMainLightNode.cs.meta} | 0 13 files changed, 33 insertions(+), 35 deletions(-) rename com.unity.shadergraph/Documentation~/{GetSunLight-Node.md => Main-Light-Node.md} (93%) rename com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/{GetSunLightNode.cs => GetMainLightNode.cs} (63%) rename com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/{GetSunLightNode.cs.meta => GetMainLightNode.cs.meta} (100%) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index cbd349b9b22..72e6380cbd5 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -78,7 +78,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added a minimum motion vector length to the motion vector debug view. - Added a better support for LODs in the ray tracing acceleration structure. - Added a SG node to get the main directional light direction. -- Added a function to get the main directional light from script. ### Fixed - Fixed Intensity Multiplier not affecting realtime global illumination. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 436dc1606fe..c6f1441f74e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -640,12 +640,7 @@ enum ClusterDepthSource : int int m_CurrentShadowSortedSunLightIndex = -1; HDAdditionalLightData m_CurrentSunLightAdditionalLightData; DirectionalLightData m_CurrentSunLightDirectionalLightData; - - /// - /// Main directional Light for the HD Render Pipeline. - /// - /// The main directional Light. - public Light GetMainDirectionalLight() => m_CurrentSunLight; + internal Light GetCurrentSunLight() { return m_CurrentSunLight; } // Screen space shadow data struct ScreenSpaceShadowData @@ -1187,7 +1182,7 @@ internal void GetDirectionalLightData(CommandBuffer cmd, HDCamera hdCamera, Visi size = new Vector2(additionalLightData.shapeWidth, additionalLightData.shapeHeight), position = light.GetPosition() }; - if (lightComponent == GetMainDirectionalLight()) + if (lightComponent == GetCurrentSunLight()) { // If this is the current sun light and volumetric cloud shadows are enabled we need to render the shadows if (HasVolumetricCloudsShadows_IgnoreSun(hdCamera)) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs index 3ca5b955b5f..e4c5da98958 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs @@ -397,7 +397,7 @@ void UpdateShaderVariableslClouds(ref ShaderVariablesClouds cb, HDCamera hdCamer // PB Sun/Sky settings var visualEnvironment = hdCamera.volumeStack.GetComponent(); cb._PhysicallyBasedSun = visualEnvironment.skyType.value == (int)SkyType.PhysicallyBased ? 1 : 0; - Light currentSun = GetMainDirectionalLight(); + Light currentSun = GetCurrentSunLight(); if (currentSun != null) { // Grab the target sun additional data @@ -611,7 +611,7 @@ VolumetricCloudsParameters PrepareVolumetricCloudsParameters(HDCamera hdCamera, parameters.worley32RGB = m_Asset.renderPipelineResources.textures.worleyNoise32RGB; BlueNoise blueNoise = GetBlueNoiseManager(); parameters.ditheredTextureSet = blueNoise.DitheredTextureSet8SPP(); - parameters.sunLight = GetMainDirectionalLight(); + parameters.sunLight = GetCurrentSunLight(); parameters.enableExposureControl = hdCamera.exposureControlFS; // MSAA support diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs index 71dd96d39d3..c9e1ebf6984 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricCloudsShadows.cs @@ -30,7 +30,7 @@ void ReleaseVolumetricCloudsShadows() bool HasVolumetricCloudsShadows(HDCamera hdCamera, in VolumetricClouds settings) { return (HasVolumetricClouds(hdCamera, in settings) - && GetMainDirectionalLight() != null + && GetCurrentSunLight() != null && settings.shadows.value); } @@ -133,7 +133,7 @@ CookieParameters RenderVolumetricCloudsShadows(CommandBuffer cmd, HDCamera hdCam TraceVolumetricCloudShadow(cmd, parameters, currentHandle); // Grab the current sun light - Light sunLight = GetMainDirectionalLight(); + Light sunLight = GetCurrentSunLight(); // Compute the shadow size float groundShadowSize = settings.shadowDistance.value * 2.0f; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 728493ea71d..533cc10b386 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -1381,7 +1381,7 @@ void PreRenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colo using (var builder = renderGraph.AddRenderPass("Pre Render Sky", out var passData)) { - passData.sunLight = GetMainDirectionalLight(); + passData.sunLight = GetCurrentSunLight(); passData.hdCamera = hdCamera; passData.colorBuffer = builder.WriteTexture(colorBuffer); passData.depthStencilBuffer = builder.WriteTexture(depthStencilBuffer); @@ -1419,7 +1419,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu using (var builder = renderGraph.AddRenderPass("Render Sky And Fog", out var passData)) { passData.visualEnvironment = hdCamera.volumeStack.GetComponent(); - passData.sunLight = GetMainDirectionalLight(); + passData.sunLight = GetCurrentSunLight(); passData.hdCamera = hdCamera; passData.volumetricLighting = builder.ReadTexture(volumetricLighting); passData.colorBuffer = builder.WriteTexture(colorBuffer); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 24c51c3f682..db2b781170c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2504,7 +2504,7 @@ void RenderWireFrame(CullingResults cull, HDCamera hdCamera, RenderTargetIdentif void UpdateSkyEnvironment(HDCamera hdCamera, ScriptableRenderContext renderContext, CommandBuffer cmd) { - m_SkyManager.UpdateEnvironment(hdCamera, renderContext, GetMainDirectionalLight(), cmd); + m_SkyManager.UpdateEnvironment(hdCamera, renderContext, GetCurrentSunLight(), cmd); } /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs index c133972b3ee..04b5344d64c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs @@ -334,7 +334,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle skyBuff using (var builder = renderGraph.AddRenderPass("Render Sky for Path Tracing", out var passData)) { passData.visualEnvironment = hdCamera.volumeStack.GetComponent(); - passData.sunLight = GetMainDirectionalLight(); + passData.sunLight = GetCurrentSunLight(); passData.hdCamera = hdCamera; passData.colorBuffer = builder.WriteTexture(skyBuffer); passData.depthTexture = builder.WriteTexture(CreateDepthBuffer(renderGraph, true, MSAASamples.None)); diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl index 58be3a009cb..8bf8c0a6e7c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -27,16 +27,20 @@ float3 shadergraph_HDBakedGI(float3 positionWS, float3 normalWS, float2 uvStatic return SampleBakedGI(positionRWS, normalWS, uvStaticLightmap, uvDynamicLightmap); } -void shadergraph_HDGetSunLight(out float3 direction, out float3 color) +void shadergraph_HDGetMainLight(out float3 direction, out float3 color) { direction = 0.0f; color = 0.0f; #if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT) - if (_DirectionalLightCount > 0) + uint lightIndex = _DirectionalShadowIndex; + if (_DirectionalShadowIndex < 0) { - direction = -_DirectionalLightDatas[0].forward; - color = _DirectionalLightDatas[0].color; + if (_DirectionalLightCount == 0) + return; + lightIndex = 0; } + direction = -_DirectionalLightDatas[lightIndex].forward; + color = _DirectionalLightDatas[lightIndex].color; #endif } @@ -59,10 +63,10 @@ void shadergraph_HDGetSunLight(out float3 direction, out float3 color) #define SHADERGRAPH_BAKED_GI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_HDBakedGI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) -#ifdef SHADERGRAPH_GET_SUN_LIGHT -#undef SHADERGRAPH_GET_SUN_LIGHT +#ifdef SHADERGRAPH_GET_MAIN_LIGHT +#undef SHADERGRAPH_GET_MAIN_LIGHT #endif -#define SHADERGRAPH_GET_SUN_LIGHT shadergraph_HDGetSunLight +#define SHADERGRAPH_GET_MAIN_LIGHT shadergraph_HDGetMainLight #endif // UNITY_GRAPHFUNCTIONS_HD_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs index b4f49dd459a..5b72053c317 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayerRenderer.cs @@ -73,7 +73,7 @@ public override bool GetSunLightCookieParameters(CloudSettings settings, ref Coo if (cloudLayer.CastShadows) { if (m_PrecomputedData == null || m_PrecomputedData.cloudShadowsRT == null) - UpdateCache(cloudLayer, HDRenderPipeline.currentPipeline.GetMainDirectionalLight()); + UpdateCache(cloudLayer, HDRenderPipeline.currentPipeline.GetCurrentSunLight()); cookieParams.texture = m_PrecomputedData.cloudShadowsRT; cookieParams.size = new Vector2(cloudLayer.shadowSize.value, cloudLayer.shadowSize.value); diff --git a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl index 5f58e4323ad..aec2f640774 100644 --- a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -9,7 +9,7 @@ #define SHADERGRAPH_AMBIENT_SKY unity_AmbientSky #define SHADERGRAPH_AMBIENT_EQUATOR unity_AmbientEquator #define SHADERGRAPH_AMBIENT_GROUND unity_AmbientGround -#define SHADERGRAPH_GET_SUN_LIGHT shadergraph_URPGetSunLight +#define SHADERGRAPH_GET_MAIN_LIGHT shadergraph_URPGetMainLight #if defined(REQUIRE_DEPTH_TEXTURE) @@ -92,7 +92,7 @@ float3x3 BuildTangentToWorld(float4 tangentWS, float3 normalWS) return tangentToWorld; } -void shadergraph_URPGetSunLight(out float3 direction, out float3 color) +void shadergraph_URPGetMainLight(out float3 direction, out float3 color) { Light light = GetMainLight(); direction = light.direction; diff --git a/com.unity.shadergraph/Documentation~/GetSunLight-Node.md b/com.unity.shadergraph/Documentation~/Main-Light-Node.md similarity index 93% rename from com.unity.shadergraph/Documentation~/GetSunLight-Node.md rename to com.unity.shadergraph/Documentation~/Main-Light-Node.md index 703561810bf..12ea299750a 100644 --- a/com.unity.shadergraph/Documentation~/GetSunLight-Node.md +++ b/com.unity.shadergraph/Documentation~/Main-Light-Node.md @@ -1,8 +1,8 @@ -# Get Sun Light Node +# Get Main Light Node ## Description -Provides access to the direction and color of the main directional light. +Provides access to the direction and color of the main directional light in the scene. The main directional light is the one casting shadows if there is any. Otherwise, it fallbacks to the first non shadow casting directional light. ### Ports diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs similarity index 63% rename from com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs rename to com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs index d6907f54f33..32239b1b09f 100644 --- a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs @@ -3,22 +3,22 @@ namespace UnityEditor.ShaderGraph { - [Title("Input", "Lighting", "Sun Light")] - class GetSunLightNode : CodeFunctionNode + [Title("Input", "Lighting", "Main Light")] + class GetMainLightNode : CodeFunctionNode { - public GetSunLightNode() + public GetMainLightNode() { - name = "GetSunLight"; + name = "Main Light"; } public override bool hasPreview { get { return false; } } protected override MethodInfo GetFunctionToConvert() { - return GetType().GetMethod("GetSunLight", BindingFlags.Static | BindingFlags.NonPublic); + return GetType().GetMethod("GetMainLight", BindingFlags.Static | BindingFlags.NonPublic); } - static string GetSunLight( + static string GetMainLight( [Slot(0, Binding.None)] out Vector3 Direction, [Slot(1, Binding.None)] out Vector3 Color) { @@ -31,7 +31,7 @@ static string GetSunLight( Direction = half3(0.5, 0.5, 0); Color = 1; #else - SHADERGRAPH_GET_SUN_LIGHT(Direction, Color); + SHADERGRAPH_GET_MAIN_LIGHT(Direction, Color); #endif } "; diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs.meta b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs.meta similarity index 100% rename from com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetSunLightNode.cs.meta rename to com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs.meta From b9d2847375b45483dcf80c2c2172b204ac77a8ad Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Wed, 8 Sep 2021 16:54:52 +0200 Subject: [PATCH 5/8] Remove color from node --- .../ShaderLibrary/ShaderGraphFunctions.hlsl | 17 ++++---- .../ShaderLibrary/ShaderGraphFunctions.hlsl | 8 ++-- ...t-Node.md => Main-Light-Direction-Node.md} | 5 +-- .../Nodes/Input/Lighting/GetMainLightNode.cs | 40 ------------------- .../Input/Lighting/MainLightDirectionNode.cs | 37 +++++++++++++++++ ...cs.meta => MainLightDirectionNode.cs.meta} | 0 .../ShaderLibrary/ShaderGraphFunctions.hlsl | 6 +++ 7 files changed, 56 insertions(+), 57 deletions(-) rename com.unity.shadergraph/Documentation~/{Main-Light-Node.md => Main-Light-Direction-Node.md} (70%) delete mode 100644 com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs create mode 100644 com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs rename com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/{GetMainLightNode.cs.meta => MainLightDirectionNode.cs.meta} (100%) diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl index 8bf8c0a6e7c..87e3e11391b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -27,20 +27,19 @@ float3 shadergraph_HDBakedGI(float3 positionWS, float3 normalWS, float2 uvStatic return SampleBakedGI(positionRWS, normalWS, uvStaticLightmap, uvDynamicLightmap); } -void shadergraph_HDGetMainLight(out float3 direction, out float3 color) +float3 shadergraph_HDMainLightDirection() { - direction = 0.0f; - color = 0.0f; #if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT) uint lightIndex = _DirectionalShadowIndex; if (_DirectionalShadowIndex < 0) { if (_DirectionalLightCount == 0) - return; + return 0.0f; lightIndex = 0; } - direction = -_DirectionalLightDatas[lightIndex].forward; - color = _DirectionalLightDatas[lightIndex].color; + return -_DirectionalLightDatas[lightIndex].forward; +#else + return 0.0f; #endif } @@ -63,10 +62,10 @@ void shadergraph_HDGetMainLight(out float3 direction, out float3 color) #define SHADERGRAPH_BAKED_GI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_HDBakedGI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) -#ifdef SHADERGRAPH_GET_MAIN_LIGHT -#undef SHADERGRAPH_GET_MAIN_LIGHT +#ifdef SHADERGRAPH_MAIN_LIGHT_DIRECTION +#undef SHADERGRAPH_MAIN_LIGHT_DIRECTION #endif -#define SHADERGRAPH_GET_MAIN_LIGHT shadergraph_HDGetMainLight +#define SHADERGRAPH_MAIN_LIGHT_DIRECTION shadergraph_HDMainLightDirection #endif // UNITY_GRAPHFUNCTIONS_HD_INCLUDED diff --git a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl index b4760b938b7..a810cb44143 100644 --- a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -9,7 +9,7 @@ #define SHADERGRAPH_AMBIENT_SKY unity_AmbientSky #define SHADERGRAPH_AMBIENT_EQUATOR unity_AmbientEquator #define SHADERGRAPH_AMBIENT_GROUND unity_AmbientGround -#define SHADERGRAPH_GET_MAIN_LIGHT shadergraph_URPGetMainLight +#define SHADERGRAPH_MAIN_LIGHT_DIRECTION shadergraph_URPMainLightDirection #if defined(REQUIRE_DEPTH_TEXTURE) @@ -97,11 +97,9 @@ float3x3 BuildTangentToWorld(float4 tangentWS, float3 normalWS) return tangentToWorld; } -void shadergraph_URPGetMainLight(out float3 direction, out float3 color) +float3 shadergraph_URPMainLightDirection() { - Light light = GetMainLight(); - direction = light.direction; - color = light.color; + return GetMainLight().direction; } // Always include Shader Graph version diff --git a/com.unity.shadergraph/Documentation~/Main-Light-Node.md b/com.unity.shadergraph/Documentation~/Main-Light-Direction-Node.md similarity index 70% rename from com.unity.shadergraph/Documentation~/Main-Light-Node.md rename to com.unity.shadergraph/Documentation~/Main-Light-Direction-Node.md index 12ea299750a..e6d03689054 100644 --- a/com.unity.shadergraph/Documentation~/Main-Light-Node.md +++ b/com.unity.shadergraph/Documentation~/Main-Light-Direction-Node.md @@ -1,8 +1,8 @@ -# Get Main Light Node +# Get Main Light Direction Node ## Description -Provides access to the direction and color of the main directional light in the scene. +Provides access to the direction of the main directional light in the scene. The main directional light is the one casting shadows if there is any. Otherwise, it fallbacks to the first non shadow casting directional light. ### Ports @@ -10,4 +10,3 @@ The main directional light is the one casting shadows if there is any. Otherwise | Name | Direction | Type | Description | | :------------ | :-------- | :------------- | :-------------------------------------------------------- | | **Direction** | Output | Vector3 | The normalized direction of the sun light in world space. | -| **Color** | Output | Vector3 | The light color multiplied by the light intensity. | diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs deleted file mode 100644 index 32239b1b09f..00000000000 --- a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Reflection; -using UnityEngine; - -namespace UnityEditor.ShaderGraph -{ - [Title("Input", "Lighting", "Main Light")] - class GetMainLightNode : CodeFunctionNode - { - public GetMainLightNode() - { - name = "Main Light"; - } - - public override bool hasPreview { get { return false; } } - - protected override MethodInfo GetFunctionToConvert() - { - return GetType().GetMethod("GetMainLight", BindingFlags.Static | BindingFlags.NonPublic); - } - - static string GetMainLight( - [Slot(0, Binding.None)] out Vector3 Direction, - [Slot(1, Binding.None)] out Vector3 Color) - { - Direction = Vector3.one; - Color = Vector3.one; - return -@" -{ - #if SHADERGRAPH_PREVIEW - Direction = half3(0.5, 0.5, 0); - Color = 1; - #else - SHADERGRAPH_GET_MAIN_LIGHT(Direction, Color); - #endif -} -"; - } - } -} diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs new file mode 100644 index 00000000000..d5336f81197 --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using UnityEngine; + +namespace UnityEditor.ShaderGraph +{ + [Title("Input", "Lighting", "Main Light Direction")] + class MainLightDirectionNode : CodeFunctionNode + { + public MainLightDirectionNode() + { + name = "Main Light Direction"; + synonyms = new string[] { "sun" }; + } + + public override bool hasPreview { get { return false; } } + + protected override MethodInfo GetFunctionToConvert() + { + return GetType().GetMethod("MainLightDirection", BindingFlags.Static | BindingFlags.NonPublic); + } + + static string MainLightDirection([Slot(0, Binding.None)] out Vector3 Direction) + { + Direction = Vector3.one; + return +@" +{ + #if SHADERGRAPH_PREVIEW + Direction = half3(0.5, 0.5, 0); + #else + Direction = SHADERGRAPH_MAIN_LIGHT_DIRECTION(); + #endif +} +"; + } + } +} diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs.meta b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs.meta similarity index 100% rename from com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/GetMainLightNode.cs.meta rename to com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs.meta diff --git a/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderGraphFunctions.hlsl index b48cb052603..705b76dd3ac 100644 --- a/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -9,6 +9,7 @@ #define SHADERGRAPH_AMBIENT_SKY unity_AmbientSky #define SHADERGRAPH_AMBIENT_EQUATOR unity_AmbientEquator #define SHADERGRAPH_AMBIENT_GROUND unity_AmbientGround +#define SHADERGRAPH_MAIN_LIGHT_DIRECTION shadergraph_MainLightDirection #if defined(REQUIRE_DEPTH_TEXTURE) #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareDepthTexture.hlsl" @@ -87,6 +88,11 @@ float3x3 BuildTangentToWorld(float4 tangentWS, float3 normalWS) return tangentToWorld; } +float3 shadergraph_MainLightDirection() +{ + return 0.0f; +} + // Always include Shader Graph version // Always include last to avoid double macros #include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" From 78928a787eac4d39636edce4352acac8dede8342 Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Wed, 8 Sep 2021 16:59:59 +0200 Subject: [PATCH 6/8] flip direction make it the actual direction --- .../Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl | 2 +- .../ShaderLibrary/ShaderGraphFunctions.hlsl | 2 +- .../Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl index 87e3e11391b..1a1c20e37c3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -37,7 +37,7 @@ float3 shadergraph_HDMainLightDirection() return 0.0f; lightIndex = 0; } - return -_DirectionalLightDatas[lightIndex].forward; + return _DirectionalLightDatas[lightIndex].forward; #else return 0.0f; #endif diff --git a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl index a810cb44143..9f6b82165be 100644 --- a/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -99,7 +99,7 @@ float3x3 BuildTangentToWorld(float4 tangentWS, float3 normalWS) float3 shadergraph_URPMainLightDirection() { - return GetMainLight().direction; + return -GetMainLight().direction; } // Always include Shader Graph version diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs index d5336f81197..8bbc9430be6 100644 --- a/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/MainLightDirectionNode.cs @@ -26,7 +26,7 @@ static string MainLightDirection([Slot(0, Binding.None)] out Vector3 Direction) @" { #if SHADERGRAPH_PREVIEW - Direction = half3(0.5, 0.5, 0); + Direction = half3(-0.5, -0.5, 0); #else Direction = SHADERGRAPH_MAIN_LIGHT_DIRECTION(); #endif From a77029c73a391a00c36af668c6f4fb647eaefeda Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Fri, 24 Sep 2021 12:03:47 +0200 Subject: [PATCH 7/8] Added test --- .../Android/OpenGLES3/None/InputNodes.png | 4 +- .../Linear/Android/Vulkan/None/InputNodes.png | 4 +- .../IPhonePlayer/Metal/None/InputNodes.png | 4 +- .../OpenGLCore/None/InputNodes.png | 4 +- .../LinuxEditor/Vulkan/None/InputNodes.png | 4 +- .../OpenGLCore/None/InputNodes.png | 4 +- .../LinuxPlayer/Vulkan/None/InputNodes.png | 4 +- .../OSXEditor/Metal/None/InputNodes.png | 4 +- .../OSXEditor/OpenGLCore/None/InputNodes.png | 4 +- .../OSXPlayer/OpenGLCore/None/InputNodes.png | 4 +- .../Direct3D11/None/InputNodes.png | 4 +- .../WindowsEditor/Vulkan/None/InputNodes.png | 4 +- .../Direct3D11/None/InputNodes.png | 4 +- .../WindowsPlayer/Vulkan/None/InputNodes.png | 4 +- .../Assets/Scenes/InputNodes.unity | 102 ++- .../Input/Lighting/MainLightDirection.mat | 53 ++ .../Lighting/MainLightDirection.mat.meta | 8 + .../Lighting/MainLightDirection.shadergraph | 669 ++++++++++++++++++ .../MainLightDirection.shadergraph.meta | 10 + 19 files changed, 868 insertions(+), 30 deletions(-) create mode 100644 TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat create mode 100644 TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat.meta create mode 100644 TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph create mode 100644 TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph.meta diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/OpenGLES3/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/OpenGLES3/None/InputNodes.png index 65c6097584d..059a2c83da6 100755 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/OpenGLES3/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/OpenGLES3/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1be9e7434d0029042f8885d5d692a1dcb8a34acdb429e7607c02fcd2e6c9a5ed -size 554279 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/Vulkan/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/Vulkan/None/InputNodes.png index 5bdff123d48..059a2c83da6 100755 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/Vulkan/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/Android/Vulkan/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ab8c05c9955091c06d3148d657a7bc6bc13a02b50ca8bdec30024189d41ece3 -size 554445 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png index 68b19109418..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b11744554b5c1fddba4d0b57fa5ca40cd7e6cfdbcfffe97cfe072872737ec591 -size 568672 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/None/InputNodes.png index 23cdb5ce3ef..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae8dafc3dbef8b8ae9b9f6eaefbe598f0c7e773abc112cd69609452eb91d3bc0 -size 623857 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/InputNodes.png index 64c46dd464b..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a08453fc98d58e6b50dfd808119911ec3e25f8278ea2fb33c7d95ed082e35d6e -size 550974 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/OpenGLCore/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/OpenGLCore/None/InputNodes.png index 23cdb5ce3ef..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/OpenGLCore/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/OpenGLCore/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae8dafc3dbef8b8ae9b9f6eaefbe598f0c7e773abc112cd69609452eb91d3bc0 -size 623857 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/InputNodes.png index 64c46dd464b..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a08453fc98d58e6b50dfd808119911ec3e25f8278ea2fb33c7d95ed082e35d6e -size 550974 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png index 542aada6602..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c9b58b967c66cb715e818451f7fe79d11b5de86194afb9b845da1af7116b45f6 -size 560834 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/None/InputNodes.png index 23cdb5ce3ef..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae8dafc3dbef8b8ae9b9f6eaefbe598f0c7e773abc112cd69609452eb91d3bc0 -size 623857 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/None/InputNodes.png index 23cdb5ce3ef..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae8dafc3dbef8b8ae9b9f6eaefbe598f0c7e773abc112cd69609452eb91d3bc0 -size 623857 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/InputNodes.png index 4bb821f216b..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0b55b1a624f2d4aa6fcd146aab7d38e2df2dd027dc33aaf89af37a8be7f1d7a -size 550974 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/InputNodes.png index 23cdb5ce3ef..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae8dafc3dbef8b8ae9b9f6eaefbe598f0c7e773abc112cd69609452eb91d3bc0 -size 623857 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/InputNodes.png index ef1d1ab643b..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:74473be81fc84073c9d503ca32a450542472099dd4f53b79a60f9f7cf3c6b7d8 -size 550934 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/InputNodes.png index 23cdb5ce3ef..059a2c83da6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae8dafc3dbef8b8ae9b9f6eaefbe598f0c7e773abc112cd69609452eb91d3bc0 -size 623857 +oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 +size 552912 diff --git a/TestProjects/ShaderGraph/Assets/Scenes/InputNodes.unity b/TestProjects/ShaderGraph/Assets/Scenes/InputNodes.unity index 41711574211..296990d83ab 100644 --- a/TestProjects/ShaderGraph/Assets/Scenes/InputNodes.unity +++ b/TestProjects/ShaderGraph/Assets/Scenes/InputNodes.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1} + m_IndirectSpecularColor: {r: 0.12731713, g: 0.13414736, b: 0.12107852, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -3651,7 +3651,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1427803695} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 180.00002, z: 0} --- !u!23 &582133712 MeshRenderer: @@ -8093,6 +8093,7 @@ Transform: - {fileID: 801207485} - {fileID: 507897635} - {fileID: 480521285} + - {fileID: 1889196525} - {fileID: 582133711} m_Father: {fileID: 134715868} m_RootOrder: 3 @@ -11206,6 +11207,103 @@ Transform: m_Father: {fileID: 303484558} m_RootOrder: 8 m_LocalEulerAnglesHint: {x: -90, y: 180, z: -90} +--- !u!1 &1889196524 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1889196525} + - component: {fileID: 1889196528} + - component: {fileID: 1889196527} + - component: {fileID: 1889196526} + m_Layer: 0 + m_Name: MainLightDirection + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1889196525 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1889196524} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -7, y: 0, z: -3} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1427803695} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1889196526 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1889196524} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: bdd050ef568927b45b30302183ca8316, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!135 &1889196527 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1889196524} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &1889196528 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1889196524} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1889255731 GameObject: m_ObjectHideFlags: 0 diff --git a/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat new file mode 100644 index 00000000000..16b2126cfbc --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: MainLightDirection + m_Shader: {fileID: -6465566751694194690, guid: 2467c0155b22f574a9be7b9069d78e38, + type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _QueueControl: 0 + - _QueueOffset: 0 + m_Colors: [] + m_BuildTextureStacks: [] +--- !u!114 &6787485369437698938 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 5 diff --git a/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat.meta b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat.meta new file mode 100644 index 00000000000..865ff30efc0 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bdd050ef568927b45b30302183ca8316 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph new file mode 100644 index 00000000000..1927078804a --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph @@ -0,0 +1,669 @@ +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "ea6d01c70c0f4d738f14e6c2ea9bdc26", + "m_Properties": [], + "m_Keywords": [], + "m_Dropdowns": [], + "m_CategoryData": [ + { + "m_Id": "a5ef653f137c4f888186c50d55184c31" + } + ], + "m_Nodes": [ + { + "m_Id": "a9fe4566a86d45d5ace39fad303b9f02" + }, + { + "m_Id": "e82ace186cff47b0a01a45293f098e9e" + }, + { + "m_Id": "c4675b01247b44edbc01c25ac8788f1f" + }, + { + "m_Id": "e34c34ffe5284a19ba359d6cd2f707b0" + }, + { + "m_Id": "50a0b0bb554f45b6be3a22fd0f4a9773" + }, + { + "m_Id": "86d9ef078bdb4278b7d992d9833c821b" + }, + { + "m_Id": "3181f6926c0a4346b74afe0e8bca0013" + }, + { + "m_Id": "e4f0f0e9cf8744298bcf0f41ffc861ae" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "3181f6926c0a4346b74afe0e8bca0013" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e4f0f0e9cf8744298bcf0f41ffc861ae" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "86d9ef078bdb4278b7d992d9833c821b" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e4f0f0e9cf8744298bcf0f41ffc861ae" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "e4f0f0e9cf8744298bcf0f41ffc861ae" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e34c34ffe5284a19ba359d6cd2f707b0" + }, + "m_SlotId": 0 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": 0.0, + "y": 0.0 + }, + "m_Blocks": [ + { + "m_Id": "a9fe4566a86d45d5ace39fad303b9f02" + }, + { + "m_Id": "e82ace186cff47b0a01a45293f098e9e" + }, + { + "m_Id": "c4675b01247b44edbc01c25ac8788f1f" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": 0.0, + "y": 200.0 + }, + "m_Blocks": [ + { + "m_Id": "e34c34ffe5284a19ba359d6cd2f707b0" + }, + { + "m_Id": "50a0b0bb554f45b6be3a22fd0f4a9773" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + }, + "preventRotation": false + }, + "m_Path": "Shader Graph Tests/Input/Lighting", + "m_GraphPrecision": 0, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_ActiveTargets": [ + { + "m_Id": "693a8efdcadb4b948681cccf3a4a85ca" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "1933ee6064f248b08a6fca6f86b58dd4" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "2c4193eafbef42ceaabe060ecfdc1ae2", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 1.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "2d5a2d436d8242a9bb8dd4bfb28f032e", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalVectorNode", + "m_ObjectId": "3181f6926c0a4346b74afe0e8bca0013", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Normal Vector", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -459.0000305175781, + "y": 251.99998474121095, + "width": 205.99998474121095, + "height": 131.00001525878907 + } + }, + "m_Slots": [ + { + "m_Id": "75e4d91929444e94a4994425e8d8dbce" + } + ], + "synonyms": [ + "surface direction" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 2, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Space": 2 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "33a383ad790047808ef8d668cb1486eb", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "50a0b0bb554f45b6be3a22fd0f4a9773", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.AlphaClipThreshold", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "75cd7ae2597d40a6a1f5f8f471dd6c9d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.AlphaClipThreshold" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "63e5b3f554ee40d8b878ba030097dd6f", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "693a8efdcadb4b948681cccf3a4a85ca", + "m_ActiveSubTarget": { + "m_Id": "1933ee6064f248b08a6fca6f86b58dd4" + }, + "m_AllowMaterialOverride": false, + "m_SurfaceType": 0, + "m_ZTestMode": 4, + "m_ZWriteControl": 0, + "m_AlphaMode": 0, + "m_RenderFace": 2, + "m_AlphaClip": false, + "m_CastShadows": true, + "m_ReceiveShadows": true, + "m_CustomEditorGUI": "", + "m_SupportVFX": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "6e156951fa074730898f804b769fa1c6", + "m_Id": 0, + "m_DisplayName": "Direction", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Direction", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "75cd7ae2597d40a6a1f5f8f471dd6c9d", + "m_Id": 0, + "m_DisplayName": "Alpha Clip Threshold", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "AlphaClipThreshold", + "m_StageCapability": 2, + "m_Value": 0.0, + "m_DefaultValue": 0.5, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "75e4d91929444e94a4994425e8d8dbce", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.MainLightDirectionNode", + "m_ObjectId": "86d9ef078bdb4278b7d992d9833c821b", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Main Light Direction", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -413.0000305175781, + "y": 160.99998474121095, + "width": 159.99998474121095, + "height": 78.00003051757813 + } + }, + "m_Slots": [ + { + "m_Id": "6e156951fa074730898f804b769fa1c6" + } + ], + "synonyms": [ + "sun" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.CategoryData", + "m_ObjectId": "a5ef653f137c4f888186c50d55184c31", + "m_Name": "", + "m_ChildObjectList": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "a9fe4566a86d45d5ace39fad303b9f02", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "d672a58ef649437084a3356d315e5ddd" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "c4675b01247b44edbc01c25ac8788f1f", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "db185695ee8d4932a426b6b988ab4e81" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "d672a58ef649437084a3356d315e5ddd", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "db185695ee8d4932a426b6b988ab4e81", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "e34c34ffe5284a19ba359d6cd2f707b0", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "63e5b3f554ee40d8b878ba030097dd6f" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DotProductNode", + "m_ObjectId": "e4f0f0e9cf8744298bcf0f41ffc861ae", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Dot Product", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -204.00001525878907, + "y": 199.99996948242188, + "width": 128.0, + "height": 118.00003051757813 + } + }, + "m_Slots": [ + { + "m_Id": "f4710baac9754c1aabc33d08a5987aa8" + }, + { + "m_Id": "2c4193eafbef42ceaabe060ecfdc1ae2" + }, + { + "m_Id": "33a383ad790047808ef8d668cb1486eb" + } + ], + "synonyms": [ + "scalar product" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "e82ace186cff47b0a01a45293f098e9e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "2d5a2d436d8242a9bb8dd4bfb28f032e" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "f4710baac9754c1aabc33d08a5987aa8", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + diff --git a/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph.meta b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph.meta new file mode 100644 index 00000000000..840d221f393 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/Input/Lighting/MainLightDirection.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2467c0155b22f574a9be7b9069d78e38 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} From aa9d42ffbb6d76ce481c97b91e4571e52e65f8b1 Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Fri, 24 Sep 2021 17:07:06 +0200 Subject: [PATCH 8/8] Update screenshost --- .../Linear/IPhonePlayer/Metal/None/InputNodes.png | 4 ++-- .../Linear/OSXEditor/Metal/None/InputNodes.png | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png index 059a2c83da6..623bb66c04f 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/IPhonePlayer/Metal/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 -size 552912 +oid sha256:376458b49f8380dacb2f3cca95f219a1b4f549572befb44de084810e88d9ff22 +size 570383 diff --git a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png index 059a2c83da6..2520e686ff6 100644 --- a/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png +++ b/TestProjects/ShaderGraph/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/InputNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd68f56c4faccbee8526c4c4414e31b37a07a140d533eb8e84381a91fc261410 -size 552912 +oid sha256:b706a9f3578fd8bb0acd73a425a3b643f800fedc6e77c047bff3b08a0b7b2eec +size 562711