- Timestamp:
- 11/18/08 11:28:38 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3133 r3134 112 112 } 113 113 114 static void ComputeSampleOffsets(float *sampleOffsets, int w, int h) 115 { 116 /* 117 const float xoffs = 0.5f / w; 118 const float yoffs = 0.5f / h; 119 120 sampleOffsets[0] = xoffs; sampleOffsets[1] = yoffs; 121 sampleOffsets[2] = xoffs; sampleOffsets[3] = -yoffs; 122 sampleOffsets[4] = -xoffs; sampleOffsets[5] = -yoffs; 123 sampleOffsets[6] = -xoffs; sampleOffsets[7] = yoffs; 124 */ 125 //const float xoffs = .5f / w; 126 //const float yoffs = .5f / h; 127 128 const float xoffs = 1.0f / w; 129 const float yoffs = 1.0f / h; 130 131 int idx = 0; 132 133 for (int x = -1; x <= 1; ++ x) 134 { 135 for (int y = -1; y <= 1; ++ y) 114 115 static void ComputeSampleOffsets(float *sampleOffsets, 116 int imageW, int imageH, 117 float width, 118 int samples) 119 { 120 const float xoffs = width / (float)imageW; 121 const float yoffs = width / (float)imageH; 122 123 const int numSamples = (int)sqrt((float)samples); 124 const int startSamples = -numSamples / 2; 125 const int endSamples = numSamples + startSamples - 1; 126 //cout << startSamples << " " << endSamples << endl; 127 128 int idx = 0; 129 130 for (int x = startSamples; x <= endSamples; ++ x) 131 { 132 for (int y = startSamples; y <= endSamples; ++ y) 136 133 { 137 sampleOffsets[idx + 0] = x * xoffs; 138 sampleOffsets[idx + 1] = y * yoffs; 139 134 sampleOffsets[idx + 0] = (float)x * xoffs; 135 sampleOffsets[idx + 1] = (float)y * yoffs; 140 136 idx += 2; 141 }142 }143 }144 145 146 static void ComputeSampleOffsets2(float *sampleOffsets, int w, int h, float width, int samples)147 {148 const float xoffs = width / (float)w;149 const float yoffs = width / (float)h;150 151 const int numSamples = (int)sqrt((float)samples);152 153 for (int x = 0; x < numSamples; ++ x)154 {155 for (int y = 0; y < numSamples; ++ y)156 {157 int idx = (y * numSamples + x) * 2;158 sampleOffsets[idx + 0] = ((float)x - 0.5f * numSamples) * xoffs;159 sampleOffsets[idx + 1] = ((float)y - 0.5f * numSamples) * yoffs;160 137 } 161 138 } … … 434 411 //////////////// 435 412 436 string combineSsaoParams[] = {"colorsTex", "normalsTex", "ssaoTex", "filterOffs", "filterWeights" };437 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 5);413 string combineSsaoParams[] = {"colorsTex", "normalsTex", "ssaoTex", "filterOffs", "filterWeights", "bl", "br", "tl", "tr"}; 414 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 9); 438 415 439 416 ////////////// … … 464 441 /////////// 465 442 466 #if 0 443 const float filterWidth = 10.0f; 444 445 #if 1 467 446 PoissonDiscSampleGenerator2 poisson(NUM_SSAO_FILTERSAMPLES, 1.0f); 468 447 poisson.Generate((float *)ssaoFilterOffsets); 469 448 470 const float filterWidth = 10.0f;471 449 const float xoffs = (float)filterWidth / mWidth; 472 450 const float yoffs = (float)filterWidth / mHeight; … … 484 462 } 485 463 #else 486 //ComputeSampleOffsets(ssaoFilterOffsets, 1024, 768, sqrt(NUM_SSAO_FILTERSAMPLES), NUM_SSAO_FILTERSAMPLES);487 ComputeSampleOffsets 2(ssaoFilterOffsets, 1024, 768, 5, NUM_SSAO_FILTERSAMPLES);488 464 //ComputeSampleOffsets(ssaoFilterOffsets, mWidth, mHeight, sqrt(NUM_SSAO_FILTERSAMPLES), NUM_SSAO_FILTERSAMPLES); 465 ComputeSampleOffsets(ssaoFilterOffsets, mWidth, mHeight, filterWidth, NUM_SSAO_FILTERSAMPLES); 466 //cout<<"ssao filter size: " << NUM_SSAO_FILTERSAMPLES << endl; 489 467 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 490 468 ssaoFilterWeights[i] = 1.0f; … … 829 807 sCgCombineSsaoProgram->SetArray1f(i ++, (float *)ssaoFilterWeights, NUM_SSAO_FILTERSAMPLES); 830 808 809 Vector3 bl = mCornersView[0]; 810 Vector3 br = mCornersView[1]; 811 Vector3 tl = mCornersView[2]; 812 Vector3 tr = mCornersView[3]; 813 814 sCgCombineSsaoProgram->SetValue3f(i ++, bl.x, bl.y, bl.z); 815 sCgCombineSsaoProgram->SetValue3f(i ++, br.x, br.y, br.z); 816 sCgCombineSsaoProgram->SetValue3f(i ++, tl.x, tl.y, tl.z); 817 sCgCombineSsaoProgram->SetValue3f(i ++, tr.x, tr.y, tr.z); 818 819 831 820 DrawQuad(sCgCombineSsaoProgram); 832 821 … … 968 957 sCgDownSampleProgram->SetTexture(0, colorsTex); 969 958 959 const float filterWidth = 1.0f; 970 960 float downSampleOffsets[NUM_DOWNSAMPLES * 2]; 971 ComputeSampleOffsets(downSampleOffsets, fbo->GetWidth(), fbo->GetHeight());972 961 //ComputeSampleOffsets(downSampleOffsets, fbo->GetWidth(), fbo->GetHeight(), filterWidth, NUM_DOWNSAMPLES); 962 973 963 sCgDownSampleProgram->SetArray2f(1, (float *)downSampleOffsets, NUM_DOWNSAMPLES); 974 964 … … 979 969 980 970 glPopAttrib(); 981 982 971 PrintGLerror("downsample"); 983 972 } … … 1019 1008 DrawQuad(sCgDownSampleProgram); 1020 1009 1021 PrintGLerror(" OUTPUT");1010 PrintGLerror("output"); 1022 1011 } 1023 1012
Note: See TracChangeset
for help on using the changeset viewer.