ShaderGraph icon indicating copy to clipboard operation
ShaderGraph copied to clipboard

Scene Depth node with Sampling Eye throws shader error

Open Krysiek opened this issue 1 year ago • 1 comments

When I use Scene Depth node and set Sampling to Eye I've got shader errors. The shader does not work and turns into pink color.

Errors do not occur when Sampling is set to Raw or Linear01.

obraz

Example shader:

obraz

Fresh World project created with VRChat Creator Companion. Unity version: 2022.3.22f Shader Graph package: 14.0.10 Shader Graph Target (z3y): 1.0.3

Krysiek avatar May 17 '24 18:05 Krysiek

Its probably related to Grab Pass / Screen Color node is broken in VR as well because of the way shader graph calculates screen position. I don't really understand all the sampling modes, or if it can even work properly in built-in in VR this way.

z3y avatar May 19 '24 19:05 z3y

Certainly not an expert in C#/Shaders but it seems to stem from the Orthographic branch ("unity_OrthoParams.w is 1.0 when camera is orthographic, 0.0 when perspective.") of this if/else statement. image

VR should always be in perspective mode anyways so I just deleted it from SceneDepthNode.cs in the ShaderGraph package and it worked for me. (alternatively maybe you could patch UNITY_MATRIX_I_VP to be UNITY_MATRIX_I_V * UNITY_MATRIX_P to stop the orthographic section without throwing an error)

image

Previews with no error and seems to work correctly in scene view

image

image

MidwayMarshall avatar Jun 11 '24 20:06 MidwayMarshall

Im glad that you figured it out! I was afraid it would be something in the main package, I'll see if I can fix it still, thanks. Just keep in mind the error might have went away, but it doesnt guarantee that the node output is accurate.

z3y avatar Jun 12 '24 11:06 z3y

Thats fixed the error, but it still wasnt working properly. I've fixed this issue entirely it should be working now.

z3y avatar Jun 20 '24 14:06 z3y