Jump to content

  • Log In with Google      Sign In   
  • Create Account


Render Depth Only


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
5 replies to this topic

#1 wh1sp3rik   Members   -  Reputation: 248

Like
0Likes
Like

Posted 24 May 2012 - 11:43 PM

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++


Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2168

Like
0Likes
Like

Posted 25 May 2012 - 12:42 AM

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!

Edited by kauna, 25 May 2012 - 01:21 AM.


#3 wh1sp3rik   Members   -  Reputation: 248

Like
0Likes
Like

Posted 25 May 2012 - 01:03 AM

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++


#4 kauna   Crossbones+   -  Reputation: 2168

Like
0Likes
Like

Posted 25 May 2012 - 01:46 AM

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!

#5 MJP   Moderators   -  Reputation: 10280

Like
1Likes
Like

Posted 25 May 2012 - 02:29 PM

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.

#6 wh1sp3rik   Members   -  Reputation: 248

Like
0Likes
Like

Posted 17 June 2012 - 10:14 AM

MJP: That i wanted to hear, thank you very much for your information !

DirectX 11, C++





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.



PARTNERS