- Timestamp:
- 07/11/08 01:12:05 (16 years ago)
- 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 174 174 float z_far = mFar; 175 175 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(); 180 180 181 181 const Vector3 view = GetDirection(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2825 r2833 179 179 texcoords = NULL; 180 180 } 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); 184 184 } 185 185 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2832 r2833 242 242 static CGparameter sPositionsTexParam; 243 243 static CGparameter sNormalsTexParam; 244 //static CGparameter sNoiseTexParam;245 244 246 245 static CGparameter sColorsTexParamSsao; … … 250 249 251 250 static CGparameter sModelViewProjMatrixParam; 252 //static CGparameter sModelMatrixParam;253 251 static CGparameter sMaxDepthParam; 254 252 static CGparameter sMaxDepthParamTex; 255 253 256 //static CGparameter sSamplesParam;257 254 static CGparameter sSamplesParamSsao; 258 static CGparameter sNoiseMultiplierParam;;255 //static CGparameter sNoiseMultiplierParam;; 259 256 260 257 … … 538 535 sNormalsTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "normals"); 539 536 sNoiseTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "noiseTexture"); 540 sNoiseMultiplierParam = cgGetNamedParameter(sCgSsaoProgram, "noiseMultiplier");537 //sNoiseMultiplierParam = cgGetNamedParameter(sCgSsaoProgram, "noiseMultiplier"); 541 538 542 539 cgGLDisableTextureParameter(sNoiseTexParamSsao); … … 923 920 glLoadIdentity(); 924 921 925 gluPerspective(fov, 1.0f /winAspectRatio, nearDist, myfar);922 gluPerspective(fov, winAspectRatio, nearDist, myfar); 926 923 927 924 glMatrixMode(GL_MODELVIEW); … … 1397 1394 winHeight = h; 1398 1395 1399 if (w) winAspectRatio = (float) h / (float) w;1396 if (w) winAspectRatio = (float) w / (float) h; 1400 1397 1401 1398 glMatrixMode(GL_PROJECTION); 1402 1399 glLoadIdentity(); 1403 1400 1404 gluPerspective(fov, 1.0f /winAspectRatio, nearDist, myfar);1401 gluPerspective(fov, winAspectRatio, nearDist, myfar); 1405 1402 1406 1403 glMatrixMode(GL_MODELVIEW); … … 1921 1918 cgGLSetTextureParameter(sNoiseTexParamSsao, noiseTex); 1922 1919 1923 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 7.0f));1920 //cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 7.0f)); 1924 1921 } 1925 1922 else … … 2051 2048 { 2052 2049 // 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); 2055 2052 2056 2053 cout << "minDist= " << minDist << endl; 2057 2054 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; 2061 2058 2062 2059 // repeat until valid sample was found 2063 2060 while (1) 2064 2061 { 2065 2066 2062 ++ tries; 2063 ++ totalTries; 2067 2064 2068 2065 const float rx = RandomValue(-1, 1); … … 2093 2090 } 2094 2091 2095 if (tries > 1000)2092 if (tries > 2000) 2096 2093 { 2097 2094 minDist *= 0.9f; … … 2099 2096 } 2100 2097 } 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; 2102 2099 } 2103 2100 … … 2112 2109 { 2113 2110 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; 2116 2116 2117 2117 float t1 = h_far * 0.5f; 2118 2118 float t2 = w_far * 0.5f; 2119 2119 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)); 2124 2124 2125 2125 // normalize to 0 .. 1 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2832 r2833 6 6 //#define SAMPLE_INTENSITY 0.5f 7 7 //#define SAMPLE_INTENSITY 1.1f 8 #define SAMPLE_INTENSITY 0. 7f8 #define SAMPLE_INTENSITY 0.25f 9 9 #define AREA_SIZE 5e-1f 10 10 … … 14 14 float4 pos: WPOS; // normalized screen position 15 15 float4 texCoord: TEXCOORD0; 16 float3 view: COLOR0; 16 17 }; 17 18 … … 51 52 uniform float2 samples[NUM_SAMPLES], 52 53 uniform float3 currentNormal, 53 uniform float noiseMultiplier)54 uniform float3 currentViewDir) 54 55 { 55 56 // the current world position … … 72 73 73 74 //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; 75 76 76 77 // rotation … … 98 99 //const float maxdist = 5e-1f; 99 100 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; 107 109 } 108 110 … … 133 135 float diffuseLight2 = max(dot(normal, light2), 0.0f); 134 136 135 float diffuse = diffuseLight + diffuseLight2; 137 //float diffuse = diffuseLight + diffuseLight2; 138 float diffuse = diffuseLight; 136 139 137 140 return (ambient + diffuse) * color * (1.0f - amb) + amb * color; … … 140 143 141 144 pixel 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]) 148 150 { 149 151 pixel OUT; … … 154 156 // expand normal 155 157 normal = normalize(normal * 2.0f - 1.0f); 158 float3 viewDir = normalize(IN.view * 2.0f - float(1.0f)); 156 159 157 160 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); 159 162 160 163 //OUT.color = ao; … … 175 178 float amb = normal.w; 176 179 180 //OUT.color.xyz = IN.view; 177 181 // expand normal 178 normal = normalize(normal * 2.0f - 1.0f);182 normal = normalize(normal * 2.0f - float4(1.0f)); 179 183 180 184 float4 col = shade(IN, colors, positions, normal.xyz, amb); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2822 r2833 91 91 pix.col = diffuse; 92 92 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); 94 94 // hack: squeeze some information about ambient into the texture 95 95 pix.norm.w = ambient.x;
Note: See TracChangeset
for help on using the changeset viewer.