Smoke Environment

Started by
13 comments, last by L. Spiro 11 years ago

In D3D9, you can't use (normal) depth buffers as textures (readable), only as surfaces (writable).

One workaround is to use MRT during your normal rendering, and manually write depth to a second render target. This however, requires editing all our shaders, and is inefficient.

Another workaround (that I'd recommend) is to create an "INTZ" texutre. This texture is a readable depth texture, and you can get its surface in order to use it as your depth/stencil target (instead of your regular depth buffer).
The only downside to this approach is that creating an INTZ texture will fail on any GPU older than a GeForce 8, so it raises your minimum requirements.

If I remember correctly from back then, you can use RawZ on older NV gpus.

Advertisement
I'm still a bit confused.
Do I have to use the pixel shader directly when rendering the particles?
Or do I have to get the depth information with the fixed functions and then pass it to the pixel shader?
The depth values are stored in a texture which your pixel shader will access.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

@L. Spiro: Any code sample for creating depth buffer texture in D3D9?

Also, I want a pixel shader example for soft particles, I have checked some links but couldn't find a complete sample.

There are no code samples because this is extremely dependent on your engine.

Hodgman mentioned the valid point that writing depth to a special texture other than the main depth surface (which normally cannot be read) requires all shaders be modified to write that information, which really will be quite a nuisance when you have a ton of basic shaders that all have to be hand-written.

My engine’s shader system works on permutations based on macros within a single shader, so for me to add this tactic (which is what I did) is nothing.

If you want to do something similar it will really take a huge amount of work and you have to really focus your shader system on a macro-based system. Macros help with permutations, obviously. But implementing your own system really takes a lot of work, and getting to the point where you can use macros may require a whole rewrite of your shader system.

So it is up to you how to proceed.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement