convert depth from linear to projection (deffered particles)

This topic is 2022 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi,

currently i would like to introduce particles into my deferred renderer, what i do:

- accumulate particles into off screen low res buffer,

- after drawing all objects into deferred buffer, "inject" accumulated particles into scene (output depth from particles into main buffer),

also use stipples during this process.

- resolve lights on this deferred buffer

- resolve final transparency for particles.

Yaay, now i have fully lighted, shadow receiving (not casting) particles with low effort but :

Because i'm using point sprites, normals always point in one direction, so basically when light comes from behind of particles, they aren't lighted at all. When light is in front of particles, everything is ok.

I would like to blur depth values in accumulated particles depth buffer and compute some surface normals to adjust particle normal somehow,

so particles will became volumes instead of sprites.

But for this i need to blur particle depth in linear space. I can do that with no problem.

But when i'm "injecting" particles, i need projection depth, so particles will be correctly occluded by objects and also lightning will work correctly.

Is there any way to convert from linear depth into projection depth with using camera parameters (near and far plane)?

Share on other sites

float2 zw = mul(float4(0, 0, z, 1.0f), ProjMatrix).zw;
float projDepth = zw.x / zw.y;


Share on other sites

float2 zw = mul(float4(0, 0, z, 1.0f), ProjMatrix).zw;
float projDepth = zw.x / zw.y;


thanks, I thought about that but wasn't sure

Edited by joeblack

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 9
• 11
• 15
• 21
• 26