Artistic Experiments
  • Home
  • Reel
  • Shaders
    • Stylized Shaders
    • Lighting Techniques
    • Shader Effects
    • Cubemaps
    • Pixel Lit Shaders (Basic)
    • Vertex Lit Shaders (Basic)
    • Unlit Shaders (Basic)
  • Tools
  • WIP
  • Contact

CG Shaders - Parallax Mapping

12/8/2013

4 Comments

 
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.
Picture

Maya CGFX File:

phongnormalparallax.cgfx
File Size: 8 kb
File Type: cgfx
Download File

Unity SHADER File:

phongnormalparallax.shader
File Size: 14 kb
File Type: shader
Download File

4 Comments
WonkyKIM link
11/4/2014 06:31:40 am

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

Reply
Gabe
11/4/2014 11:27:51 am

Yeah no problem man thanks for pointing that out. If you see any more like that let me know and i'll fix them.

Reply
WonkyKIM link
11/4/2014 01:01:08 pm

thanks a lot!
can i have your contact?
what country do you live in? i hope buy you a beer some day.
here's my
Wonky KIM(S.Korea), kimwonky@gmail.com, fb/WonkyKIM

Gabe
11/4/2014 01:16:53 pm

Yeah definitely. You can reach me at mccauley.gabe@gmail.com. I live in America, on the West coast in Seattle. If I make it over there I'll definitely take you up on that beer :)




Leave a Reply.

    CG Shaders

    Shaders I've built as i teach myself CG. Feel free to download and use for whatever. If you like them you can buy me a beer or something.

    Archives

    December 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013

    Categories

    All

    RSS Feed

Powered by Create your own unique website with customizable templates.