One of my testers is unable to see objects rendered with a diamond shader. Here is a screen-to-screen comparison:
Me - Nvidia GeForce GTX 480
Them - Nvidia Quadro 2000
Here is the shader code
Shader "FX/Diamond"
{
Properties {
_Color ("Color", Color) = (1,1,1,1)
_Fog("Fog", Color) = (0,0,0,0)
_ReflectTex ("Reflection Texture", Cube) = "dummy.jpg" {
TexGen CubeReflect
}
_RefractTex ("Refraction Texture", Cube) = "dummy.jpg" {
TexGen CubeReflect
}
_RefractTexlow ("Refraction LowGPU", 2D) = "dummy.jpg" {
TexGen SphereMap
}
_ReflectTexlow ("Reflect LowGPU", 2D) = "dummy.jpg" {
TexGen SphereMap
}
_Shininess ("Shininess", Range (0.01, 1)) = 0.7
_SpecColor ("Specular", Color) = (1,1,1,1)
_Emission ("Emissive", Color) = (1,1,1,1)
}
SubShader {
Tags {
"Queue" = "Transparent"
}
// First pass - here we render the backfaces of the diamonds. Since those diamonds are more-or-less
// convex objects, this is effectively rendering the inside of them
Pass {
Color (0,0,0,0)
Offset -1, -1
Cull Front
ZWrite Off
SetTexture [_RefractTex] {
constantColor [_Color]
combine texture * constant, primary
}
SetTexture [_ReflectTex] {
combine previous, previous +- texture
}
}
// Second pass - here we render the front faces of the diamonds.
Pass {
Fog { Color (0,0,0,0)}
ZWrite on
Blend One One
SetTexture [_RefractTex] {
constantColor [_Color]
combine texture * constant
}
SetTexture [_ReflectTex] {
combine texture + previous, previous +- texture
}
}
}
// Older cards. Here we remove the bright specular highlight
SubShader {
Tags{"Queue" = "Transparent"}
// First pass - here we render the backfaces of the diamonds. Since those diamonds are more-or-less
// convex objects, this is effectively rendering the inside of them
Pass {
Color (0,0,0,0)
Cull Front
SetTexture [_RefractTex] {
constantColor [_Color]
combine texture * constant, primary
}
}
// Second pass - here we render the front faces of the diamonds.
Pass {
Fog { Color (0,0,0,0)}
ZWrite on
Blend DstColor Zero
SetTexture [_RefractTex] {
constantColor [_Color]
combine texture * constant
}
}
}
/////////// Start iphone code////////////////
//This will cause a nice gem texture to be rendered using the low-GPU textures defined in the inspector//
//This section of the code is provided by BURNING THUMB SOFTWARE, 2010//
SubShader {
Pass {
Lighting On
SeparateSpecular On
Color (0,0,0,0)
// Offset -1, -1
Cull Front
//Blend OneMinusSrcAlpha One
SetTexture [_ReflectTexlow] {
constantColor [_Color]
combine texture * constant, primary
}
}
// Second pass - here we render the front faces of the diamonds.
Pass {
Fog { Color [_Fog]}
ZWrite on
Blend One One
SetTexture [_RefractTexlow] {
constantColor [_Emission]
combine texture * constant
}
}
}
// We need this for shadows
FallBack "Diffuse"
}
I rarely modify shaders myself; I either buy them or copy them off the web. Having said that, I have two questions:
- What is the best way to start debugging a shader that simply won’t appear?
- I thought the FallBack “Diffuse” would result in the diffuse shader being used if the shader content was unsupported by the video card. I verified that the alpha is at 100%; so why would the object not be visible?