Changeset 533

Show
Ignore:
Timestamp:
05/02/08 19:34:56 (8 months ago)
Author:
LeoD
Message:

object shadowing works, thanks h3 :D

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/run/data/shaders/model.pixel.glsl

    r530 r533  
    1414    vec4 light = texture2D(lightTexture, vec2(gl_TexCoord[1])); 
    1515     
    16     gl_FragColor = vec4(tex.rgb * tex.a + color * (1 - tex.a), 1.0) * gl_Color * (light * 2); //* shadowMap(shadow, lightSpacePos); 
    17     //gl_FragColor = vec4(tex.rgb * tex.a + color * (1 - tex.a), 1.0) * (light * 2) * shadowMap(shadow, lightSpacePos); 
     16    //gl_FragColor = vec4(tex.rgb * tex.a + color * (1 - tex.a), 1.0) * gl_Color * (light * 2); //* shadowMap(shadow, lightSpacePos); 
     17    gl_FragColor = vec4(tex.rgb * tex.a + color * (1 - tex.a), 1.0) * (light * 2) * shadowMap(shadow, lightSpacePos); 
    1818    //gl_FragColor = vec4(shadowMap(shadow, lightSpacePos)); 
    1919} 
  • trunk/run/data/shaders/model.vertex.glsl

    r530 r533  
    1919     
    2020    // Lighting 
    21     vec3 position = vec3(gl_ModelViewMatrix * gl_Vertex); 
     21    /*vec3 position = vec3(gl_ModelViewMatrix * gl_Vertex); 
    2222    //vec3 light = vec3(normalize(vec3(gl_ModelViewMatrix * LIGHT_POSITION) - position)); 
    2323    vec3 light = vec3(normalize(vec3(gl_LightSource[0].position) - position)); 
     
    2525    vec3 ambient = vec3(gl_FrontMaterial.ambient) * vec3(LIGHT_AMBIENT); 
    2626    vec3 diffuse = (max(dot(normal, light), 0.0) * LIGHT_DIFFUSE).rgb; 
    27     gl_FrontColor = vec4(diffuse + ambient, 1.0); 
     27    gl_FrontColor = vec4(diffuse + ambient, 1.0);*/ 
    2828     
    2929     
  • trunk/run/data/shaders/shadowmap.glsl

    r530 r533  
    44float shadowMap(in sampler2D sampler, vec4 lightSpacePos) 
    55{ 
    6     //return 1.0f; 
     6    vec2 shadowMapCoord = 0.5f * lightSpacePos.xy / lightSpacePos.w + vec2(0.5f, 0.5f); 
     7    float shadowMapDistance = texture2D(sampler, shadowMapCoord).r;     
     8    float lightDistance = lightSpacePos.z / lightSpacePos.w; 
    79 
    8     vec2 shadowMapCoord = 0.5f * lightSpacePos.xy / lightSpacePos.w + vec2(0.5f, 0.5f); 
    9     float shadowMapDistance = texture2D(sampler, shadowMapCoord).r;  
    10     float lightDistance = lightSpacePos.z / lightSpacePos.w; 
     10    float bias = -0.001f;    // avoid shadow aliasing by offseting the shadow a bit 
    1111 
    12     //if(shadowMapCoord.x >= 0 && shadowMapCoord.x <= 1 && shadowMapCoord.y >= 0 && shadowMapCoord.y <= 1) 
    13    //  return 0.0f; 
     12    // perspective division yields coordinates in [-1 .. 1], whilst shadow map values are [0 .. 1] 
     13    lightDistance = .5f + bias + lightDistance * .5f; 
    1414 
    15     //return lightDistance; 
    16     //return shadowMapDistance; 
    17      
    18     if(shadowMapCoord.x >= 0 && shadowMapCoord.x <= 1 && shadowMapCoord.y >= 0 && shadowMapCoord.y <= 1 && 
    19        lightDistance + 0.72f >= shadowMapDistance && shadowMapDistance != 1.0f) // point is in shadow 
    20         return 0.35f; 
    21      
    22     //if(shadowMapCoord.x >= 0 && shadowMapCoord.x <= 1 && shadowMapCoord.y >= 0 && shadowMapCoord.y <= 1) 
    23     //  return shadowMapDistance - lightDistance; 
    24      
    25     return 1.0f; 
     15    if(shadowMapCoord.x >= 0 && shadowMapCoord.x <= 1 && shadowMapCoord.y >= 0 && shadowMapCoord.y <= 1 && 
     16       lightDistance >= shadowMapDistance && shadowMapDistance != 1.0f) // point is in shadow 
     17        return 0.35f; 
     18     
     19    return 1.0f; 
    2620} 
  • trunk/src/defend/com/Gateway.d

    r435 r533  
    7474     
    7575    // Create an synchronized object 
    76     Signal!(player_id_t /* owner */, object_type_t /* type */
    77             object_pos_t /* x */, object_pos_t /* y */) CreateObject; 
     76    Signal!(player_id_t, object_type_t
     77            object_pos_t, object_pos_t) CreateObject; 
    7878 
    7979    // Chat message 
    80     Signal!(player_id_t /* from */, char[] /* text */, 
    81             bool /* team */) ChatMessage; 
     80    Signal!(player_id_t, char[], bool) ChatMessage; 
    8281 
    8382    // All players have connected and the game will start now 
     
    9190 
    9291    // A player has disconnected 
    93     Signal!(player_id_t /* id */) PlayerDisconnect; 
     92    Signal!(player_id_t) PlayerDisconnect; 
    9493 
    9594    // The gateway has found out which ID it has 
    96     Signal!(player_id_t /* id */) GatewayID; 
     95    Signal!(player_id_t) GatewayID; 
    9796 
    9897    // Emitted when the gateway shuts down 
    99     Signal!(bool /* fatal */) GatewayShutdown; 
     98    Signal!(bool) GatewayShutdown; 
    10099 
    101100    // Start the next phase 
    102     Signal!(Phase /* phase */) StartPhase; 
     101    Signal!(Phase) StartPhase; 
    103102} 
  • trunk/src/gen/rend/opengl/Texture.d

    r530 r533  
    7474                t = GL_DEPTH_COMPONENT24; 
    7575                f = GL_DEPTH_COMPONENT; 
     76                 
     77                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
     78                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);   
    7679            } 
    7780 
  • trunk/src/windefend.cbp

    r520 r533  
    7777        </Build> 
    7878        <Compiler> 
    79             <Add option="-defaultlib=tango-base-dmd.lib" /> 
    80             <Add option="-debuglib=tango-base-dmd.lib" /> 
    8179            <Add option="-version=UseSDL" /> 
    8280            <Add option="-version=DynDio" /> 
    83             <Add directory="libs\" /> 
    8481            <Add directory="." /> 
    8582        </Compiler> 
     
    183180        <Unit filename="gen\net\tcp\Message.d" /> 
    184181        <Unit filename="gen\net\tcp\Socket.d" /> 
     182        <Unit filename="gen\rend\Framebuffer.d" /> 
    185183        <Unit filename="gen\rend\IndexBuffer.d" /> 
    186184        <Unit filename="gen\rend\PrimitiveType.d" /> 
     
    191189        <Unit filename="gen\rend\VertexFormat.d" /> 
    192190        <Unit filename="gen\rend\Window.d" /> 
     191        <Unit filename="gen\rend\opengl\FBO.d" /> 
    193192        <Unit filename="gen\rend\opengl\IndexBuffer.d" /> 
    194193        <Unit filename="gen\rend\opengl\Renderer.d" />