#version 120 #if @useUBO #extension GL_ARB_uniform_buffer_object : require #endif #if @useGPUShader4 #extension GL_EXT_gpu_shader4: require #endif varying vec2 uv; varying float euclideanDepth; varying float linearDepth; #define PER_PIXEL_LIGHTING (@normalMap || @forcePPL) #if !PER_PIXEL_LIGHTING centroid varying vec3 passLighting; centroid varying vec3 shadowDiffuseLighting; #endif varying vec3 passViewPos; varying vec3 passNormal; #include "vertexcolors.glsl" #include "shadows_vertex.glsl" #include "lighting.glsl" void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; vec4 viewPos = (gl_ModelViewMatrix * gl_Vertex); gl_ClipVertex = viewPos; euclideanDepth = length(viewPos.xyz); linearDepth = gl_Position.z; #if (!PER_PIXEL_LIGHTING || @shadows_enabled) vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz); #endif passColor = gl_Color; passNormal = gl_Normal.xyz; passViewPos = viewPos.xyz; #if !PER_PIXEL_LIGHTING vec3 diffuseLight, ambientLight; doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting); passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + getEmissionColor().xyz; clampLightingResult(passLighting); shadowDiffuseLighting *= getDiffuseColor().xyz; #endif uv = gl_MultiTexCoord0.xy; #if (@shadows_enabled) setupShadowCoords(viewPos, viewNormal); #endif }