AmplifyCreations / AmplifyShaderEditor-Feedback

4 stars 0 forks source link

Indirect Specular Light Node Breaking in URP Forward+ #220

Open Dawie3565 opened 1 year ago

Dawie3565 commented 1 year ago

--- api 10x reference Lighting.hlsl --- api 12x and higher reference GlobalIllumination.hlsl

from 12x and higher code has moved to a new path in Unity GlobalIllumination.hlsl. reflectVector has significant changes and in 14x returns null when render path is set Forward+

Suggestion: Indirect Specular Light Node was originally designed for use in BIRP custom lighting then adapted to work in early release LW and early versions of URP. GlossyEnvironmentReflection has significantly changed from 12x and higher and it may now be better to make a new node specifically for URP

Dawie3565 commented 1 year ago

please check all pragma and define added from nodes: --- indirect Specular Light node --- indirect Diffuse Light node

special attention to changes in any multi_compile_fragment per api

also note when functions above are used in unlit ok however, if used in Lit no extra pragma should be given as it makes duplicates in shaders causing postnatal breaking as lighting is multiplied in return.

Dawie3565 commented 1 year ago

Note hard scene flickering is found with indirect spec forward + and SRP batching.

Dawie3565 commented 11 months ago

Moving back to highest priority Mobile is breaking without this change.

Dawie3565 commented 6 months ago

for test

--- open project in the latest URP 14x --- open new ase unlit and add Node indirect Specular Light --- set Unity settings to forward + and see results return black

(forward Rendering Path works as expected) Forward

(Forward Rendering Path returns Black and can observe some flickering) Forward +

Dawie3565 commented 6 months ago

Note This git action is bundled for two nodes with same issue to be checked --- indirect Specular Light node --- indirect Diffuse Light node

Dawie3565 commented 1 month ago

More users reporting issues with forward + --- Unity URP 6000.0.23 --- windows

`We have recently switcher to Forward+ rendering and we noticed that when using Indirect Specular Light node, we start getting crazy flickering. After some digging I figured that it's related to possibly the wrong function being called under the hood. The function called is using the unity_SpecCube0_HDR to decode the HDR skybox values, but it contains trash data. After following the standard URP Lit shader code from unity, I noticed they use a different function.

The function that ASE uses with Indirect Specular Light is half3 GlossyEnvironmentReflection(half3 reflectVector, half perceptualRoughness, half occlusion) The function that Unity URP Lit shader uses is half3 GlossyEnvironmentReflection(half3 reflectVector, float3 positionWS, half perceptualRoughness, half occlusion, float2 normalizedScreenSpaceUV)

If I update the code to use that function instead it seems to work correct. Is this a bug or am I just solving this completely wrong?`