Changeset 2945


Ignore:
Timestamp:
09/15/08 01:43:13 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r2901 r2945  
    1010winHeight=768 
    1111camPosition=483.398f 242.364f 186.078f 
    12 camDirection=0 1 0 
     12camDirection=1 0 0 
    1313useFullScreen=0 
    1414useLODs=1 
     15shadowSize=2048 
    1516#modelPath=data/city/model/ 
    1617 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Plane3.cpp

    r2944 r2945  
    121121        mD = -w / mag; 
    122122 
     123        /* 
    123124        // find point on plane 
    124         /*const Vector3 pt = mNormal * -mD; 
     125        const Vector3 pt = mNormal * -mD; 
    125126 
    126127        // transform point 
    127128        const Vector3 newPt = m * pt; 
     129 
    128130        // transform normal 
    129         const Vector3 newNormal = TransformNormal(m, newPt); 
     131        nNormal = Normalize(TransformNormal(m, newPt)); 
    130132 
    131         const float mag = Magnitude(newNormal); 
    132  
    133         return Plane3(newNormal / mag,  newPt / mag);*/ 
     133        mD = -DotProd(mNormal, newPt); 
     134        */ 
    134135} 
    135136 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp

    r2944 r2945  
    282282        //-- first find the free parameter values n, and P (the projection center), and the projection depth 
    283283 
    284         //const float n = ComputeN(bounds_ls); 
    285         const float n = ComputeNOpt(lightSpace, extremalPoints, body); 
    286  
    287         cout << "n: " << n << endl; 
     284        const float n = ComputeN(bounds_ls); 
     285        //const float n = ComputeNOpt(lightSpace, extremalPoints, body); cout << "n: " << n << endl; 
    288286 
    289287        if (n >= 1e6f) // light direction nearly parallel to view => switch to uniform 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2944 r2945  
    100100static int winHeight = 768; 
    101101 
    102 //const float shadowSize = 4096; 
    103 const float shadowSize = 2048; 
     102int shadowSize = 2048; 
    104103 
    105104static float winAspectRatio = 1.0f; 
     
    313312 
    314313                env.GetBoolParam(string("useLODs"), useLODs); 
     314                env.GetIntParam(string("shadowSize"), shadowSize); 
    315315 
    316316                //env.GetStringParam(string("modelPath"), model_path); 
     
    330330                cout << "camPosition: " << camPos << endl; 
    331331                cout << "temporal coherence: " << ssaoTempCohFactor << endl; 
     332                cout << "shadow size: " << shadowSize << endl; 
    332333 
    333334                //cout << "model path: " << model_path << endl; 
     
    747748        glEnable(GL_LIGHTING); 
    748749        glEnable(GL_LIGHT0); 
    749         glEnable(GL_LIGHT1); 
    750          
    751         GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; 
     750         
     751        /////////// 
     752        //-- first light: sunlight 
     753 
     754        //GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; 
     755        GLfloat ambient[] = {0.5, 0.5, 0.5, 1.0}; 
    752756        GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; 
    753757        GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; 
    754              
    755         GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
    756758 
    757759        glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); 
     
    759761        glLightfv(GL_LIGHT0, GL_SPECULAR, specular); 
    760762 
     763        GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 
     764        glLightfv(GL_LIGHT0, GL_POSITION, position); 
     765 
     766#if 0 
    761767 
    762768        //////////// 
    763769        //-- second light 
     770         
     771        // physically incorrect to have second directional light,  
     772        // but gives nicer shading for fixed function 
     773 
     774        glEnable(GL_LIGHT1); 
    764775 
    765776        GLfloat ambient1[] = {0.2, 0.2, 0.2, 1.0}; 
    766777        GLfloat diffuse1[] = {1.0, 1.0, 1.0, 1.0}; 
    767         //GLfloat diffuse1[] = {0.5, 0.5, 0.5, 1.0}; 
    768778        GLfloat specular1[] = {0.0, 0.0, 0.0, 1.0}; 
    769779 
     
    772782        glLightfv(GL_LIGHT1, GL_SPECULAR, specular1); 
    773783 
    774          
    775         ////////////////////////////// 
    776  
    777         GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 
    778         glLightfv(GL_LIGHT0, GL_POSITION, position); 
    779  
    780784        GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 
    781785        glLightfv(GL_LIGHT1, GL_POSITION, position1); 
     786 
     787        //GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
     788 
     789#endif 
     790 
     791        ////////////////////////////// 
     792 
     793        GLfloat lmodel_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 
    782794 
    783795        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
     
    10061018        glLightfv(GL_LIGHT0, GL_POSITION, position); 
    10071019 
     1020#if 0 
    10081021        GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 
    10091022        glLightfv(GL_LIGHT1, GL_POSITION, position1); 
    1010  
     1023#endif 
    10111024 
    10121025        if (renderLightView) 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2944 r2945  
    3535                         uniform float amb) 
    3636{ 
    37         float4 lightDir = float4(0.8f, -1.0f, 0.7f, 0.0f); 
    38         //float4 lightDir = float4(0.0f, 1.0f, 0.0f, 0.0f); 
     37        const float4 lightDir = float4(0.8f, -1.0f, 0.7f, 0.0f); 
     38        const float3 light = normalize(lightDir.xyz); 
     39        const float diffuseLight = saturate(dot(normal, light)); 
     40         
     41        /* 
    3942        float4 lightDir2 = float4(-0.5f, 0.5f, 0.4f, 0.0f); 
     43        float3 light2 = normalize(lightDir2.xyz); 
     44        float diffuseLight2 = saturate(dot(normal, light2)); 
     45*/ 
     46        float diffuse = diffuseLight;// + diffuseLight2; 
    4047 
    4148        // global ambient 
    4249        const float4 ambient = 0.25f; 
    43  
    44         // float3 L = normalize(lightPosition - position); 
    45         float3 light = normalize(lightDir.xyz); 
    46         float3 light2 = normalize(lightDir2.xyz); 
    47  
    48         float diffuseLight = saturate(dot(normal, light)); 
    49         float diffuseLight2 = saturate(dot(normal, light2)); 
    50  
    51         float diffuse = diffuseLight + diffuseLight2; 
     50        //const float4 ambient = 0.0f; 
    5251 
    5352        return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 
     
    7372        float amb = norm.w; 
    7473 
    75         // expand normal 
    76         float3 normal = normalize(norm.xyz);// * 2.0f - float4(1.0f)); 
     74        float3 normal = normalize(norm.xyz); 
    7775 
    7876        float4 col = shade(IN, color, position, normal, amb); 
     
    9593                                         ) 
    9694{ 
    97         float s; 
    98  
    9995        float total_d = 0.0; 
    100         //float total_d = tex2D(shadowMap, lightSpacePos).x; 
    10196 
    10297        for (int i = 0; i < NUM_SAMPLES; ++ i)  
     
    118113                float shadowDepth = tex2D(shadowMap, texcoord).x; 
    119114 
    120                 total_d += step(shadowDepth, depth); 
    121                 //total_d += length(offsetTransformed); 
     115                total_d += step(depth, shadowDepth); 
    122116        } 
    123117 
     
    199193         
    200194        /* 
    201  
     195        // hard shadows 
    202196        float shadowDepth = tex2D(shadowMap, lightSpacePos.xy).x; 
    203197 
     
    212206        return OUT; 
    213207} 
     208 
    214209#else 
     210 
    215211 
    216212pixel main_shadow(fragment IN,  
     
    231227        float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    232228        float4 position = tex2D(positions, IN.texCoord.xy); 
    233  
    234  
    235         // an ambient color term 
    236         float amb = norm.w; 
    237  
    238         float3 normal = normalize(norm.xyz); 
    239         float4 col = shade(IN, color, position, normal, amb); 
    240          
    241         position *= maxDepth; 
    242         position.w = 1.0f; 
    243          
    244         float4 lightSpacePos = mul(shadowMatrix, position); 
    245         lightSpacePos /= lightSpacePos.w; 
    246  
    247         OUT.color = col; 
    248  
    249         float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth, lightSpacePos.xy, lightSpacePos.z, samples, noiseTexture); 
    250  
    251         if (amb < 0.9f) // hack: prevent shadowing the sky       
    252         { 
    253                 // base lighting 
    254                 const float baseLighting = 0.3f; 
    255                 OUT.color *= baseLighting + (1.0f - baseLighting) * (1.0f - shadowTerm); 
    256         } 
    257          
     229         
     230        const float3 normal = normalize(norm.xyz); 
     231        const float3 lightDir = normalize(float3(0.8f, -1.0f, 0.7f)); 
     232 
     233        // hack: an emmisive color term 
     234        float emmisive = norm.w; 
     235 
     236        // diffuse intensity 
     237        const float angle = saturate(dot(normal, lightDir));  
     238        float diffuse = angle; 
     239 
     240        // calc diffuse illumination + shadow term 
     241        if ((emmisive < 0.95f) // hack: prevent shadowing the sky        
     242                && (angle > 1e-3f) 
     243                ) 
     244        { 
     245                position *= maxDepth; 
     246                position.w = 1.0f; 
     247 
     248                float4 lightSpacePos = mul(shadowMatrix, position); 
     249                lightSpacePos /= lightSpacePos.w; 
     250 
     251                float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth, lightSpacePos.xy, lightSpacePos.z, samples, noiseTexture); 
     252 
     253                diffuse *= shadowTerm; 
     254        } 
     255 
     256        // global ambient 
     257        const float4 ambient = 0.25f; 
     258         
     259        // base lighting 
     260        OUT.color = (ambient + diffuse) * color * (1.0f - emmisive) + emmisive * color; 
     261 
    258262        // also write out depth component 
    259263        OUT.color.w = color.w; 
Note: See TracChangeset for help on using the changeset viewer.