Is it possible to read the depth buffer in a pixel shader? Ie to measure distance from current pixel to depth behind it?
The value would presumably be based on the based on preceding layers - so layers after this a layer group wouldn’t be read
Is it possible to read the depth buffer in a pixel shader? Ie to measure distance from current pixel to depth behind it?
The value would presumably be based on the based on preceding layers - so layers after this a layer group wouldn’t be read
If you do not want to create additional render target, assign the screen position of the geometry to the output color of the pixel shader.
float4 PS(psInput input): SV_Target
{
float4 col = input.posScreen;
return col;
}
ScreenPosAsColor.zip (839 Bytes)
Not quite right - I want to access the depth of the scene ‘rendered’ thus far, ie by other shaders
I’m trying to make soft particles - billboard sprites that fade when close to other objects in the scene
btw I’m trying to stick to forward rendering for this one
unless you’re particles on post pass accessing depth before it actually rendered dosen’t make any sense…
i think what cha can look at called linear depth…
what cha gonna need is project texture coords from your camera on particles, sample depth for each particle and do some kind of function that will return 1 unless your depth - particle distance < threshold
Why does it not make sense? Surely as each shader + geometry is processed the depth buffer is checked and if suitable, written to. If the soft particles shader is the last one in the chain, why can it not read the depth buffer values already written?
Maybe it’s possible with this depthbuffer flags like read only, but I doubt so…
Try here
This is (for now) not easily possible in a single renderer.
You can use read only depth tho, there is an example in the dx11 girlpower
(sm5/misc/readonlydepth)
You can attach the depthbuffer pin out from first render as shader input in that case (since this is allowed as read only flag is set). Since depth stencil is bound as readonly, elements still need to pass depth test.
As to build it in a single renderer, I added that in this commit :
It basically adds a node to rebind depth as readonly, and a shader semantic to allow to read depth.
Please note that build failing is normal for now (there are new tests that fail deploy if a node has no help patch, so as soon as missing help will be added alpha releases will be back to normal).
Thanks Vux
I’ll have a go with the first method.
Good on you for the super fast update! So do you mean I wont be able to compile that at all until there is a help patch?
Compiling works (if you ok to do it yourself), but it will fail unit tests (as it’s now automated that every plugin in dx11 pack must have a help patch), and appveyor don’t accept releases with failed unit test (or I don’t know how to do that ;)
Got ya. Thank for the update!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.