Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Does it look like anything is happening? http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=184 |
Page 1 of 3 |
Author: | Shanee [ Sat Mar 26, 2011 3:36 pm ] |
Post subject: | Does it look like anything is happening? |
SSAO question, does it look like anything is happening here? I am multiplying SSAO result by ambient light value. (correct me if I am wrong but I should ONLY multiply ambient light value by SSAO value, right?) I just have a feeling it isn't working for some reason. ambient light for first photo: 0.2,0.2,0.2 ![]() Second photo Ambient value: 0.6, 0.6, 0.6 ![]() Ambient 1,1,1: ![]() P.S. all other lights are disable for the moment. (Oh and hey, MLE moved for Deferred Shading! ![]() |
Author: | David Williams [ Sat Mar 26, 2011 11:08 pm ] |
Post subject: | Re: Does it look like anything is happening? |
Nope... I don't see it. For debugging I guess you need to cut your shaders down till there's only ambient light, or without the textures? |
Author: | Shanee [ Sun Mar 27, 2011 7:06 am ] |
Post subject: | Re: Does it look like anything is happening? |
Well, it is there, it just doesn't like PolyVox that much for some mysterious reason. Tested with the usual suspect: ![]() ![]() P.S. yes, all lights except ambient were disabled, ambient multiplied by SSAO. I can control the variable to intensify the effect so I can clearly see it in the scene, but the shapes it gets from polyvox are a bit weird. |
Author: | beyzend [ Sun Mar 27, 2011 8:07 am ] |
Post subject: | Re: Does it look like anything is happening? |
How are you computing the input into SSAO? Anyway, I remember when I integrated SSAO from Ogre, I had to write a manual geometry pass material to output the correct normals because I generate my normals in a shader. I'm about to move to a deferred shading setup, though. |
Author: | David Williams [ Sun Mar 27, 2011 9:53 am ] |
Post subject: | Re: Does it look like anything is happening? |
Ah, I see, so it's only with PolyVox geometry that you are having the problem. Well it looks like you SSAO buffer is being filled correctly so I guess the problem has to be in your material. You still need to cut it down until you find the problem though... beyzend wrote: ...I had to write a manual geometry pass material to output the correct normals because I generate my normals in a shader. This shouldn't be a problem as the marching cubes surface extractor does generate normals. It's only the CubicSurfaceExtractor that doesn't. |
Author: | Shanee [ Sun Mar 27, 2011 12:27 pm ] |
Post subject: | Re: Does it look like anything is happening? |
How can the PolyVox material affect SSAO at all? As iti s generated from normals and depth only. |
Author: | Shanee [ Sun Mar 27, 2011 12:29 pm ] |
Post subject: | Re: Does it look like anything is happening? |
beyzend wrote: How are you computing the input into SSAO? Anyway, I remember when I integrated SSAO from Ogre, I had to write a manual geometry pass material to output the correct normals because I generate my normals in a shader. I'm about to move to a deferred shading setup, though. I am saving the Depth and Normals to the G-Buffer (normals saved in view space, depth in screen space) and using this shader (not, some variables were removed from actual use although still declared, got to clean it up): Code: float4x4 View; float4x4 InvertProjection; // diffuse color, and specularIntensity in the alpha channel texture gRandomNormals; // normals, and specularPower in the alpha channel texture normalMap; //depth texture depthMap; sampler RandomNormals = sampler_state { Texture = (gRandomNormals); AddressU = WRAP; AddressV = WRAP; MagFilter = LINEAR; MinFilter = POINT; Mipfilter = POINT; }; sampler depthSampler = sampler_state { Texture = (depthMap); AddressU = CLAMP; AddressV = CLAMP; MagFilter = POINT; MinFilter = POINT; Mipfilter = POINT; }; sampler normalSampler = sampler_state { Texture = (normalMap); AddressU = CLAMP; AddressV = CLAMP; MagFilter = POINT; MinFilter = POINT; Mipfilter = POINT; }; float2 ScreenSize; float OcclusionSampleRadius = 0.66271; float OcclusionScale = 1.75338; float OcclusionBias = 0.05464; float OcclusionIntensity = 3.04334; float3 gAmbientLight; struct PS_INPUT { float2 TexCoords : TEXCOORD0; }; // Offsets for the pixels we can sample const float2 offsets[8] = {float2(1,0), float2(-1,0), float2(0,1), float2(0,-1), float2(1,1), float2(1,-1), float2(-1,1), float2(-1,-1)}; //Get pixel's position from position buffer float3 GetPosition(in float2 coords) { //read depth float depthVal = tex2D(depthSampler,coords).r; //compute screen-space position float4 position; position.x = coords.x * 2.0f - 1.0f; position.y = -(coords.y * 2.0f - 1.0f); position.z = depthVal; position.w = 1.0f; //transform to world space position = mul(position, InvertProjection); position /= position.w; return position.xyz; } //Get pixel's normal from the normal buffer float3 GetNormal(in float2 coords) { float3 normal = tex2D(normalSampler, coords).xyz * 2.0f - 1.0f; // float4 viewNorm = mul(View, float4(normal, 1.0f)); // return normalize(viewNorm.xyz); return normal; } // Get random number from the random normal map float2 GetRandom(in float2 coords) { return normalize(tex2D(RandomNormals, ScreenSize * coords / 64).xy * 2.0f - 1.0f); } float ApplyOcclusion(in float2 Coords,in float2 UV, in float3 Position, in float3 Normal) { //Calculate vector in 3d between the two points float3 diff = GetPosition(Coords + UV) - Position; const float3 v = normalize(diff); //Calculate the distance between the two points const float d = length(diff)*OcclusionScale; //Calculate final occlusion amount return max(0.0,dot(Normal,v)-OcclusionBias)*(1.0/(1.0+d))*OcclusionIntensity; } float4 ps_main(PS_INPUT Input) : COLOR0 { float3 Position = GetPosition(Input.TexCoords); float3 Normal = GetNormal(Input.TexCoords); float2 Random = GetRandom(Input.TexCoords); float Occlusion = 0.0; float Radius = OcclusionSampleRadius/Position.z; //Sample 32 points to achieve higher-detail occlusion for (int i = 0; i < 4; ++i) { float2 Coord1 = reflect(offsets[i],Random) * Radius; float2 Coord2 = float2(Coord1.x * 0.707 - Coord1.y*0.707, Coord1.x * 0.707 + Coord1.y * 0.707); Occlusion += ApplyOcclusion(Input.TexCoords, Coord1*0.25, Position, Normal); Occlusion += ApplyOcclusion(Input.TexCoords, Coord2*0.5, Position, Normal); Occlusion += ApplyOcclusion(Input.TexCoords, Coord1*0.75, Position, Normal); Occlusion += ApplyOcclusion(Input.TexCoords, Coord2, Position, Normal); } Occlusion/=16; return float4((1-Occlusion) * gAmbientLight, 0.0f); } technique Technique0 { pass Pass0 { PixelShader = compile ps_3_0 ps_main(); } } This is a very simple post processing effect, though I might still need to optimize the shader ![]() |
Author: | David Williams [ Sun Mar 27, 2011 12:47 pm ] |
Post subject: | Re: Does it look like anything is happening? |
Shanee wrote: How can the PolyVox material affect SSAO at all? As iti s generated from normals and depth only. Well I haven't implemented either SSAO or deferred shading so take my comments with a pinch of salt. But from your first images it looks like your SSAO buffer is being computed correctly. So the problem may come from the way you are using that SSAO information, and I assumed this was done in your material somewhere. I also notice that in the second set of images where you show SSAO working correctly there is no material applied, so I guess it might be related. But as I say, I haven't implemented this stuff so I don't have a great knowledge of it... |
Author: | Shanee [ Sun Mar 27, 2011 11:59 pm ] |
Post subject: | Re: Does it look like anything is happening? |
Some other latest addition... ![]() ![]() Cascaded Shadow Mapping ![]() |
Author: | David Williams [ Mon Mar 28, 2011 6:44 pm ] |
Post subject: | Re: Does it look like anything is happening? |
Nice, what technique are you using to soften the edges? |
Page 1 of 3 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |