- Home /
Adding shine/reflection to a vertex lit shader.
Hello,
So I've been trying to find and/or piece together a shader for quite a while now. In my game each cube gets its color from setting their vertices in the game. I have been using the mask tint - vertex lit shader that is below. I have been trying to attempt to add something to it.
(And heres the poor part of the question) I'm not sure what I am trying to add, basically I am trying to get a reflective metal look to my pieces. Due to my unfamiliarity with shaders, I've only been able to narrow down what I'm looking for from other shaders I've looked at. It seems like I need to add a specular or reflective aspect to my shader. I'm really not sure how to do this while still keeping my pieces colored via vertices. I can add specular/reflectiveness/shine to the shader but when I get it to work, they all just look like the original material that was put on them.
I would think this is possible (and probably easier than I'm making it out to be) but I'm just not sure how to do it. I'm hoping someone can provide some insight or direction. Below is a copy of the shader that I'm currently using.
Most of the properties are unused, I have them in my shader for when I try to add aspects of other shaders.
Thanks.
Shader "Custom/TrialShader2" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (1, 1, 1, 1)
_Shininess ("Shininess", Range (0.01, 3)) = 1.5
//_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_Gloss("Gloss", Range (0.00, 1)) = .5
_Reflection("Reflection", Range (0.00, 1)) = 0.5
_Cube ("Reflection Cubemap", Cube) = "Black" { TexGen CubeReflect }
_FrezPow("Fresnel Reflection",Range(0,2)) = .25
_FrezFalloff("Fresnal/EdgeAlpha Falloff",Range(0,10)) = 4
_EdgeAlpha("Edge Alpha",Range(0,1)) = 1
_Metalics("Metalics",Range(0,1)) = .5
_MainAlpha("MainAlpha", Range(0, 1)) = 1
_ReflectionAlpha("ReflectionAlpha", Range(0, 1)) = 1
_TintColor ("Tint Color (RGB)", Color) = (1,1,1)
_ReflectionTex ("ReflectionTex", 2D) = "white" { TexGen ObjectLinear }
_MainTex ("Texture (A = Tint Mask)", 2D) = ""
}
SubShader {
Pass { // iPhone 3GS and later
GLSLPROGRAM
varying mediump vec2 uv;
varying lowp vec3 color;
#ifdef VERTEX
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy;
color = gl_Color.rgb;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex;
void main() {
vec4 texture = texture2D(_MainTex, uv);
gl_FragColor = vec4(texture.rgb * (color * texture.a + (1. - texture.a)), 1);
}
#endif
ENDGLSL
}
}
SubShader {
Pass { // pre-3GS devices, including the September 2009 8GB iPod touch
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
BindChannels {
Bind "vertex", vertex
Bind "color", color
Bind "texcoord", texcoord
}
SetTexture [_MainTex] {
constantColor [_Color]
Combine texture * primary DOUBLE, texture * constant}
SetTexture[_Cube] { constantColor(0,0,0, [_ReflectionAlpha]) matrix [_ProjMatrix] combine texture * previous, constant}
}
}
}
Your answer
Follow this Question
Related Questions
Need help with using world position in shader 1 Answer
Vertex program max instructions limit 2 Answers
Z-priming alpha-per-vertex 0 Answers
Strange artifacts on Vertex Color Shader 0 Answers
Shader Shininess based on vertex color 0 Answers