Archive 17/01/2023.

How to use two textures in one shader?

spwork

I’m a raw recruit with shaders,i want use two input textures to generate a output,like this:

<renderpath>
    <rendertarget name="MyTarget" tag="MyPostProcess" sizedivisor="1 1" format="rgba" filter="true" />
    <command type="quad" tag="MyPostProcess" vs="MyPostProcess" ps="MyPostProcess" output="viewport">
	<texture unit="diffuse" name="viewport" />
	<texture unit="diffuse" name="d:/mytexture.png" />
    </command>
</renderpath>

And how to fix this shader to make it generate superimposed values ​​for two picture colors?

void VS(float4 iPos : POSITION,
    out float2 oScreenPos : TEXCOORD0,
    out float4 oPos : OUTPOSITION)
{
    float4x3 modelMatrix = iModelMatrix;
    float3 worldPos = GetWorldPos(modelMatrix);
    oPos = GetClipPos(worldPos);
    oScreenPos = GetScreenPosPreDiv(oPos);
}

void PS(float2 iScreenPos : TEXCOORD0,
    out float4 oColor : OUTCOLOR0)
{
    oColor = Sample2D(DiffMap, iScreenPos);
}
Eugene

You cannot bind multiple textures to one texture unit.
Find another one (e.g. normal map) that that you don’t need for anything else.
Then, sample both and do whatever you want.