0
\$\begingroup\$

Very simple question. With C++/Direct9, I'm creating a texture as RenderTarget with a full screen quad, creating a scene, setting a HLSL pixel shader, copying the image and then call Present.

1) How does the shader's input texture get defined? Does it get configured automatically, and if so how? Let's take this very basic sample shader.

sampler2D TexSampler : register(S0);

float4 main(float2 uv : TEXCOORD) : COLOR
{
    float4 color = tex2D(TexSampler, uv);
    return float4(1 - color.rgb, color.a);
}

2) Where in the chain does the shader's magic get applied? Somehow it's not being applied and I don't know where to look.

3) What about shaders that take 2 textures as input, how do I configure the input?

sampler s0 : register(s0);
sampler s1 : register(s1);
float4 p0 :  register(c0);
float2 p1 :  register(c1);

#define width  (p0[0])
#define height (p0[1])
#define px (p1[0])
#define py (p1[1])

When creating the pixel shader, I get a PixelConstantTable that allows me to define C0 and C1, and how do I feed in all the other information?

I'm trying to make the question as basic as possible to get a quality answer. I found PSSetShaderResources in DX11 which seems to be getting close but what's the equivalent in DX9?

Thanks!

Edit: Is it possible that DirectX9 doesn't support passing multiple textures in such a way, and that DirectX11 would be required?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Answer: IDirect3DDevice9::SetTexture

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .