1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #version 400 core subroutine vec4 SurfaceColor(); uniform sampler2D U_MainTexture; subroutine uniform SurfaceColor U_SurfaceColor; varying vec3 V_Normal; varying vec4 V_WorldPos; varying vec2 V_Texcoord;
subroutine (SurfaceColor) vec4 Ambient() { return texture2D(U_MainTexture,V_Texcoord)*ambientColor; }
subroutine (SurfaceColor) vec4 Diffuse() { return ambientColor+texture2D(U_MainTexture,V_Texcoord)*diffuseColor; }
subroutine (SurfaceColor) vec4 Specular() { return ambientColor+texture2D(U_MainTexture,V_Texcoord)*diffuseColor+specularColor+vec4(1f, 0.7f, 0.72f,1.0f); }
void main() { gl_FragColor=U_SurfaceColor(); }
|