Changeset 2833 for GTP


Ignore:
Timestamp:
07/11/08 01:12:05 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp

    r2829 r2833  
    174174        float z_far = mFar; 
    175175 
    176         const float h_near = 2.0f * tan(mFovy / 2) * z_near; 
    177         const float w_near = h_near * GetAspect(); 
    178         const float h_far = 2.0f * tan(mFovy / 2) * z_far; 
    179         const float w_far = h_far * GetAspect(); 
     176        const float w_near = 2.0f * tan(mFovy / 2) * z_near; 
     177        const float h_near = w_near / GetAspect(); 
     178        const float w_far = 2.0f * tan(mFovy / 2) * z_far; 
     179        const float h_far = w_far / GetAspect(); 
    180180 
    181181        const Vector3 view = GetDirection(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2825 r2833  
    179179                texcoords = NULL; 
    180180        } 
    181  
    182         //return new Geometry(vertices, normals, texcoords, vertexCount, true); 
    183         return new Geometry(vertices, normals, texcoords, vertexCount, false); 
     181         
     182 
     183        return new Geometry(vertices, normals, texcoords, vertexCount, true); 
    184184} 
    185185 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2832 r2833  
    242242static CGparameter sPositionsTexParam; 
    243243static CGparameter sNormalsTexParam; 
    244 //static CGparameter sNoiseTexParam; 
    245244 
    246245static CGparameter sColorsTexParamSsao; 
     
    250249 
    251250static CGparameter sModelViewProjMatrixParam; 
    252 //static CGparameter sModelMatrixParam; 
    253251static CGparameter sMaxDepthParam; 
    254252static CGparameter sMaxDepthParamTex; 
    255253 
    256 //static CGparameter sSamplesParam;  
    257254static CGparameter sSamplesParamSsao;  
    258 static CGparameter sNoiseMultiplierParam;;  
     255//static CGparameter sNoiseMultiplierParam;;  
    259256 
    260257 
     
    538535                sNormalsTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "normals");   
    539536                sNoiseTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "noiseTexture"); 
    540                 sNoiseMultiplierParam = cgGetNamedParameter(sCgSsaoProgram, "noiseMultiplier"); 
     537                //sNoiseMultiplierParam = cgGetNamedParameter(sCgSsaoProgram, "noiseMultiplier"); 
    541538                 
    542539                cgGLDisableTextureParameter(sNoiseTexParamSsao); 
     
    923920        glLoadIdentity(); 
    924921 
    925         gluPerspective(fov, 1.0f / winAspectRatio, nearDist, myfar); 
     922        gluPerspective(fov, winAspectRatio, nearDist, myfar); 
    926923 
    927924        glMatrixMode(GL_MODELVIEW); 
     
    13971394        winHeight = h; 
    13981395 
    1399         if (w) winAspectRatio = (float) h / (float) w; 
     1396        if (w) winAspectRatio = (float) w / (float) h; 
    14001397 
    14011398        glMatrixMode(GL_PROJECTION); 
    14021399        glLoadIdentity(); 
    14031400 
    1404         gluPerspective(fov, 1.0f / winAspectRatio, nearDist, myfar); 
     1401        gluPerspective(fov, winAspectRatio, nearDist, myfar); 
    14051402 
    14061403        glMatrixMode(GL_MODELVIEW); 
     
    19211918                cgGLSetTextureParameter(sNoiseTexParamSsao, noiseTex); 
    19221919 
    1923                 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 7.0f)); 
     1920                //cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 7.0f)); 
    19241921        } 
    19251922        else 
     
    20512048{ 
    20522049        // generates poisson distribution on disc 
    2053         float factor = 1.0f; 
    2054         float minDist = factor / (sqrt((float)NUM_SAMPLES) * 2.0f); 
     2050        //float factor = 5.0f; 
     2051        float minDist = 2.0f;//factor / sqrt((float)NUM_SAMPLES); 
    20552052 
    20562053        cout << "minDist= " << minDist << endl; 
    20572054 
    2058         for (int i = 0; i < NUM_SAMPLES; i += 2) 
    2059         { 
    2060                 int tries = 0; 
     2055        for (int i = 0; i < NUM_SAMPLES * 2; i += 2) 
     2056        { 
     2057                int tries = 0, totalTries = 0; 
    20612058 
    20622059                // repeat until valid sample was found 
    20632060                while (1) 
    20642061                { 
    2065  
    20662062                        ++ tries; 
     2063                        ++ totalTries; 
    20672064 
    20682065                        const float rx = RandomValue(-1, 1); 
     
    20932090                        } 
    20942091 
    2095                         if (tries > 1000) 
     2092                        if (tries > 2000) 
    20962093                        { 
    20972094                                minDist *= 0.9f; 
     
    20992096                        } 
    21002097                } 
    2101                 cout << "sample: " << samples[i] << " " << samples[i + 1] << " r: " << sqrt(samples[i] * samples[i]  + samples[i + 1] * samples[i + 1]) << " tries: " << tries << endl; 
     2098                cout << "sample: " << samples[i] << " " << i /2 << " " << samples[i + 1] << " r: " << sqrt(samples[i] * samples[i]  + samples[i + 1] * samples[i + 1]) << " tries: " << totalTries << endl; 
    21022099        } 
    21032100 
     
    21122109{ 
    21132110        float myfov = fov * M_PI / 180.0f; 
    2114         const float h_far = 2.0f * tan(myfov / 2.0f); 
    2115         const float w_far = h_far * texWidth / texHeight; 
     2111 
     2112        const float w_far = 2.0f * tan(myfov / 2.0f); 
     2113        const float aspect = texWidth / texHeight; 
     2114 
     2115        const float h_far = w_far / aspect; 
    21162116 
    21172117        float t1 = h_far * 0.5f; 
    21182118        float t2 = w_far * 0.5f; 
    21192119 
    2120         bl = Normalize(Vector3(-t1, -t2, 1.0f)); 
    2121         br = Normalize(Vector3( t1, -t2, 1.0f)); 
    2122         tl = Normalize(Vector3(-t1,  t2, 1.0f)); 
    2123         tr = Normalize(Vector3( t1,  t2, 1.0f)); 
     2120        bl = Normalize(-Vector3(-t1, -t2, 1.0f)); 
     2121        br = Normalize(-Vector3( t1, -t2, 1.0f)); 
     2122        tl = Normalize(-Vector3(-t1,  t2, 1.0f)); 
     2123        tr = Normalize(-Vector3( t1,  t2, 1.0f)); 
    21242124 
    21252125        // normalize to 0 .. 1 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2832 r2833  
    66//#define SAMPLE_INTENSITY 0.5f 
    77//#define SAMPLE_INTENSITY 1.1f 
    8 #define SAMPLE_INTENSITY 0.7f 
     8#define SAMPLE_INTENSITY 0.25f 
    99#define AREA_SIZE 5e-1f 
    1010 
     
    1414  float4 pos: WPOS; // normalized screen position 
    1515  float4 texCoord: TEXCOORD0;  
     16  float3 view: COLOR0; 
    1617}; 
    1718 
     
    5152           uniform float2 samples[NUM_SAMPLES], 
    5253           uniform float3 currentNormal, 
    53            uniform float noiseMultiplier) 
     54           uniform float3 currentViewDir) 
    5455{ 
    5556  // the current world position 
     
    7273     
    7374    //sample noisetex; r stores costheta, g stores sintheta 
    74     float2 noise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
     75    float2 noise = tex2D(noiseTexture, IN.texCoord.xy * 7.1f).xy * 2.0f - 1.0f; 
    7576         
    7677    // rotation 
     
    9899    //const float maxdist = 5e-1f; 
    99100    const float distanceScale = 1e-6f; 
    100     //float distance_intensity = maxdist - length_to_sample; 
    101     float distance_intensity = (SAMPLE_INTENSITY * distanceScale) / (distanceScale + length_to_sample * length_to_sample); 
    102     //distance_intensity = max(distance_intensity, 0.0f); 
    103     // quadratic influence 
    104     //distance_intensity *= distance_intensity; 
    105      
    106     total_ao += cos_angle * distance_intensity; 
     101 
     102    float distance_intensity =  
     103      (SAMPLE_INTENSITY * distanceScale) / (distanceScale + length_to_sample * length_to_sample); 
     104 
     105    // if normal perpenticular to view dir, only half of the samples count 
     106    float view_correction = (2.0f - dot(currentViewDir, currentNormal)); 
     107 
     108    total_ao += cos_angle * distance_intensity * view_correction; 
    107109  } 
    108110         
     
    133135  float diffuseLight2 = max(dot(normal, light2), 0.0f); 
    134136 
    135   float diffuse = diffuseLight + diffuseLight2; 
     137  //float diffuse = diffuseLight + diffuseLight2; 
     138  float diffuse = diffuseLight; 
    136139 
    137140  return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 
     
    140143 
    141144pixel main_ssao(fragment IN,  
    142                uniform sampler2D colors, 
    143                uniform sampler2D positions, 
    144                uniform sampler2D normals, 
    145                uniform sampler2D noiseTexture, 
    146                uniform float2 samples[NUM_SAMPLES], 
    147                uniform float noiseMultiplier) 
     145                uniform sampler2D colors, 
     146                uniform sampler2D positions, 
     147                uniform sampler2D normals, 
     148                uniform sampler2D noiseTexture, 
     149                uniform float2 samples[NUM_SAMPLES]) 
    148150{ 
    149151  pixel OUT; 
     
    154156  // expand normal 
    155157  normal = normalize(normal * 2.0f - 1.0f); 
     158  float3 viewDir = normalize(IN.view * 2.0f - float(1.0f)); 
    156159 
    157160  float4 col = shade(IN, colors, positions, normal, amb); 
    158   float ao = ssao(IN, positions, noiseTexture, samples, normal, noiseMultiplier); 
     161  float ao = ssao(IN, positions, noiseTexture, samples, normal, viewDir); 
    159162   
    160163   //OUT.color = ao; 
     
    175178  float amb = normal.w; 
    176179 
     180  //OUT.color.xyz = IN.view; 
    177181  // expand normal 
    178   normal = normalize(normal * 2.0f - 1.0f); 
     182  normal = normalize(normal * 2.0f - float4(1.0f)); 
    179183   
    180184  float4 col = shade(IN, colors, positions, normal.xyz, amb); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2822 r2833  
    9191  pix.col = diffuse; 
    9292  pix.pos = IN.worldPos * maxDepth; 
    93   pix.norm.xyz = IN.normal * 0.5f + 0.5f; 
     93  pix.norm.xyz = IN.normal * 0.5f + float4(0.5f); 
    9494  // hack: squeeze some information about ambient into the texture 
    9595  pix.norm.w = ambient.x; 
Note: See TracChangeset for help on using the changeset viewer.