__________1st QUESTION__________
if I use (for example) 5 texture, 4 datail textures and 1 alpha texture,
and I have a texture coordinate for detail textures and a texture coordinate for
alpha texture.
In my mind, I've needed of 5 float4 (for the textures rgba values) and 2 float2
for textures coordinates.....
But many examples tell me, that I need of this struct..
struct PS_INPUT
{
float4 Position : POSITION;
float2 AlphaCoord : TEXCOORD0;
float2 TexCoord0 : TEXCOORD1;
float2 TexCoord1 : TEXCOORD2;
float2 TexCoord2 : TEXCOORD3;
float2 TexCoord3 : TEXCOORD4;
};
Can you explain it?
__________2nd QUESTION__________
look this:
sampler2D Texture2D;
PS_OUTPUT ps_main( in PS_INPUT In )
{
PS_OUTPUT Out;
float4 texture = tex2D(Texture2D, In.TexCoord);
omissis...
}
with this code I fill 'float4 texture' with the RGBA values
of the my texture at pixel with coordinates = TexCoord.....
but Texture2D is an empty variable, and the input 'In.TexCoord' is only a coordinates..
so the question is: how do this code to read these rgba values?
is not better a function like this? float4 texture = tex2D(MYTEXTURE, In.TexCoord);
in this way, if I've more textures with same dimensions, I can use only a TEXCOORD.
__________3rd QUESTION__________
DX Documentation, about D3DTSS_TEXCOORDINDEX say:
..omissis..
Index of the texture coordinate set to use with this texture stage.
You can specify up to eight sets of texture coordinates per vertex.
If a vertex does not include a set of texture coordinates at the specified index,
the system defaults to the u and v coordinates (0,0).
This flag is used only for fixed function vertex processing.
For example,
it should not be used with vertex shaders.
When rendering using vertex shaders, each stage's texture coordinate
index must be set to its default value.
The default index for each stage is equal to the stage index.
Set this state to the zero-based index of the coordinate set for each vertex
that this texture stage uses.
..omissis..
So, this means that , with PS adn VS, I must specify alls the coordinates in the
vertex structure??
in this way:
struct TERRAINVERTEX
{
float x, y, z;
float tu0, tv0, tu1, tv1, tu2, tv2, tu3, tv3, tu4, tv4; // The texture coordinates.
};
#define D3DFVF_TERRAINVERTEX (D3DFVF_XYZ | D3DFVF_TEX5)
and in the end to fill up the buffer
TERRAIN Vertices[4] =
{
x, y, z, tu0, tv0, tu1, tv1, tu2, tv2, tu3, tv3, tu4, tv4,
x, y, z, tu0, tv0, tu1, tv1, tu2, tv2, tu3, tv3, tu4, tv4,
x, y, z, tu0, tv0, tu1, tv1, tu2, tv2, tu3, tv3, tu4, tv4,
x, y, z, tu0, tv0, tu1, tv1, tu2, tv2, tu3, tv3, tu4, tv4
};
but if tu0 = tu1 = tu2 etc etc. does is it a waste of time and memory?
__________4th QUESTION__________
which relation there is between PS declaration and VS declaration??
I.e, if I want this PS struct:
struct PS_INPUT
{
float4 Position : POSITION;
float2 AlphaCoord : TEXCOORD0;
float2 TexCoord0 : TEXCOORD1;
float2 TexCoord1 : TEXCOORD2;
float2 TexCoord2 : TEXCOORD3;
float2 TexCoord3 : TEXCOORD4;
};
my VS struct must be this:
struct VS_INPUT
{
float4 Position : POSITION;
float2 Alpha : TEXCOORD0;
float2 Texture0 : TEXCOORD1;
float2 Texture1 : TEXCOORD2;
float2 Texture2 : TEXCOORD3;
float2 Texture3 : TEXCOORD4;
};
i.e. VertexShader struct MUST be like my vertex struct,
and my pixelshader struc MUST be like my VertexShader struct??
is enough for now....
sorry for these silly questions, but when I search in internet, some clues,
I can discover only sites where someone tell me like to do something,
or sites where someone tell me what shader registry done....
none tell me how works the shader.....
__________LAST QUESTION__________
I've find this:
ps_1_4
////////////////////////////////
// r0: alphamaps
// r1 - r4: textures
////////////////////////////////
// Sample textures
texld r0, t0
texld r1, t1
texld r2, t1
texld r3, t1
texld r4, t1
// Combine textures together based off of their alphamaps
blablablablalbalbalba
blablablablalbalbalba
blablablablalbalbalba
I don't undestand it, but I think that its declaration is more clear
because seem that this shader say:
Hello world! I've 5 textures, the first with coordinates t0, the others with coordinates t1