X-Ray Shader

Hey guys,

I’ve been trying to make an x-ray shader and I’m not having much luck. Typically in Maya I achieve this by applying a transparent/white ramp to the incandescence of a Phong shader who’s V value is controlled by the “facing ratio” of a samplerinfo that calculates the angle of the faces of the geometry it is being applied to based on a percentage. So the lower the percentage, the higher the white value becomes for a given face giving it a nice highlight near the edges of the geometry.

I tried to do the same thing in touch but I couldn’t figure out how to calculate the facing ratio. Anyone have any ideas?

I tried a couple GLSL x-ray shaders without much success. Where is the fragment shader portion of code suppose to go in the GLSL MAT OP? I’m very new to GLSL, any direction would be much appreciated.

Hey Matthew,
The shader code should go into a DAT and a fragment shader is the same thing as a pixel shader, so that’s the parameter in the GLSL MAT that you point to the DAT that holds the GLSL code.

The Phong shader has code that calculations the ‘facing ratio’, if you turn off ‘Uniform Alpha’. This creates an alpha value just like what you are looking for. However the Phong MAT has no way to use that value the way you want, so you will need to use a GLSL MAT here. You can get started by using the Output Shader feature in the Phong MAT, which will output a shader code the Phong MAT is currently using as a starting point. Let me know if you have any other questions.

Awesome!

Thanks for the help Malcolm, I figured it out this morning. I found this simple xray shader someone had written online: [url]http://machinesdontcare.wordpress.com/2009/06/09/simple-x-ray-shader/[/url]

Just gotta make sure you hit the button to load the variables and make sure the blending transparency is checked on the common page. Works beautifully.

-Matt