Forum

How to setup compute shader 3d to write volume texture?

hi all,

I want to precompute data and save it in a volume texture, from which my objects later can sample, using their 3D position. How do I setup the dispatch, and how do I convert from the Renderer(dx11 Buffer) to DX11 Texture 3d?

Hi, so you use Render (DX11.Volume)

You have to Write to

RWTexture3D<float4> RWDistanceVolume : BACKBUFFER;

your dispatch would use XYZ Threads

RWDistanceVolume[tid]= …

if you need preview you do it like so:

Texture3D texVOL <string uiname="Volume";>;
SamplerState g_samLinear : IMMUTABLE
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = CLAMP;
    AddressV = CLAMP;
	AddressW = CLAMP;
};
texVOL.Sample(g_samLinear,float3(In.TexCd.xy,Z) 

you can check FakeDF example in instance noodles… I’ve some other ones but could not find them…