******** Vertex shader for sprite: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 void main() { // Position 80: // Built-in slice: gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } ******** Fragment shader for sprite: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 // Built-in slice: #define OPENCLONK // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\UtilShader.glsl: // #ifdef NO_TEXTURE_LOD_IN_FRAGMENT #define texture1DLod(t,c,l) texture1D(t,c) #define texture2DLod(t,c,l) texture2D(t,c) // #endif vec3 extend_normal(vec2 v) { // the higher the second value, the further away the light source from the landscape return normalize(vec3(v, 0.45)); } // Converts the pixel range 0.0..1.0 into the integer range 0..255 int f2i(float x) { return int(x * 255.9); } // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: uniform vec4 clrMod; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: uniform mat3x2 lightTransform; #ifdef HAVE_NORMALMAP uniform sampler2D normalTex; #endif #ifdef MESH varying vec3 normalDir; #endif // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Base light calculations #ifdef HAVE_LIGHT uniform sampler2D lightTex; #endif // uncomment the following lines for debugging light directions: // yellow: light up, blue: light down, turqoise: light right, pink: light left // brightness: light strength //#define LIGHT_DEBUG // At what point of light intensity we set the "darkness" point. This // is to compensate for the fact that the engien "smoothes" the light // and therefore will often never arrive at 0 light intensity. const float lightDarknessLevel = 8.0 / 256.0; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Ambient light calculation #ifdef HAVE_LIGHT uniform sampler2D ambientTex; uniform mat3x2 ambientTransform; uniform float ambientBrightness; #endif void main() { // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: #define color gl_FragColor #ifdef MESH // TODO: Add emission part of the material. Note we cannot just // add this to the color, but it would need to be handled separately, // such that it is independent from the incident light direction. color = gl_FrontMaterial.diffuse; #else vec4 baseColor = gl_Color; color = baseColor; #endif // Position 44: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_LIGHT // prepare texture coordinate for light lookup in LightShader.c vec2 lightCoord = lightTransform * vec3(gl_FragCoord.xy, 1.0); #endif // Position 45: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef HAVE_LIGHT // Query light texture vec4 lightPx = texture2D(lightTex, lightCoord.st); float lightBright = max(0.0, lightPx.x-lightDarknessLevel); vec3 lightDir = extend_normal(vec2(1.0, 1.0) - lightPx.yz * 3.0); #else // When lighting is disabled, put a light source coming from the camera. // Note that in most cases this does not actually matter, since in the // case with lighting disabled, ambient lighting takes fully over. float lightBright = 0.5; vec3 lightDir = vec3(0.0, 0.0, 1.0); #endif // Position 46: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: #ifdef HAVE_LIGHT // Ambient light float ambient = texture2D(ambientTex, ambientTransform * vec3(gl_FragCoord.xy, 1.0)).r * ambientBrightness; #else // Lighting disabled: Ambient light everywhere float ambient = 1.0; #endif // Position 80: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_NORMALMAP vec4 normalPx = texture2D(normalTex, texcoord.xy); vec3 normalPxDir = 2.0 * (normalPx.xyz - vec3(0.5, 0.5, 0.5)); vec3 normal = normalize(gl_NormalMatrix * normalPxDir); #else #ifdef MESH vec3 normal = normalDir; // Normal matrix is already applied in vertex shader #else vec3 normal = vec3(0.0, 0.0, 1.0); #endif #endif // Position 100: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: float light = 2.0 * lightBright * max(dot(normal, lightDir), 0.0); #ifdef HAVE_2PX float light2 = 2.0 * lightBright * max(dot(normal2, lightDir), 0.0); #endif // Position 101: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Add ambience to brightness #ifdef LANDSCAPE // For landscape, ambient brightness is coming from top vec3 ambientDir = vec3(0.0, -1.0, 0.0); light = mix(light, 1.0 + 1.0 * dot(normal, ambientDir), ambient); #ifdef HAVE_2PX light2 = mix(light2, 1.0 + 1.0 * dot(normal2, ambientDir), ambient); #endif #else // For objects, ambient brightness is coming from the front vec3 ambientDir = vec3(0.0, 0.0, 1.0); light = mix(light, max(dot(normal, ambientDir), 0.0), ambient); #endif // Position 120: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: // TODO: Instead of a conditional, we could compute the color as // color = A + B*color + C*clrMod + D*color*clrMod; // Then, mod2 would be A=-0.5, B=1, C=1, D=0 // and default would be A=0,B=0,C=0,D=1 // Would allow to avoid conditionsals and #ifdefs, but need 4 uniforms... // Could also try some sort of 3x3 matrix: // out = (color, clrmod, 1) * (A,B,C,D,E,F,0,0,G) * (color, clrmod, 1) #ifdef CLRMOD_MOD2 color = clamp(color + clrMod - 0.5, 0.0, 1.0); #else color = color * clrMod; #endif // Position 125: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Add light color = vec4(light * color.rgb, color.a); #ifdef HAVE_2PX color2 = vec4(light2 * color2.rgb, color2.a); #endif // Position 145: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef LIGHT_DEBUG #ifdef HAVE_LIGHT float lightYDir = lightPx.b - 1.0/3.0; float lightXDir = lightPx.g - 1.0/3.0; float lightStrength = lightPx.r; color = vec4(lightStrength * vec3(1.0-1.5*(max(0.0, lightYDir) + max(0.0,lightXDir)), 1.0-1.5*(max(0.0, lightYDir) + max(0.0,-lightXDir)), 1.0-1.5*max(0.0, -lightYDir)), 1.0); #else color = vec4(0.0, 0.0, 0.0, 0.0); // invisible #endif #endif } gl: Compiling sprite vertex shader: No errors. gl: Compiling sprite fragment shader: No errors. gl: Compiling sprite shader program: No errors. gl: sprite shader linked successfully ******** Vertex shader for spriteMod2: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 void main() { // Position 80: // Built-in slice: gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } ******** Fragment shader for spriteMod2: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 // Built-in slice: #define OPENCLONK // Built-in slice: #define CLRMOD_MOD2 // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\UtilShader.glsl: // #ifdef NO_TEXTURE_LOD_IN_FRAGMENT #define texture1DLod(t,c,l) texture1D(t,c) #define texture2DLod(t,c,l) texture2D(t,c) // #endif vec3 extend_normal(vec2 v) { // the higher the second value, the further away the light source from the landscape return normalize(vec3(v, 0.45)); } // Converts the pixel range 0.0..1.0 into the integer range 0..255 int f2i(float x) { return int(x * 255.9); } // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: uniform vec4 clrMod; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: uniform mat3x2 lightTransform; #ifdef HAVE_NORMALMAP uniform sampler2D normalTex; #endif #ifdef MESH varying vec3 normalDir; #endif // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Base light calculations #ifdef HAVE_LIGHT uniform sampler2D lightTex; #endif // uncomment the following lines for debugging light directions: // yellow: light up, blue: light down, turqoise: light right, pink: light left // brightness: light strength //#define LIGHT_DEBUG // At what point of light intensity we set the "darkness" point. This // is to compensate for the fact that the engien "smoothes" the light // and therefore will often never arrive at 0 light intensity. const float lightDarknessLevel = 8.0 / 256.0; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Ambient light calculation #ifdef HAVE_LIGHT uniform sampler2D ambientTex; uniform mat3x2 ambientTransform; uniform float ambientBrightness; #endif void main() { // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: #define color gl_FragColor #ifdef MESH // TODO: Add emission part of the material. Note we cannot just // add this to the color, but it would need to be handled separately, // such that it is independent from the incident light direction. color = gl_FrontMaterial.diffuse; #else vec4 baseColor = gl_Color; color = baseColor; #endif // Position 44: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_LIGHT // prepare texture coordinate for light lookup in LightShader.c vec2 lightCoord = lightTransform * vec3(gl_FragCoord.xy, 1.0); #endif // Position 45: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef HAVE_LIGHT // Query light texture vec4 lightPx = texture2D(lightTex, lightCoord.st); float lightBright = max(0.0, lightPx.x-lightDarknessLevel); vec3 lightDir = extend_normal(vec2(1.0, 1.0) - lightPx.yz * 3.0); #else // When lighting is disabled, put a light source coming from the camera. // Note that in most cases this does not actually matter, since in the // case with lighting disabled, ambient lighting takes fully over. float lightBright = 0.5; vec3 lightDir = vec3(0.0, 0.0, 1.0); #endif // Position 46: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: #ifdef HAVE_LIGHT // Ambient light float ambient = texture2D(ambientTex, ambientTransform * vec3(gl_FragCoord.xy, 1.0)).r * ambientBrightness; #else // Lighting disabled: Ambient light everywhere float ambient = 1.0; #endif // Position 80: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_NORMALMAP vec4 normalPx = texture2D(normalTex, texcoord.xy); vec3 normalPxDir = 2.0 * (normalPx.xyz - vec3(0.5, 0.5, 0.5)); vec3 normal = normalize(gl_NormalMatrix * normalPxDir); #else #ifdef MESH vec3 normal = normalDir; // Normal matrix is already applied in vertex shader #else vec3 normal = vec3(0.0, 0.0, 1.0); #endif #endif // Position 100: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: float light = 2.0 * lightBright * max(dot(normal, lightDir), 0.0); #ifdef HAVE_2PX float light2 = 2.0 * lightBright * max(dot(normal2, lightDir), 0.0); #endif // Position 101: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Add ambience to brightness #ifdef LANDSCAPE // For landscape, ambient brightness is coming from top vec3 ambientDir = vec3(0.0, -1.0, 0.0); light = mix(light, 1.0 + 1.0 * dot(normal, ambientDir), ambient); #ifdef HAVE_2PX light2 = mix(light2, 1.0 + 1.0 * dot(normal2, ambientDir), ambient); #endif #else // For objects, ambient brightness is coming from the front vec3 ambientDir = vec3(0.0, 0.0, 1.0); light = mix(light, max(dot(normal, ambientDir), 0.0), ambient); #endif // Position 120: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: // TODO: Instead of a conditional, we could compute the color as // color = A + B*color + C*clrMod + D*color*clrMod; // Then, mod2 would be A=-0.5, B=1, C=1, D=0 // and default would be A=0,B=0,C=0,D=1 // Would allow to avoid conditionsals and #ifdefs, but need 4 uniforms... // Could also try some sort of 3x3 matrix: // out = (color, clrmod, 1) * (A,B,C,D,E,F,0,0,G) * (color, clrmod, 1) #ifdef CLRMOD_MOD2 color = clamp(color + clrMod - 0.5, 0.0, 1.0); #else color = color * clrMod; #endif // Position 125: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Add light color = vec4(light * color.rgb, color.a); #ifdef HAVE_2PX color2 = vec4(light2 * color2.rgb, color2.a); #endif // Position 145: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef LIGHT_DEBUG #ifdef HAVE_LIGHT float lightYDir = lightPx.b - 1.0/3.0; float lightXDir = lightPx.g - 1.0/3.0; float lightStrength = lightPx.r; color = vec4(lightStrength * vec3(1.0-1.5*(max(0.0, lightYDir) + max(0.0,lightXDir)), 1.0-1.5*(max(0.0, lightYDir) + max(0.0,-lightXDir)), 1.0-1.5*max(0.0, -lightYDir)), 1.0); #else color = vec4(0.0, 0.0, 0.0, 0.0); // invisible #endif #endif } gl: Compiling spriteMod2 vertex shader: No errors. gl: Compiling spriteMod2 fragment shader: No errors. gl: Compiling spriteMod2 shader program: No errors. gl: spriteMod2 shader linked successfully ******** Vertex shader for spriteBase: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 void main() { // Position 50: // Built-in slice: gl_TexCoord[0] = gl_MultiTexCoord0; // Position 80: // Built-in slice: gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } ******** Fragment shader for spriteBase: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 // Built-in slice: #define texcoord gl_TexCoord[0] // Built-in slice: #define OPENCLONK // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\UtilShader.glsl: // #ifdef NO_TEXTURE_LOD_IN_FRAGMENT #define texture1DLod(t,c,l) texture1D(t,c) #define texture2DLod(t,c,l) texture2D(t,c) // #endif vec3 extend_normal(vec2 v) { // the higher the second value, the further away the light source from the landscape return normalize(vec3(v, 0.45)); } // Converts the pixel range 0.0..1.0 into the integer range 0..255 int f2i(float x) { return int(x * 255.9); } // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: uniform vec4 clrMod; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: uniform sampler2D baseTex; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: uniform mat3x2 lightTransform; #ifdef HAVE_NORMALMAP uniform sampler2D normalTex; #endif #ifdef MESH varying vec3 normalDir; #endif // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Base light calculations #ifdef HAVE_LIGHT uniform sampler2D lightTex; #endif // uncomment the following lines for debugging light directions: // yellow: light up, blue: light down, turqoise: light right, pink: light left // brightness: light strength //#define LIGHT_DEBUG // At what point of light intensity we set the "darkness" point. This // is to compensate for the fact that the engien "smoothes" the light // and therefore will often never arrive at 0 light intensity. const float lightDarknessLevel = 8.0 / 256.0; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Ambient light calculation #ifdef HAVE_LIGHT uniform sampler2D ambientTex; uniform mat3x2 ambientTransform; uniform float ambientBrightness; #endif void main() { // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: #define color gl_FragColor #ifdef MESH // TODO: Add emission part of the material. Note we cannot just // add this to the color, but it would need to be handled separately, // such that it is independent from the incident light direction. color = gl_FrontMaterial.diffuse; #else vec4 baseColor = gl_Color; color = baseColor; #endif // Position 40: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: color = baseColor * texture2D(baseTex, texcoord.xy); // Position 44: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_LIGHT // prepare texture coordinate for light lookup in LightShader.c vec2 lightCoord = lightTransform * vec3(gl_FragCoord.xy, 1.0); #endif // Position 45: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef HAVE_LIGHT // Query light texture vec4 lightPx = texture2D(lightTex, lightCoord.st); float lightBright = max(0.0, lightPx.x-lightDarknessLevel); vec3 lightDir = extend_normal(vec2(1.0, 1.0) - lightPx.yz * 3.0); #else // When lighting is disabled, put a light source coming from the camera. // Note that in most cases this does not actually matter, since in the // case with lighting disabled, ambient lighting takes fully over. float lightBright = 0.5; vec3 lightDir = vec3(0.0, 0.0, 1.0); #endif // Position 46: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: #ifdef HAVE_LIGHT // Ambient light float ambient = texture2D(ambientTex, ambientTransform * vec3(gl_FragCoord.xy, 1.0)).r * ambientBrightness; #else // Lighting disabled: Ambient light everywhere float ambient = 1.0; #endif // Position 80: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_NORMALMAP vec4 normalPx = texture2D(normalTex, texcoord.xy); vec3 normalPxDir = 2.0 * (normalPx.xyz - vec3(0.5, 0.5, 0.5)); vec3 normal = normalize(gl_NormalMatrix * normalPxDir); #else #ifdef MESH vec3 normal = normalDir; // Normal matrix is already applied in vertex shader #else vec3 normal = vec3(0.0, 0.0, 1.0); #endif #endif // Position 100: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: float light = 2.0 * lightBright * max(dot(normal, lightDir), 0.0); #ifdef HAVE_2PX float light2 = 2.0 * lightBright * max(dot(normal2, lightDir), 0.0); #endif // Position 101: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Add ambience to brightness #ifdef LANDSCAPE // For landscape, ambient brightness is coming from top vec3 ambientDir = vec3(0.0, -1.0, 0.0); light = mix(light, 1.0 + 1.0 * dot(normal, ambientDir), ambient); #ifdef HAVE_2PX light2 = mix(light2, 1.0 + 1.0 * dot(normal2, ambientDir), ambient); #endif #else // For objects, ambient brightness is coming from the front vec3 ambientDir = vec3(0.0, 0.0, 1.0); light = mix(light, max(dot(normal, ambientDir), 0.0), ambient); #endif // Position 120: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: // TODO: Instead of a conditional, we could compute the color as // color = A + B*color + C*clrMod + D*color*clrMod; // Then, mod2 would be A=-0.5, B=1, C=1, D=0 // and default would be A=0,B=0,C=0,D=1 // Would allow to avoid conditionsals and #ifdefs, but need 4 uniforms... // Could also try some sort of 3x3 matrix: // out = (color, clrmod, 1) * (A,B,C,D,E,F,0,0,G) * (color, clrmod, 1) #ifdef CLRMOD_MOD2 color = clamp(color + clrMod - 0.5, 0.0, 1.0); #else color = color * clrMod; #endif // Position 125: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Add light color = vec4(light * color.rgb, color.a); #ifdef HAVE_2PX color2 = vec4(light2 * color2.rgb, color2.a); #endif // Position 145: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef LIGHT_DEBUG #ifdef HAVE_LIGHT float lightYDir = lightPx.b - 1.0/3.0; float lightXDir = lightPx.g - 1.0/3.0; float lightStrength = lightPx.r; color = vec4(lightStrength * vec3(1.0-1.5*(max(0.0, lightYDir) + max(0.0,lightXDir)), 1.0-1.5*(max(0.0, lightYDir) + max(0.0,-lightXDir)), 1.0-1.5*max(0.0, -lightYDir)), 1.0); #else color = vec4(0.0, 0.0, 0.0, 0.0); // invisible #endif #endif } gl: Compiling spriteBase vertex shader: No errors. gl: Compiling spriteBase fragment shader: No errors. gl: Compiling spriteBase shader program: No errors. gl: spriteBase shader linked successfully ******** Vertex shader for spriteBaseMod2: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 void main() { // Position 50: // Built-in slice: gl_TexCoord[0] = gl_MultiTexCoord0; // Position 80: // Built-in slice: gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } ******** Fragment shader for spriteBaseMod2: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 // Built-in slice: #define texcoord gl_TexCoord[0] // Built-in slice: #define OPENCLONK // Built-in slice: #define CLRMOD_MOD2 // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\UtilShader.glsl: // #ifdef NO_TEXTURE_LOD_IN_FRAGMENT #define texture1DLod(t,c,l) texture1D(t,c) #define texture2DLod(t,c,l) texture2D(t,c) // #endif vec3 extend_normal(vec2 v) { // the higher the second value, the further away the light source from the landscape return normalize(vec3(v, 0.45)); } // Converts the pixel range 0.0..1.0 into the integer range 0..255 int f2i(float x) { return int(x * 255.9); } // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: uniform vec4 clrMod; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: uniform sampler2D baseTex; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: uniform mat3x2 lightTransform; #ifdef HAVE_NORMALMAP uniform sampler2D normalTex; #endif #ifdef MESH varying vec3 normalDir; #endif // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Base light calculations #ifdef HAVE_LIGHT uniform sampler2D lightTex; #endif // uncomment the following lines for debugging light directions: // yellow: light up, blue: light down, turqoise: light right, pink: light left // brightness: light strength //#define LIGHT_DEBUG // At what point of light intensity we set the "darkness" point. This // is to compensate for the fact that the engien "smoothes" the light // and therefore will often never arrive at 0 light intensity. const float lightDarknessLevel = 8.0 / 256.0; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Ambient light calculation #ifdef HAVE_LIGHT uniform sampler2D ambientTex; uniform mat3x2 ambientTransform; uniform float ambientBrightness; #endif void main() { // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: #define color gl_FragColor #ifdef MESH // TODO: Add emission part of the material. Note we cannot just // add this to the color, but it would need to be handled separately, // such that it is independent from the incident light direction. color = gl_FrontMaterial.diffuse; #else vec4 baseColor = gl_Color; color = baseColor; #endif // Position 40: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: color = baseColor * texture2D(baseTex, texcoord.xy); // Position 44: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_LIGHT // prepare texture coordinate for light lookup in LightShader.c vec2 lightCoord = lightTransform * vec3(gl_FragCoord.xy, 1.0); #endif // Position 45: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef HAVE_LIGHT // Query light texture vec4 lightPx = texture2D(lightTex, lightCoord.st); float lightBright = max(0.0, lightPx.x-lightDarknessLevel); vec3 lightDir = extend_normal(vec2(1.0, 1.0) - lightPx.yz * 3.0); #else // When lighting is disabled, put a light source coming from the camera. // Note that in most cases this does not actually matter, since in the // case with lighting disabled, ambient lighting takes fully over. float lightBright = 0.5; vec3 lightDir = vec3(0.0, 0.0, 1.0); #endif // Position 46: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: #ifdef HAVE_LIGHT // Ambient light float ambient = texture2D(ambientTex, ambientTransform * vec3(gl_FragCoord.xy, 1.0)).r * ambientBrightness; #else // Lighting disabled: Ambient light everywhere float ambient = 1.0; #endif // Position 80: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_NORMALMAP vec4 normalPx = texture2D(normalTex, texcoord.xy); vec3 normalPxDir = 2.0 * (normalPx.xyz - vec3(0.5, 0.5, 0.5)); vec3 normal = normalize(gl_NormalMatrix * normalPxDir); #else #ifdef MESH vec3 normal = normalDir; // Normal matrix is already applied in vertex shader #else vec3 normal = vec3(0.0, 0.0, 1.0); #endif #endif // Position 100: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: float light = 2.0 * lightBright * max(dot(normal, lightDir), 0.0); #ifdef HAVE_2PX float light2 = 2.0 * lightBright * max(dot(normal2, lightDir), 0.0); #endif // Position 101: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Add ambience to brightness #ifdef LANDSCAPE // For landscape, ambient brightness is coming from top vec3 ambientDir = vec3(0.0, -1.0, 0.0); light = mix(light, 1.0 + 1.0 * dot(normal, ambientDir), ambient); #ifdef HAVE_2PX light2 = mix(light2, 1.0 + 1.0 * dot(normal2, ambientDir), ambient); #endif #else // For objects, ambient brightness is coming from the front vec3 ambientDir = vec3(0.0, 0.0, 1.0); light = mix(light, max(dot(normal, ambientDir), 0.0), ambient); #endif // Position 120: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: // TODO: Instead of a conditional, we could compute the color as // color = A + B*color + C*clrMod + D*color*clrMod; // Then, mod2 would be A=-0.5, B=1, C=1, D=0 // and default would be A=0,B=0,C=0,D=1 // Would allow to avoid conditionsals and #ifdefs, but need 4 uniforms... // Could also try some sort of 3x3 matrix: // out = (color, clrmod, 1) * (A,B,C,D,E,F,0,0,G) * (color, clrmod, 1) #ifdef CLRMOD_MOD2 color = clamp(color + clrMod - 0.5, 0.0, 1.0); #else color = color * clrMod; #endif // Position 125: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Add light color = vec4(light * color.rgb, color.a); #ifdef HAVE_2PX color2 = vec4(light2 * color2.rgb, color2.a); #endif // Position 145: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef LIGHT_DEBUG #ifdef HAVE_LIGHT float lightYDir = lightPx.b - 1.0/3.0; float lightXDir = lightPx.g - 1.0/3.0; float lightStrength = lightPx.r; color = vec4(lightStrength * vec3(1.0-1.5*(max(0.0, lightYDir) + max(0.0,lightXDir)), 1.0-1.5*(max(0.0, lightYDir) + max(0.0,-lightXDir)), 1.0-1.5*max(0.0, -lightYDir)), 1.0); #else color = vec4(0.0, 0.0, 0.0, 0.0); // invisible #endif #endif } gl: Compiling spriteBaseMod2 vertex shader: No errors. gl: Compiling spriteBaseMod2 fragment shader: No errors. gl: Compiling spriteBaseMod2 shader program: No errors. gl: spriteBaseMod2 shader linked successfully ******** Vertex shader for spriteBaseOverlay: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 void main() { // Position 50: // Built-in slice: gl_TexCoord[0] = gl_MultiTexCoord0; // Position 80: // Built-in slice: gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } ******** Fragment shader for spriteBaseOverlay: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 // Built-in slice: #define texcoord gl_TexCoord[0] // Built-in slice: #define OPENCLONK // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\UtilShader.glsl: // #ifdef NO_TEXTURE_LOD_IN_FRAGMENT #define texture1DLod(t,c,l) texture1D(t,c) #define texture2DLod(t,c,l) texture2D(t,c) // #endif vec3 extend_normal(vec2 v) { // the higher the second value, the further away the light source from the landscape return normalize(vec3(v, 0.45)); } // Converts the pixel range 0.0..1.0 into the integer range 0..255 int f2i(float x) { return int(x * 255.9); } // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: uniform vec4 clrMod; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: uniform sampler2D baseTex; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteOverlayShader.glsl: uniform vec4 overlayClr; uniform sampler2D overlayTex; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: uniform mat3x2 lightTransform; #ifdef HAVE_NORMALMAP uniform sampler2D normalTex; #endif #ifdef MESH varying vec3 normalDir; #endif // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Base light calculations #ifdef HAVE_LIGHT uniform sampler2D lightTex; #endif // uncomment the following lines for debugging light directions: // yellow: light up, blue: light down, turqoise: light right, pink: light left // brightness: light strength //#define LIGHT_DEBUG // At what point of light intensity we set the "darkness" point. This // is to compensate for the fact that the engien "smoothes" the light // and therefore will often never arrive at 0 light intensity. const float lightDarknessLevel = 8.0 / 256.0; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Ambient light calculation #ifdef HAVE_LIGHT uniform sampler2D ambientTex; uniform mat3x2 ambientTransform; uniform float ambientBrightness; #endif void main() { // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: #define color gl_FragColor #ifdef MESH // TODO: Add emission part of the material. Note we cannot just // add this to the color, but it would need to be handled separately, // such that it is independent from the incident light direction. color = gl_FrontMaterial.diffuse; #else vec4 baseColor = gl_Color; color = baseColor; #endif // Position 40: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: color = baseColor * texture2D(baseTex, texcoord.xy); // Position 41: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteOverlayShader.glsl: // Get overlay color from overlay texture vec4 overlay = baseColor * overlayClr * texture2D(overlayTex, texcoord.xy); // Mix overlay with texture float alpha0 = 1.0 - (1.0 - color.a) * (1.0 - overlay.a); color = vec4(mix(color.rgb, overlay.rgb, overlay.a / alpha0), alpha0); // Position 44: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_LIGHT // prepare texture coordinate for light lookup in LightShader.c vec2 lightCoord = lightTransform * vec3(gl_FragCoord.xy, 1.0); #endif // Position 45: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef HAVE_LIGHT // Query light texture vec4 lightPx = texture2D(lightTex, lightCoord.st); float lightBright = max(0.0, lightPx.x-lightDarknessLevel); vec3 lightDir = extend_normal(vec2(1.0, 1.0) - lightPx.yz * 3.0); #else // When lighting is disabled, put a light source coming from the camera. // Note that in most cases this does not actually matter, since in the // case with lighting disabled, ambient lighting takes fully over. float lightBright = 0.5; vec3 lightDir = vec3(0.0, 0.0, 1.0); #endif // Position 46: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: #ifdef HAVE_LIGHT // Ambient light float ambient = texture2D(ambientTex, ambientTransform * vec3(gl_FragCoord.xy, 1.0)).r * ambientBrightness; #else // Lighting disabled: Ambient light everywhere float ambient = 1.0; #endif // Position 80: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_NORMALMAP vec4 normalPx = texture2D(normalTex, texcoord.xy); vec3 normalPxDir = 2.0 * (normalPx.xyz - vec3(0.5, 0.5, 0.5)); vec3 normal = normalize(gl_NormalMatrix * normalPxDir); #else #ifdef MESH vec3 normal = normalDir; // Normal matrix is already applied in vertex shader #else vec3 normal = vec3(0.0, 0.0, 1.0); #endif #endif // Position 100: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: float light = 2.0 * lightBright * max(dot(normal, lightDir), 0.0); #ifdef HAVE_2PX float light2 = 2.0 * lightBright * max(dot(normal2, lightDir), 0.0); #endif // Position 101: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Add ambience to brightness #ifdef LANDSCAPE // For landscape, ambient brightness is coming from top vec3 ambientDir = vec3(0.0, -1.0, 0.0); light = mix(light, 1.0 + 1.0 * dot(normal, ambientDir), ambient); #ifdef HAVE_2PX light2 = mix(light2, 1.0 + 1.0 * dot(normal2, ambientDir), ambient); #endif #else // For objects, ambient brightness is coming from the front vec3 ambientDir = vec3(0.0, 0.0, 1.0); light = mix(light, max(dot(normal, ambientDir), 0.0), ambient); #endif // Position 120: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: // TODO: Instead of a conditional, we could compute the color as // color = A + B*color + C*clrMod + D*color*clrMod; // Then, mod2 would be A=-0.5, B=1, C=1, D=0 // and default would be A=0,B=0,C=0,D=1 // Would allow to avoid conditionsals and #ifdefs, but need 4 uniforms... // Could also try some sort of 3x3 matrix: // out = (color, clrmod, 1) * (A,B,C,D,E,F,0,0,G) * (color, clrmod, 1) #ifdef CLRMOD_MOD2 color = clamp(color + clrMod - 0.5, 0.0, 1.0); #else color = color * clrMod; #endif // Position 125: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Add light color = vec4(light * color.rgb, color.a); #ifdef HAVE_2PX color2 = vec4(light2 * color2.rgb, color2.a); #endif // Position 145: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef LIGHT_DEBUG #ifdef HAVE_LIGHT float lightYDir = lightPx.b - 1.0/3.0; float lightXDir = lightPx.g - 1.0/3.0; float lightStrength = lightPx.r; color = vec4(lightStrength * vec3(1.0-1.5*(max(0.0, lightYDir) + max(0.0,lightXDir)), 1.0-1.5*(max(0.0, lightYDir) + max(0.0,-lightXDir)), 1.0-1.5*max(0.0, -lightYDir)), 1.0); #else color = vec4(0.0, 0.0, 0.0, 0.0); // invisible #endif #endif } gl: Compiling spriteBaseOverlay vertex shader: No errors. gl: Compiling spriteBaseOverlay fragment shader: No errors. gl: Compiling spriteBaseOverlay shader program: No errors. gl: spriteBaseOverlay shader linked successfully ******** Vertex shader for spriteBaseOverlayMod2: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 void main() { // Position 50: // Built-in slice: gl_TexCoord[0] = gl_MultiTexCoord0; // Position 80: // Built-in slice: gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } ******** Fragment shader for spriteBaseOverlayMod2: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 // Built-in slice: #define texcoord gl_TexCoord[0] // Built-in slice: #define OPENCLONK // Built-in slice: #define CLRMOD_MOD2 // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\UtilShader.glsl: // #ifdef NO_TEXTURE_LOD_IN_FRAGMENT #define texture1DLod(t,c,l) texture1D(t,c) #define texture2DLod(t,c,l) texture2D(t,c) // #endif vec3 extend_normal(vec2 v) { // the higher the second value, the further away the light source from the landscape return normalize(vec3(v, 0.45)); } // Converts the pixel range 0.0..1.0 into the integer range 0..255 int f2i(float x) { return int(x * 255.9); } // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: uniform vec4 clrMod; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: uniform sampler2D baseTex; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteOverlayShader.glsl: uniform vec4 overlayClr; uniform sampler2D overlayTex; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: uniform mat3x2 lightTransform; #ifdef HAVE_NORMALMAP uniform sampler2D normalTex; #endif #ifdef MESH varying vec3 normalDir; #endif // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Base light calculations #ifdef HAVE_LIGHT uniform sampler2D lightTex; #endif // uncomment the following lines for debugging light directions: // yellow: light up, blue: light down, turqoise: light right, pink: light left // brightness: light strength //#define LIGHT_DEBUG // At what point of light intensity we set the "darkness" point. This // is to compensate for the fact that the engien "smoothes" the light // and therefore will often never arrive at 0 light intensity. const float lightDarknessLevel = 8.0 / 256.0; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Ambient light calculation #ifdef HAVE_LIGHT uniform sampler2D ambientTex; uniform mat3x2 ambientTransform; uniform float ambientBrightness; #endif void main() { // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: #define color gl_FragColor #ifdef MESH // TODO: Add emission part of the material. Note we cannot just // add this to the color, but it would need to be handled separately, // such that it is independent from the incident light direction. color = gl_FrontMaterial.diffuse; #else vec4 baseColor = gl_Color; color = baseColor; #endif // Position 40: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteTextureShader.glsl: color = baseColor * texture2D(baseTex, texcoord.xy); // Position 41: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\SpriteOverlayShader.glsl: // Get overlay color from overlay texture vec4 overlay = baseColor * overlayClr * texture2D(overlayTex, texcoord.xy); // Mix overlay with texture float alpha0 = 1.0 - (1.0 - color.a) * (1.0 - overlay.a); color = vec4(mix(color.rgb, overlay.rgb, overlay.a / alpha0), alpha0); // Position 44: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_LIGHT // prepare texture coordinate for light lookup in LightShader.c vec2 lightCoord = lightTransform * vec3(gl_FragCoord.xy, 1.0); #endif // Position 45: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef HAVE_LIGHT // Query light texture vec4 lightPx = texture2D(lightTex, lightCoord.st); float lightBright = max(0.0, lightPx.x-lightDarknessLevel); vec3 lightDir = extend_normal(vec2(1.0, 1.0) - lightPx.yz * 3.0); #else // When lighting is disabled, put a light source coming from the camera. // Note that in most cases this does not actually matter, since in the // case with lighting disabled, ambient lighting takes fully over. float lightBright = 0.5; vec3 lightDir = vec3(0.0, 0.0, 1.0); #endif // Position 46: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: #ifdef HAVE_LIGHT // Ambient light float ambient = texture2D(ambientTex, ambientTransform * vec3(gl_FragCoord.xy, 1.0)).r * ambientBrightness; #else // Lighting disabled: Ambient light everywhere float ambient = 1.0; #endif // Position 80: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_NORMALMAP vec4 normalPx = texture2D(normalTex, texcoord.xy); vec3 normalPxDir = 2.0 * (normalPx.xyz - vec3(0.5, 0.5, 0.5)); vec3 normal = normalize(gl_NormalMatrix * normalPxDir); #else #ifdef MESH vec3 normal = normalDir; // Normal matrix is already applied in vertex shader #else vec3 normal = vec3(0.0, 0.0, 1.0); #endif #endif // Position 100: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: float light = 2.0 * lightBright * max(dot(normal, lightDir), 0.0); #ifdef HAVE_2PX float light2 = 2.0 * lightBright * max(dot(normal2, lightDir), 0.0); #endif // Position 101: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Add ambience to brightness #ifdef LANDSCAPE // For landscape, ambient brightness is coming from top vec3 ambientDir = vec3(0.0, -1.0, 0.0); light = mix(light, 1.0 + 1.0 * dot(normal, ambientDir), ambient); #ifdef HAVE_2PX light2 = mix(light2, 1.0 + 1.0 * dot(normal2, ambientDir), ambient); #endif #else // For objects, ambient brightness is coming from the front vec3 ambientDir = vec3(0.0, 0.0, 1.0); light = mix(light, max(dot(normal, ambientDir), 0.0), ambient); #endif // Position 120: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: // TODO: Instead of a conditional, we could compute the color as // color = A + B*color + C*clrMod + D*color*clrMod; // Then, mod2 would be A=-0.5, B=1, C=1, D=0 // and default would be A=0,B=0,C=0,D=1 // Would allow to avoid conditionsals and #ifdefs, but need 4 uniforms... // Could also try some sort of 3x3 matrix: // out = (color, clrmod, 1) * (A,B,C,D,E,F,0,0,G) * (color, clrmod, 1) #ifdef CLRMOD_MOD2 color = clamp(color + clrMod - 0.5, 0.0, 1.0); #else color = color * clrMod; #endif // Position 125: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Add light color = vec4(light * color.rgb, color.a); #ifdef HAVE_2PX color2 = vec4(light2 * color2.rgb, color2.a); #endif // Position 145: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef LIGHT_DEBUG #ifdef HAVE_LIGHT float lightYDir = lightPx.b - 1.0/3.0; float lightXDir = lightPx.g - 1.0/3.0; float lightStrength = lightPx.r; color = vec4(lightStrength * vec3(1.0-1.5*(max(0.0, lightYDir) + max(0.0,lightXDir)), 1.0-1.5*(max(0.0, lightYDir) + max(0.0,-lightXDir)), 1.0-1.5*max(0.0, -lightYDir)), 1.0); #else color = vec4(0.0, 0.0, 0.0, 0.0); // invisible #endif #endif } gl: Compiling spriteBaseOverlayMod2 vertex shader: No errors. gl: Compiling spriteBaseOverlayMod2 fragment shader: No errors. gl: Compiling spriteBaseOverlayMod2 shader program: No errors. gl: spriteBaseOverlayMod2 shader linked successfully ******** Vertex shader for spriteLight: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 void main() { // Position 80: // Built-in slice: gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } ******** Fragment shader for spriteLight: #version 120 #define MAX_FRAGMENT_UNIFORM_COMPONENTS 1024 #define MAX_VERTEX_UNIFORM_COMPONENTS 512 // Built-in slice: #define OPENCLONK // Built-in slice: #define HAVE_LIGHT // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\UtilShader.glsl: // #ifdef NO_TEXTURE_LOD_IN_FRAGMENT #define texture1DLod(t,c,l) texture1D(t,c) #define texture2DLod(t,c,l) texture2D(t,c) // #endif vec3 extend_normal(vec2 v) { // the higher the second value, the further away the light source from the landscape return normalize(vec3(v, 0.45)); } // Converts the pixel range 0.0..1.0 into the integer range 0..255 int f2i(float x) { return int(x * 255.9); } // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: uniform vec4 clrMod; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: uniform mat3x2 lightTransform; #ifdef HAVE_NORMALMAP uniform sampler2D normalTex; #endif #ifdef MESH varying vec3 normalDir; #endif // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Base light calculations #ifdef HAVE_LIGHT uniform sampler2D lightTex; #endif // uncomment the following lines for debugging light directions: // yellow: light up, blue: light down, turqoise: light right, pink: light left // brightness: light strength //#define LIGHT_DEBUG // At what point of light intensity we set the "darkness" point. This // is to compensate for the fact that the engien "smoothes" the light // and therefore will often never arrive at 0 light intensity. const float lightDarknessLevel = 8.0 / 256.0; // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Ambient light calculation #ifdef HAVE_LIGHT uniform sampler2D ambientTex; uniform mat3x2 ambientTransform; uniform float ambientBrightness; #endif void main() { // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: #define color gl_FragColor #ifdef MESH // TODO: Add emission part of the material. Note we cannot just // add this to the color, but it would need to be handled separately, // such that it is independent from the incident light direction. color = gl_FrontMaterial.diffuse; #else vec4 baseColor = gl_Color; color = baseColor; #endif // Position 44: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_LIGHT // prepare texture coordinate for light lookup in LightShader.c vec2 lightCoord = lightTransform * vec3(gl_FragCoord.xy, 1.0); #endif // Position 45: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef HAVE_LIGHT // Query light texture vec4 lightPx = texture2D(lightTex, lightCoord.st); float lightBright = max(0.0, lightPx.x-lightDarknessLevel); vec3 lightDir = extend_normal(vec2(1.0, 1.0) - lightPx.yz * 3.0); #else // When lighting is disabled, put a light source coming from the camera. // Note that in most cases this does not actually matter, since in the // case with lighting disabled, ambient lighting takes fully over. float lightBright = 0.5; vec3 lightDir = vec3(0.0, 0.0, 1.0); #endif // Position 46: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: #ifdef HAVE_LIGHT // Ambient light float ambient = texture2D(ambientTex, ambientTransform * vec3(gl_FragCoord.xy, 1.0)).r * ambientBrightness; #else // Lighting disabled: Ambient light everywhere float ambient = 1.0; #endif // Position 80: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectLightShader.glsl: #ifdef HAVE_NORMALMAP vec4 normalPx = texture2D(normalTex, texcoord.xy); vec3 normalPxDir = 2.0 * (normalPx.xyz - vec3(0.5, 0.5, 0.5)); vec3 normal = normalize(gl_NormalMatrix * normalPxDir); #else #ifdef MESH vec3 normal = normalDir; // Normal matrix is already applied in vertex shader #else vec3 normal = vec3(0.0, 0.0, 1.0); #endif #endif // Position 100: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: float light = 2.0 * lightBright * max(dot(normal, lightDir), 0.0); #ifdef HAVE_2PX float light2 = 2.0 * lightBright * max(dot(normal2, lightDir), 0.0); #endif // Position 101: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\AmbientShader.glsl: // Add ambience to brightness #ifdef LANDSCAPE // For landscape, ambient brightness is coming from top vec3 ambientDir = vec3(0.0, -1.0, 0.0); light = mix(light, 1.0 + 1.0 * dot(normal, ambientDir), ambient); #ifdef HAVE_2PX light2 = mix(light2, 1.0 + 1.0 * dot(normal2, ambientDir), ambient); #endif #else // For objects, ambient brightness is coming from the front vec3 ambientDir = vec3(0.0, 0.0, 1.0); light = mix(light, max(dot(normal, ambientDir), 0.0), ambient); #endif // Position 120: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\ObjectBaseShader.glsl: // TODO: Instead of a conditional, we could compute the color as // color = A + B*color + C*clrMod + D*color*clrMod; // Then, mod2 would be A=-0.5, B=1, C=1, D=0 // and default would be A=0,B=0,C=0,D=1 // Would allow to avoid conditionsals and #ifdefs, but need 4 uniforms... // Could also try some sort of 3x3 matrix: // out = (color, clrmod, 1) * (A,B,C,D,E,F,0,0,G) * (color, clrmod, 1) #ifdef CLRMOD_MOD2 color = clamp(color + clrMod - 0.5, 0.0, 1.0); #else color = color * clrMod; #endif // Position 125: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: // Add light color = vec4(light * color.rgb, color.a); #ifdef HAVE_2PX color2 = vec4(light2 * color2.rgb, color2.a); #endif // Position 145: // Slice from C:\Dokumente und Einstellungen\frnv401\Eigene Dateien\oc snapshot\\Graphics.ocg\LightShader.glsl: #ifdef LIGHT_DEBUG #ifdef HAVE_LIGHT float lightYDir = lightPx.b - 1.0/3.0; float lightXDir = lightPx.g - 1.0/3.0; float lightStrength = lightPx.r; color = vec4(lightStrength * vec3(1.0-1.5*(max(0.0, lightYDir) + max(0.0,lightXDir)), 1.0-1.5*(max(0.0, lightYDir) + max(0.0,-lightXDir)), 1.0-1.5*max(0.0, -lightYDir)), 1.0); #else color = vec4(0.0, 0.0, 0.0, 0.0); // invisible #endif #endif } gl: Compiling spriteLight vertex shader: No errors. gl: Compiling spriteLight fragment shader: ERROR: 0:74: '=' : cannot convert from '3-component vector of float' to '2-component vector of float' ERROR: 0:92: 'texture2D' : no matching overloaded function found (using implicit conversion) ERROR: 0:92: 'r' : field selection requires structure, vector, or matrix on left hand side