2 registered members (AndrewAMD, Akow),
1,371
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
fade between two materials
#400279
04/28/12 05:51
04/28/12 05:51
|
Joined: Jan 2010
Posts: 23
Darkmax
OP
Newbie
|
OP
Newbie
Joined: Jan 2010
Posts: 23
|
Hi i don't know if this have been answered before, but i search it in the forums and i haven't found anything.
I have a model with a texture and i want it to animate a fade in with another texture, i tried with ent_morphskin but that change all the texture at once, and i want some more smooth.
Also i though to make several textures with the transition, but there must be a better way because this needs too much textures to have a good smooth fade in of the the second texture..
Please if some one has a good idea of how to pull this off i will be grateful.
Last edited by Darkmax; 04/28/12 05:52.
|
|
|
Re: fade between two materials
[Re: Darkmax]
#400324
04/28/12 20:18
04/28/12 20:18
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
A shader that blends between the first and the second skin could look like this (where the important part obviously is "lerp(...)"): Effect:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecViewDir;
float4 vecSkill41;
texture entSkin1;
texture entSkin2;
sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Wrap;
AddressV = Wrap;
};
sampler ColorMapSampler2 = sampler_state
{
Texture = <entSkin2>;
AddressU = Wrap;
AddressV = Wrap;
};
void BlendVS(
in float4 InPos: POSITION,
in float3 InNormal: NORMAL,
in float2 InTex: TEXCOORD0,
out float4 OutPos: POSITION,
out float2 OutTex: TEXCOORD0,
out float3 OutNormal: TEXCOORD1)
{
OutPos = mul(InPos, matWorldViewProj);
OutNormal = mul(InNormal, matWorld);
OutTex = InTex;
}
float4 BlendPS(
in float2 InTex: TEXCOORD0,
in float3 InNormal: TEXCOORD1): COLOR
{
float4 Color = tex2D(ColorMapSampler, InTex);
float4 Color2 = tex2D(ColorMapSampler2, InTex);
float Diffuse = saturate(dot(normalize(InNormal),-vecViewDir));
Color = lerp(Color,Color2,vecSkill41.x);
return Color*(Diffuse*0.5+0.5);
}
technique DiffuseTechnique
{
pass P0
{
VertexShader = compile vs_2_0 BlendVS();
PixelShader = compile ps_2_0 BlendPS();
}
}
lite-C code:
MATERIAL* mat_texture_blend =
{
effect = "texture_blend.fx";
flags = AUTORELOAD;
}
action object()
{
my.material = mat_texture_blend;
while(1)
{
my.skill41 = floatv(sinv(total_frames)*0.5+0.5);
wait(1);
}
}
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: fade between two materials
[Re: Superku]
#401983
05/28/12 08:17
05/28/12 08:17
|
Joined: Jan 2010
Posts: 23
Darkmax
OP
Newbie
|
OP
Newbie
Joined: Jan 2010
Posts: 23
|
Hi sorry for the late respond, but i tried what you told me but is doing the same here a three pictures of what is happening and the settings that i have. Normal image fade in image material setup If you can help me i would appreciated it.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|