Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

convert depth from linear to projection (deffered particles)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 joeblack   Members   

303
Like
0Likes
Like

Posted 09 April 2014 - 02:52 AM

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)?

 

 



#2 spazzarama   GDNet+   

1643
Like
1Likes
Like

Posted 09 April 2014 - 04:08 AM

There's a couple of pages by MJP that might help you work it out:

 

http://mynameismjp.wordpress.com/2010/03/22/attack-of-the-depth-buffer/

 

http://mynameismjp.wordpress.com/2009/05/05/reconstructing-position-from-depth-continued/

 

http://mynameismjp.wordpress.com/2010/09/05/position-from-depth-3/


Justin Stenning | Blog | Book - Direct3D Rendering Cookbook (using C# and SharpDX)

Projects: Direct3D Hook, EasyHook, Shared Memory (IPC), SharpDisasm (x86/64 disassembler in C#)

@spazzarama

 

#3 MJP   Moderators   

19429
Like
2Likes
Like

Posted 09 April 2014 - 12:06 PM

Just multiply your depth by your projection matrix:

 

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


#4 joeblack   Members   

303
Like
0Likes
Like

Posted 09 April 2014 - 12:09 PM

 

Just multiply your depth by your projection matrix:

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, 09 April 2014 - 12:10 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.