Move skin/material

Posted By: Timothy

Move skin/material - 06/11/10 17:18

Hi,

I want to move one out of 3 skins/materials of my model via u,v.
Since using "my.v += 20;" or "my.u += 20;" moves every 3 skins/materials, I have to find another solution to only move skin2 to a certain direction.
Is this possible and if yes, how?
I already searched in the manual and the forum, but couldn't find anything similar.

Thanks in advance,

Timothy
Posted By: Vinous_Beret

Re: Move skin/material - 06/11/10 17:35

I think this is only possible via SHADERS.
but sorry ,am not a shader programer frown
Posted By: Timothy

Re: Move skin/material - 06/11/10 17:42

Thanks for your answer! I searched and found skin-shift shader in the shader library. Maybe I can modify it to work the way I want it.
Posted By: DJBMASTER

Re: Move skin/material - 06/11/10 18:06

In the shader you want to use the 'entSkin2' (entity skin 2) or 'mtlSkin2' (material skin 2) texture.

The way to scroll/shift the texture is to change the texture coordinates.

In the pixel shader there will probably be something like this...
Code:
return tex2D(sampler,inTex);


...so just modify the 'inTex' parameter...
Code:
float2 coords = float2(inTex.x + 0.5, inTex.y); // example shift in x
return tex2D(sampler,coords);


Posted By: Timothy

Re: Move skin/material - 06/11/10 18:32

Also thank you for your suggestion! But how should I use your given code parts? Are they for a new shader or for an existing one? I only know small parts about the shader basics.

I think I have to define "texture mtlSkin2;", the technique and one pass?
Posted By: DJBMASTER

Re: Move skin/material - 06/11/10 18:49

Here, try this simple shader. Play around with the values of the 'coords' variable to shift the texture...
Code:
const matrix<float,4,4> matWorldViewProj;

texture entSkin2;

sampler map_sampler = sampler_state
{
Texture = <entSkin2>;
};

void ShiftPass_VS
(
in float4 inPos : POSITION0,in float2 inTex : TEXCOORD0,
out float4 outPos : POSITION0,out float2 outTex : TEXCOORD0
)
{
outPos = mul(inPos, matWorldViewProj);
outTex = inTex;
}

float4 ShiftPass_PS(in float2 inTex : TEXCOORD0) : COLOR
{
// play with these values
float2 coords = float2(inTex.x + 0.5,inTex.y);

return tex2D(map_sampler,coords);
}

technique ShaderTechnique 
{
pass ShiftPass
{
VertexShader = compile vs_2_0 ShiftPass_VS();
PixelShader = compile ps_2_0 ShiftPass_PS();
}
}

technique fallback { pass one { } }


Texture coordinates lie within the range 0..1.
Posted By: Timothy

Re: Move skin/material - 06/11/10 19:17

Thank you very very much! smile
© 2024 lite-C Forums