1 /** 2 * Lighting Pass shader for ambient lights 3 */ 4 module dash.graphics.shaders.glsl.ambientlight; 5 import dash.graphics.shaders.glsl; 6 7 package: 8 9 /// Takes in a clip-space quad and interpolates the UVs 10 immutable string ambientlightVS = glslVersion ~ q{ 11 layout(location = 0) in vec3 vPosition_s; 12 layout(location = 1) in vec2 vUV; 13 14 out vec4 fPosition_s; 15 out vec2 fUV; 16 17 void main( void ) 18 { 19 fPosition_s = vec4( vPosition_s, 1.0f ); 20 gl_Position = fPosition_s; 21 fUV = vUV; 22 } 23 }; 24 25 /// Outputs the color for the diffuse * the ambient light value 26 immutable string ambientlightFS = glslVersion ~ q{ 27 struct AmbientLight 28 { 29 vec3 color; 30 }; 31 32 in vec4 fPosition; 33 in vec2 fUV; 34 35 // this diffuse should be set to the geometry output 36 uniform sampler2D diffuseTexture; 37 uniform AmbientLight light; 38 39 // https://stackoverflow.com/questions/9222217/how-does-the-fragment-shader-know-what-variable-to-use-for-the-color-of-a-pixel 40 out vec4 color; 41 42 void main( void ) 43 { 44 color = vec4( light.color * texture( diffuseTexture, fUV ).xyz, 1.0f ); 45 } 46 };