Changeset 540
- Timestamp:
- 05/17/08 11:10:34 (8 months ago)
- Files:
-
- trunk/run/data/shaders/model-pixel.glsl (modified) (2 diffs)
- trunk/run/data/shaders/model-vertex.glsl (modified) (2 diffs)
- trunk/run/data/shaders/shadowmap.glsl (modified) (1 diff)
- trunk/run/data/shaders/terrain-pixel.glsl (modified) (2 diffs)
- trunk/run/data/shaders/terrain-vertex.glsl (modified) (2 diffs)
- trunk/run/defend.cfg (modified) (2 diffs)
- trunk/src/defend/Config.d (modified) (1 diff)
- trunk/src/defend/Main.d (modified) (1 diff)
- trunk/src/defend/game/Game.d (modified) (2 diffs)
- trunk/src/defend/objects/SceneNode.d (modified) (2 diffs)
- trunk/src/gen/util/Config.d (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/run/data/shaders/model-pixel.glsl
r539 r540 1 1 uniform sampler2D diffuseTexture; 2 3 #if defined(OBJECTS_LIGHTMAP) 2 4 uniform sampler2D lightTexture; 5 #endif 3 6 4 #if def SHADOWMAPPING7 #if defined(SHADOWMAPPING) 5 8 # include "shadowmap.glsl" 6 9 … … 16 19 { 17 20 vec4 tex = texture2D(diffuseTexture, vec2(gl_TexCoord[0])); 21 22 gl_FragColor = vec4(tex.rgb * tex.a + color * (1 - tex.a), 1.0); 23 24 #if defined(OBJECTS_LIGHTMAP) 18 25 vec4 light = texture2D(lightTexture, vec2(gl_TexCoord[1])); 26 gl_FragColor *= (light * 2); 27 #endif 19 28 20 gl_FragColor = vec4(tex.rgb * tex.a + color * (1 - tex.a), 1.0) * (light * 2); 21 22 #ifdef SHADOWMAPPING 29 #if defined(SHADOWMAPPING) 23 30 gl_FragColor *= shadowMap(shadowTexture, lightSpacePos); 24 #el se31 #elif defined(NORMAL_LIGHTING) 25 32 gl_FragColor *= gl_Color; 26 33 #endif trunk/run/data/shaders/model-vertex.glsl
r537 r540 1 #if defined(OBJECTS_LIGHTMAP) 1 2 uniform vec3 mapPos; 2 3 uniform vec3 mapSize; 4 #endif 3 5 4 #if def SHADOWMAPPING6 #if defined(SHADOWMAPPING) 5 7 uniform mat4 lightTransform; 6 8 uniform mat4 modelTransform; … … 18 20 19 21 gl_TexCoord[0] = gl_MultiTexCoord0; 22 23 #if defined(OBJECTS_LIGHTMAP) 20 24 gl_TexCoord[1] = vec4(mapPos.x / mapSize.x, -mapPos.z / mapSize.y, 0.0, 0.0); 25 #endif 21 26 22 #if def SHADOWMAPPING27 #if defined(SHADOWMAPPING) 23 28 lightSpacePos = lightTransform * (modelTransform * gl_Vertex); 24 #el se29 #elif defined(NORMAL_LIGHTING) 25 30 vec3 position = vec3(gl_ModelViewMatrix * gl_Vertex); 26 31 vec3 light = vec3(normalize(vec3(gl_LightSource[0].position) - position)); trunk/run/data/shaders/shadowmap.glsl
r539 r540 1 #if def SHADOWMAPPING1 #if defined(SHADOWMAPPING) 2 2 3 3 float shadowMapSingle(in sampler2D sampler, in vec2 shadowMapCoord, in float lightDistance) trunk/run/data/shaders/terrain-pixel.glsl
r539 r540 5 5 uniform sampler2D lightMap; 6 6 7 #if def SHADOWMAPPING7 #if defined(SHADOWMAPPING) 8 8 # include "shadowmap.glsl" 9 9 … … 31 31 gl_FragColor = (c1 + c2 + c3) * (l * 2); 32 32 33 #if def SHADOWMAPPING33 #if defined(SHADOWMAPPING) 34 34 gl_FragColor *= shadowMap(shadowTexture, lightSpacePos); 35 35 #endif trunk/run/data/shaders/terrain-vertex.glsl
r535 r540 1 #if def SHADOWMAPPING1 #if defined(SHADOWMAPPING) 2 2 uniform mat4 lightTransform; 3 3 … … 11 11 gl_TexCoord[1] = gl_MultiTexCoord1; 12 12 13 #if def SHADOWMAPPING13 #if defined(SHADOWMAPPING) 14 14 lightSpacePos = lightTransform * gl_Vertex; 15 15 #endif trunk/run/defend.cfg
r539 r540 26 26 // shadow mapping 27 27 [shadowmapping] 28 enable = 128 enable = 0 29 29 30 30 size = 2048 … … 33 33 // normal lighting (ignored, if shadow mapping is enabled) 34 34 lighting = 1 35 36 // light objects by the terrain lightmap 37 objects_lightmap = 1 trunk/src/defend/Config.d
r539 r540 53 53 "int graphics.shadowmapping.size;" 54 54 "int graphics.shadowmapping.samples;" 55 "int graphics.lighting;") 55 "int graphics.lighting;" 56 "int graphics.objects_lightmap;") 56 57 57 58 defendConfig; trunk/src/defend/Main.d
r539 r540 248 248 Shader.define("SHADOWMAPPING"); 249 249 Shader.define("SHADOWMAPPING_SAMPLES", 250 to!(char[])(defendConfig("graphics")("shadowmapping").integer("samples"))); 250 to!(char[])(defendConfig.graphics.shadowmapping.samples)); 251 } 252 253 if(defendConfig.graphics.objects_lightmap) 254 { 255 Shader.define("OBJECTS_LIGHTMAP"); 256 } 257 258 if(defendConfig.graphics.lighting) 259 { 260 Shader.define("NORMAL_LIGHTING"); 251 261 } 252 262 trunk/src/defend/game/Game.d
r539 r540 202 202 203 203 // tmp 204 if(defendConfig.graphics.lighting) 204 205 { 205 206 renderer.identity(); … … 218 219 sceneGraph.render(); 219 220 }); 221 220 222 renderer.setMatrix(mainCamera.modelview, MatrixType.Modelview); 221 223 renderer.setMatrix(mainCamera.projection, MatrixType.Projection); trunk/src/defend/objects/SceneNode.d
r539 r540 116 116 renderer.setShader(shader); 117 117 shader.setUniform("color", parent.color); 118 shader.setUniform("mapPos", absolutePosition);119 shader.setUniform("mapSize", vec3(terrain.dimension.x, terrain.dimension.y, 0));120 118 shader.setUniform("diffuseTexture", 0); 121 shader.setUniform("lightTexture", 1);122 119 123 120 if(defendConfig.graphics.shadowmapping.enable) … … 132 129 } 133 130 131 if(defendConfig.graphics.objects_lightmap) 132 { 133 renderer.setTexture(1, terrain.lightmapTexture); 134 135 shader.setUniform("mapSize", vec3(terrain.dimension.x, terrain.dimension.y, 0)); 136 shader.setUniform("mapPos", absolutePosition); 137 shader.setUniform("lightTexture", 1); 138 } 139 134 140 renderer.setTexture(0, texture); 135 renderer.setTexture(1, terrain.lightmapTexture);136 141 } 137 142 else trunk/src/gen/util/Config.d
r539 r540 147 147 } 148 148 149 static char[] genAssign(char[] type, char[] id )149 static char[] genAssign(char[] type, char[] id, char[][] parts) 150 150 { 151 151 char[] result = "\t" ~ id ~ " = this"; 152 152 153 153 { 154 char[][] parts = splitParts(id);155 156 154 for(uint i = 0; i < parts.length; i++) 157 155 { … … 179 177 } 180 178 181 static char[] genStructs(char[][] types, char[][] ids, char[] level = "", uint depth = 0)179 static char[] genStructs(char[][] types, char[][] ids, char[][][] idParts, char[] level = "", uint depth = 0) 182 180 { 183 181 char[] result = ""; … … 186 184 foreach(i, id; ids) 187 185 { 188 char[][] parts = splitParts(id);186 char[][] parts = idParts[i]; 189 187 190 188 if(id.length > level.length && id[0 .. level.length] == level) … … 213 211 214 212 result ~= "struct _" ~ parts[depth] ~ "\n{\n"; 215 result ~= genStructs(types, ids, newLevel, depth + 1);213 result ~= genStructs(types, ids, idParts, newLevel, depth + 1); 216 214 result ~= "}\n_" ~ parts[depth] ~ " " ~ parts[depth] ~ ";\n"; 217 215 } … … 232 230 extractNames(types, ids); 233 231 234 result ~= genStructs(types, ids); 232 char[][][] idParts = []; 233 234 foreach(id; ids) 235 idParts ~= splitParts(id); 236 237 result ~= genStructs(types, ids, idParts); 235 238 236 239 result ~= "this(char[] c)\n{\n\tsuper(c);\n"; 237 240 238 241 for(uint i = 0; i < types.length; i++) 239 result ~= genAssign(types[i], ids[i] );242 result ~= genAssign(types[i], ids[i], idParts[i]); 240 243 241 244 result ~= "}";
