It is currently Sat Aug 22, 2020 4:14 am


All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Does it look like anything is happening?
PostPosted: Sat Mar 26, 2011 3:36 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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

Image

Second photo Ambient value: 0.6, 0.6, 0.6
Image

Ambient 1,1,1:
Image

P.S. all other lights are disable for the moment.

(Oh and hey, MLE moved for Deferred Shading! :))


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sat Mar 26, 2011 11:08 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sun Mar 27, 2011 7:06 am 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Well, it is there, it just doesn't like PolyVox that much for some mysterious reason.

Tested with the usual suspect:
Image

Image

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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sun Mar 27, 2011 8:07 am 

Joined: Sat Sep 18, 2010 9:45 pm
Posts: 189
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sun Mar 27, 2011 9:53 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sun Mar 27, 2011 12:27 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
How can the PolyVox material affect SSAO at all? As iti s generated from normals and depth only.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sun Mar 27, 2011 12:29 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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 ;)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sun Mar 27, 2011 12:47 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Sun Mar 27, 2011 11:59 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Some other latest addition...

Image

Image

Cascaded Shadow Mapping :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Does it look like anything is happening?
PostPosted: Mon Mar 28, 2011 6:44 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Nice, what technique are you using to soften the edges?


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net