Changeset 2811 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 07/03/08 17:52:45 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2800 r2811 171 171 } 172 172 else 173 { 173 174 texcoords = NULL; 175 } 176 177 for (int i = 0; i < vertexCount; i += 3) 178 { 179 Triangle3 tri(vertices[i], vertices[i + 1], vertices[i + 2]); 180 Vector3 n = tri.GetNormal(); 181 normals[i + 0] = n; 182 normals[i + 1] = n; 183 normals[i + 2] = n; 184 } 174 185 175 186 return new Geometry(vertices, normals, texcoords, vertexCount, true); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2810 r2811 89 89 90 90 static int winWidth = 1024; 91 static int winHeight = 768;91 static int winHeight = 1024; 92 92 static float winAspectRatio = 1.0f; 93 93 … … 98 98 99 99 // rendertexture 100 const static int texWidth = 2048;101 const static int texHeight = 2048;100 const static int texWidth = 1024; 101 const static int texHeight = 1024; 102 102 103 103 int renderedObjects = 0; … … 331 331 //bvh = bvhLoader.Load("data/city/model/city.bvh", sceneEntities); 332 332 333 myfar = 1 0.0f * Magnitude(bvh->GetBox().Diagonal());333 myfar = 1.0f * Magnitude(bvh->GetBox().Diagonal()); 334 334 335 335 if (!bvh) … … 550 550 glGenRenderbuffersEXT(1, &normalsBuffer); 551 551 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, normalsBuffer); 552 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA 8, texWidth, texHeight);552 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 553 553 554 554 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_RENDERBUFFER_EXT, normalsBuffer); … … 556 556 glGenTextures(1, &normalsTex); 557 557 glBindTexture(GL_TEXTURE_2D, normalsTex); 558 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA 8, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);558 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 559 559 glGenerateMipmapEXT(GL_TEXTURE_2D); 560 560 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, normalsTex, 0); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2810 r2811 57 57 58 58 // the normal on the current position 59 float3 centerNormal = tex2D(normals, IN.texCoord.xy).xyz * 2.0f - 1.0f; 60 59 float3 centerNormal = tex2D(normals, IN.texCoord.xy).xyz; 60 normalize(centerNormal); 61 61 62 // Check in a circular area around the current position. 62 63 // Shoot vectors to the positions there, and check the angle to these positions. … … 66 67 67 68 //const float areaSize = 4.0f; 68 const float areaSize = 5e-3f;69 const float sampleIntensity = 0.1 ;69 const float areaSize = 4e-3f; 70 const float sampleIntensity = 0.1f; 70 71 71 72 for (int i = 0; i < SAMPLES; i ++) { … … 75 76 float3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz * 2.0f - 1.0f; 76 77 78 // float2 offsetTransformed = offset; 77 79 float2 offsetTransformed; 78 80 offsetTransformed.x = noise.r*offset.x - noise.g*offset.y; … … 84 86 85 87 float3 vector_to_sample = sample_position - centerPosition; 88 // vector_to_sample.z = -vector_to_sample.z; 86 89 float length_to_sample = length(vector_to_sample); 87 float3 direction_to_sample = vector_to_sample / length_to_sample;90 float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f); 88 91 89 92 // Angle between current normal and direction to sample controls AO intensity. … … 92 95 93 96 // distance between current position and sample position controls AO intensity. 94 const float scale = 5e-1f; 97 const float maxdist = 5e-1f; 98 //const float scale = 50.0f; 95 99 96 float distance_intensity = scale * (1.0f - length_to_sample);100 float distance_intensity = maxdist - length_to_sample; 97 101 distance_intensity = max(distance_intensity, 0.0f); 98 102 … … 112 116 { 113 117 pixel OUT; 114 float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f); 118 //float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f); 119 float4 lightDir = float4(0.0f, 1.0f, 0.0f, 0.0f); 115 120 116 121 float4 color = tex2D(colors, IN.texCoord.xy); … … 121 126 float4 position = tex2D(positions, IN.texCoord.xy); 122 127 123 float4 ambient = float4(0. 3f);128 float4 ambient = float4(0.1f); 124 129 125 130 // float3 L = normalize(lightPosition - position); … … 132 137 OUT.color = ao; //(ambient + diffuse) * color; 133 138 //OUT.color = (ambient + diffuse) * color; 139 134 140 //float4 currentPos = tex2D(positions, IN.texCoord.xy); 141 //OUT.color = currentPos; 142 //float4 currentPos = tex2D(normals, IN.texCoord.xy) * 0.5f + 0.5f; 135 143 //OUT.color = currentPos; 136 144 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2810 r2811 16 16 float4 color: COLOR0; 17 17 float4 worldPos: TEXCOORD1; // world position 18 float3 norm : TEXCOORD2;18 float3 normal: TEXCOORD2; 19 19 }; 20 20 … … 29 29 float4 color: COLOR0; 30 30 float4 worldPos: TEXCOORD1; // world position 31 float3 norm : TEXCOORD2;31 float3 normal: TEXCOORD2; 32 32 }; 33 33 … … 54 54 // eye pos with linear depth 55 55 //OUT.worldPos = OUT.position; 56 OUT.norm = IN.normal;56 OUT.normal = IN.normal; 57 57 58 58 return OUT; … … 66 66 pix.col = tex2D(tex, IN.texCoord.xy); 67 67 pix.pos = IN.worldPos * maxDepth; 68 pix.norm = IN.norm * 0.5f + 0.5f;68 pix.norm = IN.normal; 69 69 70 70 return pix;
Note: See TracChangeset
for help on using the changeset viewer.