Skip to main content
GameDev.net gamedev.net
🔒 Locked

mutitexture

Started by derek7 Aug 1, 2006 at 7:09 AM 3 replies 1.1k views
Original Post
derek7
derek7
if I use shader to do mutitexture.if the texture coordinate is the same.Can I use only a texture coordinate?
MrFlibble
MrFlibble

Err - not quite sure what you mean.

As far as I remember if you are multi-texturing, on anything above a shader 1.1 card, you will be able to reuse a single set of texture co-ordinates (U,V) to pull information from any number of textures - up to the maximum supported by the card.
MrF.--Code..reboot..code..reboot..sigh!
jollyjeffers
jollyjeffers
As MrFlibble replied - you can do whatever you want with the input data in higher shader models. I've quite often packed 2D position data (or even a 2nd/3rd position coordinate) into declarations marked as TEXCOORDn.

In the SM1 profiles there are restrictions though - but you'll know about it if you get that wrong as the compiler will scream-n-shout at you [wink]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
derek7
derek7
////////////////////////////////////////////////////////////////////////////// // File: ps_alphablend.txt// // Author: Frank Luna (C) All Rights Reserved//// System: AMD Athlon 1800+ XP, 512 DDR, Geforce 3, Windows XP, MSVC++ 7.0 //// Desc: Pixel shader that does multi texturing.//          //////////////////////////////////////////////////////////////////////////////// Globals//sampler BaseTex1;sampler SpotLightTex;sampler StringTex;//// Structures//struct PS_INPUT{    float2 base      : TEXCOORD0;    float2 spotlight : TEXCOORD1;    float2 text      : TEXCOORD2;};struct PS_OUTPUT{    vector diffuse : COLOR0;}; //// Main//PS_OUTPUT Main(PS_INPUT input){    // zero out members of output    PS_OUTPUT output = (PS_OUTPUT)0;    // sample appropriate textures    vector b = tex2D(BaseTex1,      input.base);    vector s = tex2D(SpotLightTex, input.base);    vector t = tex2D(StringTex,    input.base);    // combine texel colors    vector c = b * s + t;    // increase the intensity of the pixel slightly    c += 0.1f;    // save the resulting pixel color    output.diffuse = c;    return output;}


I use the same texcoord input.base to sample, it fail ,said:x4516 can not read from the same texcoord. I cannot use a tex coordinate for 3 texture?
MrFlibble
MrFlibble

Well, if you are getting that error then you are trying to use this pixel shader on a Shader 1.1 card, or have compiled it for Shader 1.1.

Pixel Shader 1.1 had a restriction that a single set of texture co-ordinates could only be used for addressing one texture. This was removed in Pixel Shader 2.0 onwards.

The only way around this is to feed in the texture co-ordinate 3 times via seperate variables. Then use these 3 variables to sample the textures.
MrF.--Code..reboot..code..reboot..sigh!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.