Copy TEXCOORDS ????

Posted By: Rigoletto

Copy TEXCOORDS ???? - 09/10/05 14:47

Hi,

i wanīt to copy TEXCOORD from my base texture to 2 other textures. But i canīt copy it in a PS (I have to do this in VS):

float2 temp;

temp = In.Base.xy; //<- the compiler wonīt copy it

color = tex2D( sBase, temp );
shadow = tex2D( sShadow, In.Shadow.xy );
alpha = tex2D( sAlpha, temp );
grass = tex2D( sGrass, temp );

same error as

color = tex2D( sBase, In.Base.xy );
shadow = tex2D( sShadow, In.Shadow.xy );
alpha = tex2D( sAlpha, In.Base.xy );
grass = tex2D( sGrass, In.Base.xy );

I got error X4516, that every sample must have an unique texcoord. (With 2.0 PS it works, 1.0 wonīt.)

Is there a special way to really copy a value?
Posted By: ello

Re: Copy TEXCOORDS ???? - 09/10/05 16:14

i dont get your question , exactly?? do you mean this:

Out.texCoord0 =In.texCoord;
Out.texCoord1 =Out.texCoord0;
Posted By: Rigoletto

Re: Copy TEXCOORDS ???? - 09/10/05 16:46

Yes, i do this in my VS because it did not work in PS.
Why canīt use a temp var to copy and apply that in PS?


Code:


struct PS_IN
{
float2 Shadow : TEXCOORD0;
float2 Base : TEXCOORD1;
float2 Alpha : TEXCOORD2;
float2 Grass : TEXCOORD3;
};

struct VS_OUT
{
float4 Pos : POSITION;
float2 Shadow : TEXCOORD0;
float2 Base : TEXCOORD1;
float2 Alpha : TEXCOORD2;
float2 Grass : TEXCOORD3;
};

//simple vertex shader calculates the vertex position and tex coords
VS_OUT vs( float4 Pos : POSITION,
float2 Shadow : TEXCOORD0,
float2 Base : TEXCOORD1,
float2 Alpha : TEXCOORD2,
float2 Grass : TEXCOORD3 )
{
VS_OUT Out = ( VS_OUT ) 0;
Out.Pos = mul( Pos, matWorldViewProj );

Out.Shadow = Shadow;
Out.Base = Base;
Out.Alpha = Base; //using base, must be done cause they have no coords (they not applied to level geo, only at runtime)
Out.Grass = Base;
return Out;
}

float4 ps( PS_IN In ) : COLOR
{
float4 color;
float4 shadow;
float4 alpha;
float4 grass;

color = tex2D( sBase, In.Base.xy );
shadow = tex2D( sShadow, In.Shadow.xy );
alpha = tex2D( sAlpha, In.Alpha.xy );
grass = tex2D( sGrass, In.Grass.xy );

color = lerp( color, grass, alpha );
color = color * shadow;

return color;
}



Posted By: Rhuarc

Re: Copy TEXCOORDS ???? - 09/10/05 18:54

Because PS 1.0-1.3 cannot do dependant texture reads. Basically, you simply cannot change the texture coordinates in the PS, it's just not supported. On the ASM level, all texture reads must be performed on unmodified texture coordinates.

-Rhuarc
Posted By: Specterdragon

Re: Copy TEXCOORDS ???? - 09/13/05 18:07

Quote:


Because PS 1.0-1.3 cannot do dependant texture reads. Basically, you simply cannot change the texture coordinates in the PS, it's just not supported. On the ASM level, all texture reads must be performed on unmodified texture coordinates.

-Rhuarc




Correct me if I'm wrong, but wasn't that issue corrected in PS2.0 and higher? I'm (unfortunatly) not at home and can't look at my shader codes, but it seems I had done something like this with a higher version.
Posted By: Rhuarc

Re: Copy TEXCOORDS ???? - 09/14/05 01:57

Quote:

Quote:


Because PS 1.0-1.3 cannot do dependant texture reads. Basically, you simply cannot change the texture coordinates in the PS, it's just not supported. On the ASM level, all texture reads must be performed on unmodified texture coordinates.

-Rhuarc




Correct me if I'm wrong, but wasn't that issue corrected in PS2.0 and higher? I'm (unfortunatly) not at home and can't look at my shader codes, but it seems I had done something like this with a higher version.




That's what I just said... "Because PS 1.0-1.3 cannot do dependant texture reads. " Thus, implying that 1.4+ all support it
-Rhuarc
© 2024 lite-C Forums