Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 30 Jul 2011
Offline Last Active Mar 16 2013 07:04 PM

Posts I've Made

In Topic: Geometry shader, but why ?

26 November 2012 - 01:44 PM

This tutorial does exactly what you are looking for:


It shows how to build any parametric surface entirely in the GPU using the tessellator in one pass.

In Topic: Multiple Depth Rendering

05 July 2012 - 04:47 PM

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 cullingPS(){ 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.

In Topic: Multiple Depth Rendering

05 July 2012 - 03:33 PM

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.

In Topic: Creating Terrain

09 June 2012 - 06:27 PM

@DJTN: Any example on creating a Shader file to blend textures on the terrain?

Riemer does exactly this on one of his tutorials. Take a look.


In Topic: Math for computing relative sun direction

09 June 2012 - 04:36 PM

isnt this function what are you looking for? This rotates (x,y,z) about the axis (u,v,w) by the angle θ.

f(x,y,z,u,v,w,θ) =

Posted Image