- Timestamp:
- 11/07/08 10:15:44 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r3102 r3109 15 15 { 16 16 17 int SceneEntity::sCurrentId = 0; 17 18 bool SceneEntity::sUseLODs = true; 18 19 19 20 20 21 SceneEntity::SceneEntity(Transform3 *trafo): 21 mTransform(trafo), mCurrentLODLevel(0), mLODLastUpdated(-1) 22 mTransform(trafo), mCurrentLODLevel(0), mLODLastUpdated(-1), mId(sCurrentId ++) 22 23 { 23 24 mBox.Initialize(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r3102 r3109 127 127 Vector3 mCenter; 128 128 129 int mId; 130 129 131 static bool sUseLODs; 132 static int sCurrentId; 130 133 }; 134 131 135 132 136 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3108 r3109 125 125 uniform float4x4 oldModelViewProj, 126 126 uniform float temporalCoherence, 127 uniform float2 samples[NUM_SAMPLES],128 127 uniform sampler2D colors, 129 uniform sampler2D noiseTex,130 float scaleFactor,131 128 uniform float3 bl, 132 129 uniform float3 br, 133 130 uniform float3 tl, 134 131 uniform float3 tr, 132 float invW, 133 float3 projPos, 134 float4x4 inverseModelTrafo, 135 float id, 136 uniform sampler2D noiseTex, 137 uniform float2 samples[NUM_SAMPLES], 138 float scaleFactor, 135 139 uniform float3 oldbl, 136 140 uniform float3 oldbr, 137 141 uniform float3 oldtl, 138 uniform float3 oldtr, 139 float invW, 140 float3 projPos 141 //,const uniform float4x4 inverseModelTrafo 142 //, float id 143 ) 142 uniform float3 oldtr 143 ) 144 144 { 145 145 float4 illum_col; 146 146 147 //////////// 148 //-- dynamic objects 149 150 float4x4 trafo; 151 152 if (id > 20) trafo = oldModelViewProj; 153 else trafo = inverseModelTrafo * oldModelViewProj; 154 155 // compute translational portion 156 const float3 translatedPt = worldPos.xyz - oldEyePos; 157 147 158 ///////////////// 148 //-- compute reprojection for temporal smoothing 149 150 //float4x4 trafo; 151 // dynamic object 152 //if (id > 20) trafo = oldModelViewProj; 153 //else trafo = inverseModelTrafo * oldModelViewProj; 154 155 const float3 translatedPt = worldPos.xyz - oldEyePos; 156 157 // reproject into old frame and calculate texture position of sample in old frame 158 float4 backProjPos = mul(oldModelViewProj, float4(translatedPt, 1.0f)); 159 //-- reproject into old frame and calculate texture position of sample in old frame 160 161 // note: the old model view matrix only holds the view orientation part 162 float4 backProjPos = mul(trafo, float4(translatedPt, 1.0f)); 159 163 backProjPos /= backProjPos.w; 164 160 165 // fit from unit cube into 0 .. 1 161 166 const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f; 162 167 163 164 168 // retrieve the sample from the last frame 165 169 const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f)); 170 166 171 167 172 #if USE_EYESPACE_DEPTH … … 171 176 // vector from eye pos to old sample 172 177 const float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 173 const float inv len = 1.0f / length(viewVec);174 const float projectedEyeSpaceDepth = inv len * length(translatedPt);178 const float invLen = 1.0f / length(viewVec); 179 const float projectedEyeSpaceDepth = invLen * length(translatedPt); 175 180 176 181 //const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth); 177 //const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 178 179 const float depthDif = abs(projectedEyeSpaceDepth - oldEyeSpaceDepth ) / projectedEyeSpaceDepth; 182 const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 183 //const float depthDif = abs(projectedEyeSpaceDepth - oldEyeSpaceDepth ) / projectedEyeSpaceDepth; 180 184 181 185 #else … … 345 349 uniform float3 oldbr, 346 350 uniform float3 oldtl, 347 uniform float3 oldtr 351 uniform float3 oldtr, 352 uniform sampler2D attribs, 353 uniform float4x4 inverseModelTrafo 348 354 ) 349 355 { … … 377 383 //-- compute temporally smoothing 378 384 385 float id = tex2Dlod(attribs, float4(IN.texCoord, 0, 0)).x; 386 379 387 OUT.illum_col = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, ao, IN.texCoord, oldEyePos, 380 388 oldTex, oldModelViewProj, temporalCoherence, 381 samples, colors, noiseTex, w, bl, br, tl, tr,382 oldbl, oldbr, oldtl, oldtr, scaleFactor, projPos);389 colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id, 390 noiseTex, samples, scaleFactor, oldbl, oldbr, oldtl, oldtr); 383 391 384 392 //OUT.illum_col.xyz = normal * 0.5f + 0.5f;
Note: See TracChangeset
for help on using the changeset viewer.