- Timestamp:
- 11/09/08 23:06:26 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3111 r3112 340 340 "samples", "bl", "br", "tl", "tr", 341 341 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr", 342 "oldtl", "oldtr", "attribsTex", "inverseModelTrafo "};342 "oldtl", "oldtr", "attribsTex", "inverseModelTrafos"}; 343 343 sCgSsaoProgram->AddParameters(ssaoParams, 0, 19); 344 344 … … 565 565 sCgSsaoProgram->SetTexture(i ++, attribsTex); 566 566 567 sCgSsaoProgram->SetMatrix(i ++, invTrafo); 567 float trafos[32]; 568 for (int i = 0; i < 16; ++ i) 569 trafos[i] = ((const float *)invTrafo.x)[i]; 570 571 static Matrix4x4 identity = IdentityMatrix(); 572 573 for (int i = 0; i < 16; ++ i) 574 trafos[i+16] = ((const float *)identity.x)[i]; 575 576 sCgSsaoProgram->SetMatrixArray(i ++, trafos, 2); 568 577 //sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix()); 569 578 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp
r3057 r3112 45 45 if(lastError) 46 46 { 47 printf("%s\n\n", cgGetErrorString(lastError)); 47 Debug << "\n" << cgGetErrorString(lastError) << endl; 48 Debug << "\n" << cgGetLastListing(sCgContext) << endl; 49 /*printf("%s\n\n", cgGetErrorString(lastError)); 48 50 printf("%s\n", cgGetLastListing(sCgContext)); 49 51 */ 50 52 printf("Cg error, exiting...\n"); 53 51 54 52 55 exit(0); … … 63 66 // get the optimal fragment profile 64 67 sCgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); 68 //sCgFragmentProfile = CG_PROFILE_GPU_FP; 69 //CG_PROFILE_FP40;; 65 70 cgGLSetOptimalOptions(sCgFragmentProfile); 66 71 // get the optimal vertex profile -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp
r3104 r3112 21 21 22 22 23 23 24 /*********************************************************/ 24 25 /* GPUProgramParameters implementation */ … … 52 53 mMatrices.clear(); 53 54 mArrays.clear(); 55 mMatrixArrays.clear(); 54 56 55 57 mTimerParam = -1; … … 118 120 119 121 122 void GPUProgramParameters::SetMatrixArray(int idx, float *mats, int numElements) 123 { 124 if (mMatrixArrays.size() < idx + 1) 125 mMatrixArrays.resize(idx + 1); 126 127 mMatrixArrays[idx] = MatrixArrayParam(mats, numElements); 128 } 129 130 120 131 void GPUProgramParameters::SetTexture(int idx, unsigned int tex) 121 132 { … … 199 210 { 200 211 SetMatrix(mProgram->GetParamIdxByName(name), mat); 212 } 213 214 215 void GPUProgramParameters::SetMatrixArray(const string &name, float *mats, int numElements) 216 { 217 SetMatrixArray(mProgram->GetParamIdxByName(name), mats, numElements); 201 218 } 202 219 … … 272 289 } 273 290 291 for (int i = 0; i < (int)mMatrixArrays.size(); ++ i) 292 { 293 const MatrixArrayParam &p = mMatrixArrays[i]; 294 295 if (p.mValid) 296 mProgram->SetMatrixArray(i, p.mValues, p.mNumEntries); 297 } 298 274 299 if (mTimerParam >= 0) 275 300 mProgram->SetValue1f(mTimerParam, sCurrentTimer); … … 295 320 // transform to view space 296 321 cam->GetViewOrientationMatrix(vo); 297 //sCurrentLightDir = /*vo **/ -light->GetDirection();298 322 sCurrentLightDir = vo * -light->GetDirection(); 299 323 } … … 441 465 442 466 467 void ShaderProgram::SetMatrixArray(int idx, float *mats, int numElements) 468 { 469 cgGLSetMatrixParameterArrayfc(GetParameter(idx), 0, numElements, (const float *)mats); 470 } 471 472 473 443 474 void ShaderProgram::SetTexture(int idx, unsigned int tex) 444 475 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h
r3104 r3112 56 56 void SetArray2f(int idx, float *vals, int numElements); 57 57 void SetArray3f(int idx, float *vals, int numElements); 58 59 58 /** Sets the texture parameter. 60 59 */ … … 63 62 */ 64 63 void SetMatrix(int idx, Matrix4x4 *mat); 64 /** Sets an array of matrices 65 */ 66 void SetMatrixArray(int idx, float *vals, int numElements); 65 67 66 68 //////////// … … 96 98 void SetArray2f(const std::string &name, float *vals, int numElements); 97 99 void SetArray3f(const std::string &name, float *vals, int numElements); 100 98 101 /** Sets the texture parameter. 99 102 */ … … 102 105 */ 103 106 void SetMatrix(const std::string &name, Matrix4x4 *mat); 107 /** Sets an array of matrices 108 */ 109 void SetMatrixArray(const std::string &name, float *vals, int numElements); 110 104 111 /** Feeds the shader program with the parameter values. 105 112 */ … … 120 127 { 121 128 for (int i = 0; i < mNumComponents; ++ i) 122 {123 129 mValues[i] = val[i]; 124 }125 130 } 126 131 … … 164 169 }; 165 170 171 172 struct MatrixArrayParam 173 { 174 MatrixArrayParam(): mValues(NULL), mNumEntries(0), mValid(false) {} 175 MatrixArrayParam(float *mats, int numEntries): 176 mValues(mats), mNumEntries(numEntries), mValid(true) 177 {} 178 179 bool mValid; 180 float *mValues; 181 182 int mNumEntries; 183 }; 184 185 166 186 /// the program this parameter set is connected to 167 187 ShaderProgram *mProgram; … … 176 196 std::vector<MatrixParam> mMatrices; 177 197 std::vector<ArrayParam> mArrays; 198 std::vector<MatrixArrayParam> mMatrixArrays; 178 199 }; 179 200 … … 215 236 void SetArray3f(int idx, float *vals, int numElements); 216 237 void SetMatrix(int idx, const Matrix4x4 &mat); 238 void SetMatrixArray(int idx, float *mats, int numElements); 217 239 218 240 void SetTexture(int idx, unsigned int tex); … … 233 255 */ 234 256 void SetMatrix(const std::string &name, const Matrix4x4 &mat); 257 /** Sets array of matrices 258 */ 259 void SetMatrixArray(const std::string &name, float *mats, int numElements); 235 260 /** Sets the texture parameter. 236 261 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3111 r3112 529 529 dynamicObjects[i]->mId = 0; 530 530 531 buddha->mId = 250; 531 //buddha->mId = 250; 532 buddha->mId = 1; 532 533 533 534 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3111 r3112 6 6 7 7 #define USE_EYESPACE_DEPTH 1 8 //#extension GL_EXT_gpu_shader4 : enable 9 8 10 9 11 … … 130 132 uniform float3 tl, 131 133 uniform float3 tr, 134 float3 projPos, 132 135 float invW, 133 float3 projPos, 134 float4x4 inverseModelTrafo, 136 float4x4 inverseModelTrafos[2], 135 137 float id, 136 138 uniform sampler2D noiseTex, … … 148 150 //////////// 149 151 //-- dynamic objects 150 152 /*float4x4 dummy; 153 uniform mat4 ident = float4x4(1); 154 x = dot(vec, ident[n]); 155 */ 156 float4x4 dummyTrafo = inverseModelTrafos[(int)id]; 151 157 //float4x4 trafo = (id < 10.0f) ? oldModelViewProj : mul(oldModelViewProj, inverseModelTrafo); 152 float4x4 trafo = mul(oldModelViewProj, inverseModelTrafo);158 float4x4 trafo = mul(oldModelViewProj, dummyTrafo); 153 159 154 160 // compute translational portion … … 351 357 uniform float3 oldtr, 352 358 uniform sampler2D attribsTex, 353 uniform float4x4 inverseModelTrafo 359 uniform float4x4 inverseModelTrafos[2] 354 360 ) 355 361 { … … 369 375 370 376 float4 projPos = mul(modelViewProj, eyeSpacePos); 371 const float w = 1.0f / projPos.w;372 projPos *= w;373 float scaleFactor = SAMPLE_RADIUS * w;377 const float invw = 1.0f / projPos.w; 378 projPos *= invw; 379 float scaleFactor = SAMPLE_RADIUS * invw; 374 380 375 381 float2 ao = float2(1.0f, 0); … … 387 393 OUT.illum_col = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, ao, IN.texCoord, oldEyePos, 388 394 oldTex, oldModelViewProj, temporalCoherence, 389 colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id.z, 390 noiseTex, samples, scaleFactor, oldbl, oldbr, oldtl, oldtr); 395 colors, 396 bl, br, tl, tr, 397 projPos.xyz, 398 invw, 399 inverseModelTrafos, 400 id.z, 401 noiseTex, 402 samples, 403 scaleFactor, 404 oldbl, oldbr, oldtl, oldtr); 391 405 392 406 //OUT.illum_col.xyz = id;
Note: See TracChangeset
for help on using the changeset viewer.