Hey,
I’m trying to make the fastest shader for mobile (iOS) with support for: texture, lightmap and per material color.
I’ve got it working by just stripping the Mobile/diffuseDetail shader of its detail texture.
Shader "Mobile/VertexLitColor" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass{
Material{
Diffuse [_Color]
}
Lighting On
SetTexture [_MainTex] { combine texture * primary Double, texture * primary}
}
}
FallBack "VertexLit", 2
}
Can anyone tell me if this is the faster thing to do or if it’s just the same as using a diffuse texture (I only use lights for baking, no realtime lights)
Thanks a lot!
Ok after some great tips/link from Jessy I’m trying to build a GLSL shader but its seaming way over my heat atm.
Here is my current attempt, it has the color, texture and the lightmap kind of works but then if I rotate the camera the object goes black at certain angles.
I’m starting to get bits and pieces of how this works but its still way over my head
Shader "Mobile/VertexLitColor" {
Properties {
_MainTex ("Texture Image", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
}
SubShader {
Pass {
GLSLPROGRAM
uniform sampler2D _MainTex, unity_Lightmap;
uniform mat4 unity_LightmapMatrix;
uniform vec4 _Color ;
varying vec4 textureCoordinates;
varying vec2 textureCoordinatesLM;
#ifdef VERTEX
void main()
{
textureCoordinates = gl_MultiTexCoord0;
textureCoordinatesLM = vec2(unity_LightmapMatrix[0].x, unity_LightmapMatrix[1].y) * gl_MultiTexCoord1.xy + unity_LightmapMatrix[3].xy;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
#endif
#ifdef FRAGMENT
void main()
{
gl_FragColor = texture2D(_MainTex, vec2(textureCoordinates)) * _Color * texture2D(unity_Lightmap, textureCoordinatesLM);
}
#endif
ENDGLSL
}
}
// The definition of a fallback shader should be commented out during development:
// Fallback "Unlit/Texture"
}