Forum

Dx11 mrt

Hey there, it’s me again about dx11.

I don’t seem to be able to render multiple textures with the Renderer (DX11 MRT).

Easiest case: if I tell it to render two textures, but spread no input, that should result in two equal textures, right?
Or is there some way of telling which texture to render to, or something else?

So in this patch:

I’d expect to see two equal previews, but the second texture is empty. The only thing I can change about it is the background color…

I’ll make a helppatch for it once I figure out how it works, I promise! ;)

cheers
dominikkoller

you have to create render targets in pixel shader, if you just want multiple slices use render texture array…
you can look on to this example vvekend-vvorkshops-raymarching-basics there should be some MRT therefore

you have this code in your shader:

float4 PS(vs2ps In): SV_Target

this is where you bind your target to float4
you have to bind it to struct, with PS targets like this:

struct PS_OUT
{ 	float4 color : SV_Target0;
	float4 normal : SV_Target1;
	float4 position : SV_Target2; 
	float4 posView : SV_Target3;
	float4 AO : SV_Target4;
	float  depth : SV_Depth;
};

(you can change number of targets and formats)

then

PS_OUT PS(VS_OUT input)
{

PS_OUT Out;
  
Out.color = float4( col.xyz, 1.0 );
Out.normal = float4 (normal, 1.0);
Out.position = float4 (p,1);
Out.posView = pos;
Out.AO = float4 (AO,AO,AO,1);
Out.depth = pos.z/pos.w;
return Out;
}

this example has 6 targets but you can just use two…
hope it helps

Aaahh coool thanks. Will try it out as soon as I can :D

The trouble with TextureArray for me was that I needed multiple viewports per texture, which it doesn’t have. Is that on purpose? It’d have to have a binsize pin I guess.

Gracias!

hi

it’s not gonna work with mrt, mrt used to render multiple textures from same scene like color, normals, etc… And it’s done by specifying passes on shader.
So if you don’t need normals, or the other stuff, but you need many views or cameras you should still use TextureArray…

You can look on to my old modulo, should be easy to make it work how you need.
P.S. I’m pretty sure there is more elegant way of doing this, but whatever worked…

NumberTexture (DX11.Texture Helper).v4p (10.9 kB)