Changeset 2975 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 09/26/08 10:31:58 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2974 r2975 81 81 82 82 OUT.color = col; 83 OUT.color.w = color.w; 84 85 // write out logaritmic luminance for tone mapping 83 84 85 //////////// 86 //-- write out logaritmic luminance for tone mapping 87 86 88 const float3 w = float3(0.299f, 0.587f, 0.114f); 87 89 … … 89 91 float logLum = log(1e-5f + lum); 90 92 91 float invLogLumRange = 1 / (MAXLOGLUM + MINLOGLUM); 92 float logLumOffset = MINLOGLUM * invLogLumRange; 93 float logLumScaled = logLum * invLogLumRange + logLumOffset; 93 float logLumOffset = MINLOGLUM * INV_LOGLUM_RANGE; 94 float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 94 95 95 96 OUT.color.w = logLumScaled; … … 194 195 OUT.color = (emmisive > 1.5f) ? color: (ambient + diffuse) * color; 195 196 196 // write out logaritmic luminance for tone mapping 197 //////////// 198 //-- write out logaritmic luminance for tone mapping 199 197 200 const float3 w = float3(0.299f, 0.587f, 0.114f); 198 201 … … 200 203 float logLum = log(1e-5f + lum); 201 204 202 OUT.color.w = 100;//logLum; 205 float logLumOffset = MINLOGLUM * INV_LOGLUM_RANGE; 206 float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 207 208 OUT.color.w = logLumScaled; 203 209 204 210 return OUT; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r2974 r2975 52 52 uniform float2 samples[NUM_SAMPLES], 53 53 uniform float3 currentNormal, 54 uniform float3 currentViewDir, 55 uniform float4 centerPosition 54 uniform float4 centerPosition, 55 float w 56 //, uniform float3 currentViewDir 56 57 ) 57 58 { 58 59 GiStruct gi; 59 60 // the w coordinate from the persp. projection61 float w = centerPosition.w;62 60 63 61 // Check in a circular area around the current position. … … 117 115 } 118 116 119 gi.illum = saturate(total_color);117 gi.illum = total_color; 120 118 gi.ao = float2(max(0.0f, 1.0f - total_ao), numSamples); 121 119 … … 143 141 144 142 float4 norm = tex2D(normals, IN.texCoord.xy); 145 146 // theambient term143 float3 normal = normalize(norm.xyz); 144 // something like a constant ambient term 147 145 const float amb = norm.w; 148 149 // expand normal150 float3 normal = normalize(norm.xyz);151 152 146 /// the current view direction 153 float3 viewDir;// = normalize(IN.view); 154 147 //float3 viewDir = normalize(IN.view); 148 149 // the w coordinate from the persp. projection 150 float w = norm.w; 155 151 // the current world position 156 152 const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 157 158 153 // the current color 159 154 const float4 currentCol = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 160 155 // the current depth is stored in the w component 161 const float currentDepth = c urrentCol.w;162 163 GiStruct gi = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, centerPosition);156 const float currentDepth = centerPosition.w; 157 158 GiStruct gi = globIllum(IN, colors, positions, noiseTexture, samples, normal, centerPosition, w); //, viewDir); 164 159 165 160 … … 186 181 187 182 const float oldNumSamples = oldSsao.y; 183 const float oldAvgDepth = oldSsao.z; 188 184 189 185 if ((temporalCoherence > 0.0f) && 190 186 (tex.x >= 0.0f) && (tex.x < 1.0f) && 191 187 (tex.y >= 0.0f) && (tex.y < 1.0f) && 192 (abs(depthDif) < 1e-3f) 193 && (oldNumSamples > gi.ao.y - 1.5f) // check if something happened in the surrounding area 188 (abs(depthDif) < 1e-3f) 189 // check if something changed in the surrounding area 190 && (oldNumSamples > 0.2 * gi.ao.y) 191 && (oldAvgDepth / newAvgDepth > 0.99) 194 192 ) 195 193 { … … 218 216 uniform sampler2D ssaoTex, 219 217 uniform sampler2D illumTex 220 218 ) 221 219 { 222 220 pixel OUT; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2974 r2975 117 117 118 118 float4 norm = tex2D(normals, IN.texCoord.xy); 119 120 // expand normal121 119 float3 normal = normalize(norm.xyz); 122 120 123 121 // a constant ambient term 124 122 const float amb = norm.w; 125 123 // the w coordinate from the persp. projection 126 124 float w = norm.w; 127 128 125 // the current world position 129 126 const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 130 131 127 // the current color 132 128 const float currentDepth = centerPosition.w; … … 141 137 realPos.w = 1.0f; 142 138 143 // reproject 139 140 /////////// 141 //-- reprojection from new frame into old one 142 144 143 float4 oldPos = mul(oldModelViewProj, realPos); 145 144 … … 161 160 (tex.y >= 0.0f) && (tex.y < 1.0f) && 162 161 (abs(depthDif) < 1e-3f) 163 && (oldNumSamples > ao.y - 1.5f) // check if something happened in the surrounding area 162 // check if visibility changed in the surrounding area: 163 // then we have to recompute 164 && (oldNumSamples > ao.y - 1.5f) 164 165 ) 165 166 { 166 167 // increase the weight for convergence 167 168 newWeight = oldWeight + 1.0f; 168 169 //OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor);170 169 OUT.illum_col.xy = (ao.xy + oldCol.xy * oldWeight) / newWeight; 171 170 … … 193 192 194 193 float4 col = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 195 float depth = tex2Dlod(positions, float4(IN.texCoord.xy, 0, 0)).w;196 194 float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 197 195 198 196 OUT.illum_col = col * ao.x; 199 OUT.illum_col.w = ao.w; 197 //OUT.illum_col.w = ao.w; 198 OUT.illum_col.w = col.w; 200 199 201 200 return OUT; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
r2974 r2975 90 90 // obtain new image key from highest mipmap level 91 91 float logLumScaled = tex2Dlod(colors, float4(.5f, .5f, 0, 99)).w; 92 93 float logLumRange = MAXLOGLUM + MINLOGLUM; 94 //float logLumOffset = MINLOGLUM * logLumRange; 95 float logLum = logLumScaled * logLumRange - MINLOGLUM; 92 float logLum = logLumScaled * LOGLUM_RANGE + MINLOGLUM; 96 93 97 94 float newImageKey = exp(logLum);
Note: See TracChangeset
for help on using the changeset viewer.