• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
wh1sp3rik

Multiple Depth Rendering

4 posts in this topic

I am trying to find a way, how to optimalize my code and becuase i have to render scene depth from more viewpoints, i though, i can just render scene once and render depths to rendertargets.

I am curious, if it's really possible :)

I have tried to pass buffer with four ViewProjection matrixes, i transformed position with all matrices and in a pixel shader, i just divided positions with W component and store them in rendertarget.

Unfortunately :) every rendertarget contain same data, but different depths only. that's wrong.

I hope, there is a solution for that to avoid multiple scene renderings just becuase i need depth maps :)

Thank you very much
0

Share this post


Link to post
Share on other sites
I don't think that this way would work, or at least has any benefit. The reason is, that the depthbuffer is the fastest way to determine the visibility of single pixels. When you render simultaneously to multiple render targets, then you need to handle the visibility problem on your own. This will render many hardware performance features like early-z-rejection, hi-z etc. obsolete.
0

Share this post


Link to post
Share on other sites
One possibility is to use render target arrays, and use the geometry shader to amplify your geometry and send it to multiple viewports. This is demonstrated in the CubeMapsGS sample in the SDK. However this is generally [i]slower[/i] in terms of GPU performance, due to the geometry shader amplification. But it can decrease CPU overhead, so it can be worth it if you're CPU-bound.
0

Share this post


Link to post
Share on other sites
The reason of your results is because with a VS and a PS you can only select ONE rendertarget to rasterize. So, although you are passing all the ViewProj matrices to the Pixel Shader, you selected only one to perform the rasterization, the others you are passing through TEXCOORDS semantics. So, indeed, you are going to get only different ( and meaningless) dephts in the other render targets and the same image, because you selected to rasterize only one of the Views.

As MJP said, the solution is to rasterize multiple views using the Geometry Shader, you gonna pass all your ViewProj matrices and output each one to a different render target. Just like the CubeMapGS as MJP pointed.

Then you can get all your depths in a single pass. Remember that enabling GS yields in a overhead for the GPU, you have to do some profiling to see if it is worthy.

Regardin Ashaman73 concern, that won't happen in this case, each rendertarget will have a depth test of it's own and there will be no visibility problem. Edited by wiselogi
0

Share this post


Link to post
Share on other sites
Thinking on this more, I came up with an approach you can use UAVs(D3D11) to avoid GS overhead. I never did this approach, so, fellow forum users, pointing pitfall on this would be useful, although I dont see any (yet).

Lets assume you have three depth buffers to compute. The idea here is to perform your own depth buffer operation manually, using only VS and PS.

1. Bind 2 UAVs to the PS stage
2. Make sure any frustum culling you are doing on the CPU is aware and considering all ViewProj's in the single pass now. Disable any backface culling you might be doing at Hull Shader ( if it is enabled ).
2. Pseucode below

[source lang="csharp"]//lets say UAV[1-2] are your UAVs and ViewProj[1-2] are your ViewProj matrices.
//inPos3D is your 3D position that came from VS

//initialize all your UAVs with '1'
//disable early-z culling

PS()
{
float4 pos1 = mul(inPos3D, ViewProj1);
float4 pos2 = mul(inPos3D, ViewProj2);

pos1.xyz /= pos1.w; pos2.xyz /= pos1.w;

float currentDepth1 = sample(pos1.xy,UAV1); //samples UAV1 at screen pos pos1.xy.
//pos1.xy might not be on the screen, in that case you do nothing
float currentDepth2 = sample(pos2.xy,UAV2);

if(currentDepth1 > pos1.z)
{ //write currentDepth1 at UAV1 at pos1.xy}

if(currentDepth2 > pos2.z)
{//write currentDepth2 at UAV2 at pos2.xy}

//do other stuff
}[/source]
At the end, each of the UAVs are going to have your desired depth buffer

The third depth buffer you dont need a UAV, you gonna use the regular pipeline depth test. Edited by wiselogi
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0