0
\$\begingroup\$

Hi I am not very good with writing shaders. How would I make a shader that simply supports 2 texture coordinates so I can load up 2 different textures to be used at the same time but on different parts of my world? Right now I have 1 texturecoord variable setup and I load a texture through it using GraphicsDevice->SetTexture(0, &Texture); and making sure my VertexDeclaration and FVF both support that, but how can I add a second texture to this? Would I make it so that I make separate coordinates and link the coordinates to a texture? How would I write that?

\$\endgroup\$
1
  • \$\begingroup\$ You want to use one texture to control the other two (splat mapping), you will have a hard time to create assets if you go with a too home made solution. just my 2 cents ;-) ps. you might want to check out this link gamedev.stackexchange.com/questions/19930/… \$\endgroup\$
    – Valmond
    Aug 19, 2012 at 11:29

1 Answer 1

1
\$\begingroup\$

render code:

GraphicsDevice->SetTexture(0, &Texture);
GraphicsDevice->SetTexture(1, &SecondTexture);

hlsl declaration:

sampler Texture0 : register(s0);
sampler Texture1 : register(s1);

Use the vertices's other coordinates to sample Texture1.

\$\endgroup\$
7
  • \$\begingroup\$ thank you for that but could you tell me how I would write to the pixel shader that? I currently have Out.Color = tex2D(Tex0, In.Texture); How would I make it do a second texture? Would I just add Out.Color = tex2D(Tex1, In.Texture2); ? \$\endgroup\$
    – dvds414
    Aug 19, 2012 at 22:13
  • \$\begingroup\$ I tried just adding under my Out.Color = tex2D(Tex0, In.Texture) Out.Color = tex2D(Tex1, In.Texture2) and it only payed attention to the last one (for obvious reasons). So how would I get it to use both samplers to output as you explained? \$\endgroup\$
    – dvds414
    Aug 19, 2012 at 23:59
  • \$\begingroup\$ Well, you would need to mix the two colors into a single output. There are literally infinite ways to do that. What are you trying to achieve with your two different textures? Perhaps you should post a second question, now that you have your textures available in your shader. \$\endgroup\$ Aug 20, 2012 at 1:19
  • \$\begingroup\$ It would be nice just to get my answer here now that I have found someone that knows what they are talking about so could you please tell me how I can get the outputs into 1 thing? \$\endgroup\$
    – dvds414
    Aug 20, 2012 at 1:44
  • 1
    \$\begingroup\$ I was trying to tell you that you haven't given enough information for me to answer your followup question. What are you trying to accomplish with your two textures? I think the best place for you to explain that would be another question post. \$\endgroup\$ Aug 20, 2012 at 1:50

You must log in to answer this question.

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