Page 1 of 1

Execution Order Problems

PostPosted: Wed Jan 10, 2018 3:47 pm
by HellGate
i was wondering how screendepth / surfacedepth can create values <0 untill i looked into the generated code.

it turns out that the surface depth is calcuated in the vertex shade before the vertex offset is applied

Example:
Code: Select all
o.eyeDepth = -UnityObjectToViewPos( v.vertex.xyz ).z;
v.vertex.xyz += float3(4,4,4);


i think this problem can occur on multiple occasions and might need some special execution priority.
(for example passing world position before and after vertex offset into the pixel shader using vertex to fragment node)

Re: Execution Order Problems

PostPosted: Thu Jan 11, 2018 11:30 am
by Amplify_Borba
Hello HellGate, thank you for bringing this to our attention, we're going to investigate it on our side and fix it as soon as possible!

Please don't hesitate to get back in touch if you run into any further issues, thanks!

Re: Execution Order Problems

PostPosted: Mon Jan 22, 2018 10:22 am
by Amplify_RnD_Rick
Hey HellGate,

We first would like to apologize on our delay in providing you a fix.

On our latest build we added a new input port to both Surface Depth and Camera Depth Fade so you can place a custom vertex position and it will do its calculation according to that instead of the current vertex position.

You can download it over here:
https://amplify.pt/download/

So, to use Screen Depth with a custom vertex offset you can do something like this:

CustomVertexOffsetDepth.jpg
CustomVertexOffsetDepth.jpg (146.29 KiB) Viewed 1504 times


Please notice that we changed the Vertex Output option on the Node Properties from Relative to Absolute as we are specifying a final vertex position and not an offset.

Please don't hesitate on reaching us if you stumble into any issues.

Re: Execution Order Problems

PostPosted: Tue Jan 30, 2018 9:47 pm
by HellGate
Sorry for the late reply. The fix worked fine for me so thanks a lot for that.

Re: Execution Order Problems

PostPosted: Wed Jan 31, 2018 9:54 am
by Amplify_Borba
No worries, glad we could be of assistance!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, the Unity Asset Store thrives on user interaction and direct feedback.

Please don't hesitate to get back in touch if you run across any further issues, thanks!