I implemented a basic parallax shader to round out the current shaders. It is similar to Unity’s Implementation of parallax in CG with an exposed parallax bias. Unity uses a constant bias (of 0.42 from what i hear on the interwebs?) allowing them to only expose 1 value which is easier to understand for some users. I expose it as it allows for a greater range of control and to avoid ‘magic’ numbers. If you were going to bias with a constant, i would use a higher value to allow more range of control (42 sounds like a good number)Unfortunately this shader seems to have a bug in maya related to scaling the object. I can correct for this in Unity with * unity_Scale.w, but i am not sure how to extract the object scale in maya just yet. It is possible to work around this by freezing the transforms of the object though. Since you should be freezing your transforms prior to export anyway, and it otherwise works fine…¯\_(ツ)_/¯ Should i find a solution to the scaling issue or a better implementation that works in a different way, i will update the shader to reflect this. At this point i think its a better use of my time to ask for help and move on.EDIT: 1-14 – I figured it out. I reversed the matrix and the camera position while converting the camera position to object space and that screwed everything up. Oops.

Maya CGFX File:

phongnormalparallax.cgfx
File Size: 6 kb
File Type: cgfx

Download File


Unity SHADER File:

phongnormalparallax.shader
File Size: 9 kb
File Type: shader

Download File


2 Responses

  1. hi, I appreciate greatly to these shader stuffs.
    can you check unity shader file link in this post? i think it linked cgfx.

Leave a Reply

Your email address will not be published. Required fields are marked *