Jump to content
  • Advertisement

gsc

Member
  • Content Count

    2
  • Joined

  • Last visited

Everything posted by gsc

  1. Hi! I am trying to implement simple SSAO postprocess. The main source of my knowledge on this topic is that awesome tutorial. But unfortunately something doesn't work... And after a few long hours I need some help. Here is my hlsl shader: float3 randVec = _noise * 2.0f - 1.0f; // noise: vec: {[0;1], [0;1], 0} float3 tangent = normalize(randVec - normalVS * dot(randVec, normalVS)); float3 bitangent = cross(tangent, normalVS); float3x3 TBN = float3x3(tangent, bitangent, normalVS); float occlusion = 0.0; for (int i = 0; i < kernelSize; ++i) { float3 samplePos = samples[i].xyz; // samples: {[-1;1], [-1;1], [0;1]} samplePos = mul(samplePos, TBN); samplePos = positionVS.xyz + samplePos * ssaoRadius; float4 offset = float4(samplePos, 1.0f); offset = mul(offset, projectionMatrix); offset.xy /= offset.w; offset.y = -offset.y; offset.xy = offset.xy * 0.5f + 0.5f; float sampleDepth = tex_4.Sample(textureSampler, offset.xy).a; sampleDepth = vsPosFromDepth(sampleDepth, offset.xy).z; const float threshold = 0.025f; float rangeCheck = abs(positionVS.z - sampleDepth) < ssaoRadius ? 1.0 : 0.0; occlusion += (sampleDepth <= samplePos.z + threshold ? 1.0 : 0.0) * rangeCheck; } occlusion = saturate(1 - (occlusion / kernelSize)); And current result: http://imgur.com/UX2X1fc I will really appreciate for any advice!
  2. gsc

    trying with ssao

    @missionctrl yes, I have that part of math, I am using a buffer with normals in view space (look at the attachment) @KarimIO hmmm... if the shader hasn't any mistakes, then my data from buffers should be wrong... Generally, I have normal buffer ( and depth buffer to reconstruct VS of geometry, but for test purpose I created special position buffers to eliminate possibility of mistakes in calculations from the depth buffer. All buffers and results here: http://imgur.com/a/nm0bA I have no idea, why version with positions read directly from the buffer is so noisy and the second one hasn't virtually any noise.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!