Changeset 3016
- Timestamp:
- 10/08/08 17:39:20 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3010 r3016 515 515 </File> 516 516 <File 517 RelativePath=".\src\shaderenv.h"518 >519 </File>520 <File521 517 RelativePath=".\src\ShadowMapping.h" 522 518 > … … 769 765 <File 770 766 RelativePath=".\src\shaders\mrt.cg" 767 > 768 </File> 769 <File 770 RelativePath=".\src\shaderenv.h" 771 771 > 772 772 </File> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3015 r3016 70 70 static CGparameter sOldModelViewProjMatrixParam; 71 71 static CGparameter sModelViewProjMatrixParam; 72 static CGparameter sMaxDepthParam;73 72 static CGparameter sEyePosParam; 74 73 static CGparameter sEyePosShadowParam; … … 83 82 84 83 static CGparameter sColorsTexGiParam; 85 static CGparameter sPositionsTexGiParam;86 84 static CGparameter sNormalsTexGiParam; 87 85 … … 89 87 static CGparameter sOldModelViewProjMatrixGiParam; 90 88 static CGparameter sModelViewProjMatrixGiParam; 91 static CGparameter sMaxDepthGiParam;92 89 static CGparameter sSamplesGiParam; 93 90 static CGparameter sOldSsaoTexGiParam; … … 131 128 132 129 static CGparameter sShadowMatrixParam; 133 static CGparameter sMaxDepthShadowParam;134 130 static CGparameter sSampleWidthParam; 135 131 … … 274 270 mWidth(w), mHeight(h), 275 271 mCamera(cam), 276 mScaleFactor(scaleFactor),277 272 mUseTemporalCoherence(true), 278 273 mRegenerateSamples(true), … … 374 369 sOldModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "oldModelViewProj"); 375 370 sModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "modelViewProj"); 376 sMaxDepthParam = cgGetNamedParameter(sCgSsaoProgram, "maxDepth");377 371 sTemporalCoherenceParam = cgGetNamedParameter(sCgSsaoProgram, "temporalCoherence"); 378 372 … … 401 395 402 396 // we need size of texture for scaling 403 sPositionsTexGiParam = cgGetNamedParameter(sCgGiProgram, "positions");404 397 sColorsTexGiParam = cgGetNamedParameter(sCgGiProgram, "colors"); 405 398 sNormalsTexGiParam = cgGetNamedParameter(sCgGiProgram, "normals"); … … 407 400 sOldModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "oldModelViewProj"); 408 401 sModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "modelViewProj"); 409 sMaxDepthGiParam = cgGetNamedParameter(sCgGiProgram, "maxDepth");410 402 sTemporalCoherenceGiParam = cgGetNamedParameter(sCgGiProgram, "temporalCoherence"); 411 403 … … 501 493 502 494 sShadowMapParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMap"); 503 sMaxDepthShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "maxDepth");504 495 sSampleWidthParam = cgGetNamedParameter(sCgDeferredShadowProgram, "sampleWidth"); 505 496 sShadowMatrixParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMatrix"); … … 696 687 697 688 cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 698 #if 1689 #if 0 699 690 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 700 691 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); … … 733 724 cgGLEnableTextureParameter(sOldTexParam); 734 725 735 cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 736 737 Vector3 pos = mCamera->GetPosition() / mScaleFactor; 726 Vector3 pos = mCamera->GetPosition(); 738 727 cgGLSetParameter3f(sEyePosParam, pos.x, pos.y, pos.z); 739 728 … … 913 902 cgGLSetMatrixParameterfc(sModelViewProjMatrixGiParam, (const float *)projViewMatrix.x); 914 903 915 //GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 904 #if 0 905 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 906 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 907 #else 916 908 GLuint colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 917 909 GLuint normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 918 GLuint positionsTex = fbo->GetColorBuffer(2)->GetTexture(); 910 #endif 919 911 920 912 glPushAttrib(GL_VIEWPORT_BIT); … … 931 923 cgGLBindProgram(sCgGiProgram); 932 924 933 cgGLSetTextureParameter(sPositionsTexGiParam, positionsTex);934 cgGLEnableTextureParameter(sPositionsTexGiParam);935 925 936 926 cgGLSetTextureParameter(sColorsTexGiParam, colorsTex); … … 948 938 cgGLSetTextureParameter(sOldIllumTexGiParam, oldIllumTex); 949 939 cgGLEnableTextureParameter(sOldIllumTexGiParam); 950 951 cgGLSetParameter1f(sMaxDepthGiParam, mScaleFactor);952 940 953 941 … … 964 952 GenerateSamples(mSamplingMethod); 965 953 966 #ifdef USE_3D_SSAO967 cgGLSetParameterArray3f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples3);968 #else969 954 cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples2); 970 #endif971 955 } 972 956 … … 975 959 ComputeViewVectors(tl, tr, bl, br); 976 960 977 const Vector3 pos = mCamera->GetPosition() / mScaleFactor;961 const Vector3 pos = mCamera->GetPosition(); 978 962 cgGLSetParameter3f(sEyePosGiParam, pos.x, pos.y, pos.z); 979 963 … … 997 981 998 982 cgGLDisableTextureParameter(sColorsTexGiParam); 999 cgGLDisableTextureParameter(sPositionsTexGiParam);1000 983 cgGLDisableTextureParameter(sNormalsTexGiParam); 1001 984 cgGLDisableTextureParameter(sNoiseTexGiParam); … … 1132 1115 cgGLEnableTextureParameter(sShadowMapParam); 1133 1116 1134 cgGLSetParameter1f(sMaxDepthShadowParam, mScaleFactor);1135 1136 1117 cgGLSetParameter1f(sSampleWidthParam, 2.0f / shadowMap->GetSize()); 1137 1118 … … 1148 1129 ComputeViewVectors(tl, tr, bl, br); 1149 1130 1150 const Vector3 pos = mCamera->GetPosition() / mScaleFactor;1131 const Vector3 pos = mCamera->GetPosition(); 1151 1132 cgGLSetParameter3f(sEyePosShadowParam, pos.x, pos.y, pos.z); 1152 1133 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r3007 r3016 103 103 int mHeight; 104 104 105 /// a scale factor of scene positions in order to get better float precision in the shader106 float mScaleFactor;107 108 105 Camera *mCamera; 109 106 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3015 r3016 24 24 #include "RenderQueue.h" 25 25 #include "Material.h" 26 #include <Cg/cg.h>27 #include <Cg/cgGL.h>28 26 #include "glfont2.h" 29 27 #include "PerformanceGraph.h" … … 42 40 #include "EntityMerger.h" 43 41 42 #include <Cg/cg.h> 43 #include <Cg/cgGL.h> 44 44 45 45 … … 98 98 SkyPreetham *preetham = NULL; 99 99 100 100 101 /// the used render type for this render pass 101 102 enum RenderMethod … … 269 270 static CGprogram sCgMrtVertexProgram = NULL; 270 271 271 static CGparameter sMaxDepthParam;272 static CGparameter sMaxDepthParamTex;273 272 static CGparameter sEyePosParamTex; 274 273 static CGparameter sEyePosParam; … … 565 564 cgGLLoadProgram(RenderState::sCgMrtFragmentTexProgram); 566 565 567 sMaxDepthParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "maxDepth");568 566 sEyePosParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 569 567 RenderState::sTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tex"); 570 568 571 //const float maxDepth = MAX_DEPTH_CONST / farDist;572 const float maxDepth = 1.0f;573 574 cgGLSetParameter1f(sMaxDepthParamTex, maxDepth);575 576 569 sTLParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tl"); 577 570 sTRParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tr"); … … 594 587 cgGLLoadProgram(RenderState::sCgMrtFragmentProgram); 595 588 596 sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth");597 589 sEyePosParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 598 590 599 //const float maxDepth = MAX_DEPTH_CONST / farDist;600 const float maxDepth = 1.0f;601 602 cgGLSetParameter1f(sMaxDepthParam, maxDepth);603 604 591 sTLParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tl"); 605 592 sTRParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tr"); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3015 r3016 10 10 11 11 // for quadratic falloff 12 #define SAMPLE_INTENSITY 0. 35f12 #define SAMPLE_INTENSITY 0.15f 13 13 //#define SAMPLE_INTENSITY 0.32f 14 14 15 15 #define AREA_SIZE 8e-1f 16 16 17 #define DISTANCE_SCALE 1e-1f18 //#define DISTANCE_SCALE 1e-6f17 //#define DISTANCE_SCALE 1e-1f 18 #define DISTANCE_SCALE 5e-2f 19 19 20 #define ILLUM_INTENSITY 5e- 1f;20 #define ILLUM_INTENSITY 5e-2f 21 21 22 22 #define VIEW_CORRECTION_SCALE 0.1f … … 40 40 #define MAX_LOD_LEVEL 10 41 41 42 #define MIN_DEPTH_DIFF 1e- 1f42 #define MIN_DEPTH_DIFF 1e-3f 43 43 // burnout 44 44 #define WHITE_LUMINANCE 3e4f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3014 r3016 140 140 uniform sampler2D shadowMap, 141 141 uniform float4x4 shadowMatrix, 142 uniform float maxDepth,143 142 uniform float sampleWidth, 144 143 uniform sampler2D noiseTexture, … … 183 182 ) 184 183 { 185 position *= maxDepth;186 184 position.w = 1.0f; 187 185 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r3014 r3016 10 10 // normalized screen position 11 11 float4 pos: WPOS; 12 float 4texCoord: TEXCOORD0;12 float2 texCoord: TEXCOORD0; 13 13 float3 view: TEXCOORD1; 14 14 }; … … 123 123 float cos_angle = max(dot(direction_to_sample, currentNormal), 0); 124 124 125 const float denom = (DISTANCE_SCALE + length_to_sample * length_to_sample); 125 126 // distance between current position and sample position controls AO intensity. 126 const float distance_intensity = 127 (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 127 const float ssao_intensity = SAMPLE_INTENSITY / denom; 128 129 const float illum_intensity = ILLUM_INTENSITY / denom; 128 130 129 131 // if normal perpenticular to view dir, only half of the samples count … … 133 135 total_color.xyz += cos_angle * distance_intensity * view_correction * sample_color * ILLUM_INTENSITY; 134 136 #endif 135 total_ao += cos_angle * distance_intensity;136 total_color += cos_angle * distance_intensity * sample_color * ILLUM_INTENSITY;137 total_ao += cos_angle * ssao_intensity; 138 total_color += cos_angle * illum_intensity * sample_color; 137 139 } 138 140 … … 148 150 pixel2 main(fragment IN, 149 151 uniform sampler2D colors, 150 uniform sampler2D positions,151 152 uniform sampler2D normals, 152 153 uniform sampler2D noiseTexture, … … 156 157 const uniform float4x4 oldModelViewProj, 157 158 const uniform float4x4 modelViewProj, 158 uniform float maxDepth,159 159 uniform float temporalCoherence, 160 160 uniform float3 eyePos, … … 167 167 pixel2 OUT; 168 168 169 float4 norm = tex2D (normals, IN.texCoord.xy);169 float4 norm = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)); 170 170 float3 normal = normalize(norm.xyz); 171 171 … … 178 178 179 179 float3 viewDir = IN.view; 180 const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord .xy, 0, 0)).w;180 const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 181 181 182 182 const float3 eyeSpacePos = -viewDir * eyeDepth; 183 183 184 float3 centerPosition; 185 centerPosition.xyz = eyePos - viewDir * eyeDepth; 186 184 float3 centerPosition = eyePos + eyeSpacePos; 187 185 //const float3 centerPosition = tex2D(positions, IN.texCoord.xy).xyz; 188 186 … … 197 195 //-- compute temporally smoothing 198 196 199 float4 realPos = float4(centerPosition * maxDepth, 1.0f);197 float4 realPos = float4(centerPosition, 1.0f); 200 198 201 199 … … 269 267 pixel OUT; 270 268 271 float4 col = tex2D (colors, IN.texCoord.xy);272 float ao = tex2D(ssaoTex, IN.texCoord.xy).x;273 float4 illum = tex2D (illumTex, IN.texCoord.xy);274 269 float4 col = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 270 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)).x; 271 float4 illum = tex2Dlod(illumTex, float4(IN.texCoord, 0, 0)); 272 275 273 OUT.illum_col = (col + illum) * ao; 276 274 OUT.illum_col.w = col.w; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3009 r3016 78 78 pixel fragtex(fragin IN, 79 79 uniform sampler2D dirtTex, 80 uniform float maxDepth,81 80 uniform sampler2D tex, 82 81 uniform float3 eyePos, … … 110 109 const float2 screenCoord = projPos.xy * 0.5f + 0.5f; 111 110 const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 112 pix.col.w = length(eyePos - IN.worldPos.xyz) * maxDepth/ magView;111 pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 113 112 114 113 #if 0 … … 122 121 123 122 pixel frag(fragin IN, 124 uniform float maxDepth,125 123 uniform float3 eyePos, 126 124 uniform float3 bl, … … 147 145 float2 screenCoord = projPos.xy * 0.5f + 0.5f; 148 146 const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 149 pix.col.w = length(eyePos - IN.worldPos.xyz) * maxDepth/ magView;147 pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 150 148 151 149 #if 0 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3014 r3016 150 150 const uniform float4x4 oldModelViewProj, 151 151 const uniform float4x4 modelViewProj, 152 uniform float maxDepth,153 152 uniform float temporalCoherence, 154 153 uniform float3 eyePos, … … 176 175 177 176 float3 centerPosition; 178 centerPosition.xyz = eyePos - viewDir * eyeDepth;177 centerPosition.xyz = eyePos + eyeSpacePos; 179 178 180 179 const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, eyeSpacePos, w, bl, br, tl, tr); 180 181 181 #else 182 182 … … 191 191 //-- compute temporally smoothing 192 192 193 float4 realPos = float4(centerPosition * maxDepth, 1.0f);193 float4 realPos = float4(centerPosition, 1.0f); 194 194 195 195 … … 264 264 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 265 265 266 //OUT.illum_col = col * ao.x;267 OUT.illum_col = float4(ao.x,ao.x,ao.x, ao.w);266 OUT.illum_col = col * ao.x; 267 //OUT.illum_col = float4(ao.x,ao.x,ao.x, ao.w); 268 268 OUT.illum_col.w = col.w; 269 269 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
r3014 r3016 51 51 uniform float2 downSampleOffs[NUM_DOWNSAMPLES]): COLOR 52 52 { 53 //return tex2Dlod(colors, float4(IN.texCoord, 0, 0));54 53 return tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 54 /* 55 55 float4 average = .0f; 56 56 … … 62 62 average *= 1.0f / (float)NUM_DOWNSAMPLES; 63 63 64 return average; 64 return average;*/ 65 65 } 66 66
Note: See TracChangeset
for help on using the changeset viewer.