Render Depth Only

Started by
4 comments, last by wh1sp3rik 11 years, 10 months ago
Hello,

i would like to ask, how can i render depth only ?
I have objects, which consist of vertices, normals, bitangets, uvs and for depth, i need to pass only vertices.
Is there any way, how can i render these objects just passing their verticles ?

How shadows are done ? Are they using somekind of shadow model, if passing verticles only in not possible ?

thank you very much,

DirectX 11, C++

Advertisement
Many questions here:

1) to render depth only, you may set your rendertarget to NULL and keeping the depthstencil target bound. Practically, if you plan to do shadowmapping, you'd create a separate depth stencil texture for the shadows and bind that when rendering the depth.

Also, you may write the depth info to a floating point rendertarget. This is used often with deferred renderers.

2) You may use exactly the same data for shadow rendering as you'd use for normal rendering. Even the same shaders may work, although writing to non-bound render targets may cause debug output to give few errors. You'll need position and texture coordinates for objects with transparency.

You may either create a separate shadow mesh with only position data, or use a second vertex stream for the data not used with the depth pass. However, I tried this once, and I didn't see noticeable performance boost (having only position and texture coordinates for the depth pass).

3) I'm not sure if I understand your question correctly, but there are plenty of examples how to do shadows on the internet.

Simplest way of doing shadows is:

- render the scene from the point of view of the light (use orthogonal projection matrix for directional lights). Store depth in depth/stencil buffer.

- render scene normally. For shadowing factor , in the pixel shader, transform each position to shadow maps space. If the z-value of the transformed position is farther than the corresponding value in the shadow map, it is in shadow.



Best regards!
I understand, thank you.

Main reason why i am asking is that i need to render scene from light and it can be pretty slow, if i will render depth from objects, which passes all data again instead only positions of verticles. So it seems, i should use second stream with positions only. Any other way ? :)

I though, i can SetVertexBuffer with somekind of offsets, like ... use only first 12 bytes, then jump over data i don't need to another position element. So i will not send all data to GPU.

DirectX 11, C++

Hi,

- Since you are using a vertex buffer, your data is most likely already in the memory of your graphics card. For large vertex structures there may be some benefit to drop the unused data. For small vertex structures you may not gain any extra speed.

- You should make some performance tests on this matter since this may be premature optimization. Ie. for me it sounds like that you think it is a problem, although the problem may be elsewhere.

There are other ways to optimize your shadows.

- use simpler 3d-models for shadow rendering (especially at distance)
- use static shadow maps for static objects.
- disable shadows for small objects

Cheers!
Just use a NULL pixel shader, set all render targets to NULL, and enable depth writes. You can use a simple vertex shader that only performs vertex position transformations, if you want. You don't need to split your vertex data into multiple streams. When you generate an input layout for a vertex shader, it binds vertex data to the inputs required by the vertex shader. So if you only need positions, then only positions will be fetched from the vertex buffer.
MJP: That i wanted to hear, thank you very much for your information !

DirectX 11, C++

This topic is closed to new replies.

Advertisement