Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Akow), 1,371 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
fade between two materials #400279
04/28/12 05:51
04/28/12 05:51
Joined: Jan 2010
Posts: 23
D
Darkmax Offline OP
Newbie
Darkmax  Offline OP
Newbie
D

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] #400291
04/28/12 10:53
04/28/12 10:53
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Normally you would use a shader for this purpose. Does your version support shaders?


"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] #400318
04/28/12 18:49
04/28/12 18:49
Joined: Jan 2010
Posts: 23
D
Darkmax Offline OP
Newbie
Darkmax  Offline OP
Newbie
D

Joined: Jan 2010
Posts: 23
my version of gamestudio or what do you mean? i have gamestudio a7, but i'm not very good with shader programming, so this the only way?

Re: fade between two materials [Re: Darkmax] #400321
04/28/12 19:22
04/28/12 19:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
What's your Gamestudio edition, that means do you own the commercial or pro edition? If yes, a shader will be the best (and even the easiest) solution.

If not, you can use pixel_... instructions to blend the two textures together (have a look at bmap_for_entity, too).


"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] #400322
04/28/12 19:43
04/28/12 19:43
Joined: Jan 2010
Posts: 23
D
Darkmax Offline OP
Newbie
Darkmax  Offline OP
Newbie
D

Joined: Jan 2010
Posts: 23
ok thanks, its commercial.

I will check those methods

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 Offline
Senior Expert
Superku  Offline
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:
Code:
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:
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] #400327
04/28/12 20:46
04/28/12 20:46
Joined: Jan 2010
Posts: 23
D
Darkmax Offline OP
Newbie
Darkmax  Offline OP
Newbie
D

Joined: Jan 2010
Posts: 23
wow this just works flawless, thank you very much.

just a quick question, if the model has two texture, and i just want to change one of them, there is a way to just change that texture and leave the other one unchanged or i need to have the model in two separate mdl files and just change the mdl that i want.

For example i have a head and i want to change the skin but leave the eyes untouched, because i tried with you shader and change also the texture of the eyes.

By the way thank you very much

Re: fade between two materials [Re: Darkmax] #400333
04/28/12 21:45
04/28/12 21:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
It should work to create a "material setup" for the eye skin in the Skin Editor/ Settings. This way, the assignment "my.material = mat_texture_blend;" does not have an effect on the eyes.


"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
D
Darkmax Offline OP
Newbie
Darkmax  Offline OP
Newbie
D

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.

Re: fade between two materials [Re: Darkmax] #401996
05/28/12 13:57
05/28/12 13:57
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Hm then you have to check "Effect Setup" and assign a default shader for the eyes, that works.


"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

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1