Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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 (Akow, SBGuy), 1,423 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
change smoothly between textures #96405
10/29/06 12:58
10/29/06 12:58
Joined: Sep 2006
Posts: 36
Ger
F
Fussfoehn Offline OP
Newbie
Fussfoehn  Offline OP
Newbie
F

Joined: Sep 2006
Posts: 36
Ger
Hi, i´m looking for a shader which changes smoothly between two or more textures depending on a skill of the entity. for example like a chameleon for camouflage.
Hope you can help me

Hi Allemiteinander ich bin auf der suche nach nem shader der weich zwischen mehreren texturen wechseln kann abhängig von einem oder mehreren skills der entity. Also wenn man wie beim multitex terrain mehrere texturen übereinanderlegt aber den Alphawert der Texturen während dem spielverlauf verändern kann. Wie wenn sich ein Chamäleon grade anpasst.
Hoffe ihr könnt mir helfen

Re: change smoothly between textures [Re: Fussfoehn] #96406
10/30/06 13:37
10/30/06 13:37
Joined: Sep 2006
Posts: 36
Ger
F
Fussfoehn Offline OP
Newbie
Fussfoehn  Offline OP
Newbie
F

Joined: Sep 2006
Posts: 36
Ger
Nobody can help me? :/

Kann mir keiner helfen? oder ist das unverständlich wie ich es beschrieben habe ?!

Re: change smoothly between textures [Re: Fussfoehn] #96407
10/30/06 13:40
10/30/06 13:40
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
ich hab keinen shader parat, aber generell kannst Du irgendeinen nehmen und folgendes einbauen

float4 tex1 = tex2D(textur1, In.texCoord);
float4 tex2 = tex2D(textur2, In.texCoord);
float4 blended = lerp(tex1,tex2,blendfactor);// wobei blendfactor z..b. entSkill41.x sein kann und somit vom entity skill41 gesteuert wird

Re: change smoothly between textures [Re: ello] #96408
10/30/06 21:07
10/30/06 21:07
Joined: Sep 2006
Posts: 36
Ger
F
Fussfoehn Offline OP
Newbie
Fussfoehn  Offline OP
Newbie
F

Joined: Sep 2006
Posts: 36
Ger
k thx das klingt schon gut... nur dafür muss man doch dann nen pixel shader benutzen oder?

hab nu mal folgenden shader für die entity... wie bau ich das jetzt da ein?.. also dass man den Alphawert von s_blueTex von vecSkill41.x anhängig macht?



material anpassen_mat
{

effect=
"

float4x4 matTerrainTexSize = {1.0, 0.0, 0.0 ,0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};

float4 vecLight;
float4 vecSkill41;
float ambientLightFactor = 0.05;

Texture entSkin1;
Texture entSkin2;

sampler s_redTex = sampler_state
{
Texture = (entSkin1);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;

MipMapLodBias=-0.2;
};

sampler s_blueTex = sampler_state
{
Texture = (entSkin2);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;

MipMapLodBias=-0.2;
};



technique technique_one
{

pass p0
{
Sampler[0] = (s_redTex);

AlphaBlendEnable = False;
AlphaTestEnable = False;
DitherEnable = True;
zWriteEnable = True;
zEnable = True;
Lighting=True;

Ambient = mul(vecLight, ambientLightFactor);

TextureTransformFlags[0] = Count2;
TexCoordIndex[0] = 1;

ColorOp[0] = Modulate2x;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;
AlphaOp[0] = Disable;


}


pass p1
{
Sampler[0] = (s_blueTex);

AlphaBlendEnable = False;
AlphaTestEnable = False;
DitherEnable = True;
zWriteEnable = True;
zEnable = True;
Lighting=True;

Ambient = mul(vecLight, ambientLightFactor);

TextureTransformFlags[0] = Count2;
TexCoordIndex[0] = 1;

ColorOp[0] = Modulate2x;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;
AlphaOp[0] = Disable;
}
}


";
}


ich weiss manche Zeilen sind da überflüssig, aber ich als shadernewb bin froh das ich den so hinbekomme hab^^

Re: change smoothly between textures [Re: ello] #96409
11/04/06 20:35
11/04/06 20:35
Joined: Oct 2002
Posts: 150
Prince Edward Island, Canada
Nagashi Offline
Member
Nagashi  Offline
Member

Joined: Oct 2002
Posts: 150
Prince Edward Island, Canada
Here is what I have come up with based on this idea. Unfortunaly I'm stuck when it comes to passing the needed value to the shader…

The shader it’s self works well if you replace “mtlSkill1” in the pixel shader output, with a value like 0.5 (must be between 1 and 0) but to do smooth transitions you would need to set this dynamically out side the shader and pass it. As ello hase metioned above.

So the big question is dose any one know how I would pass a value between 1 and 0 to a shader, again for example the number 0.5

Here is the shader
Code:

float4x4 matWorldViewProj;

float4 mtlSkill1;

struct VS_OUTPUT
{
float4 Pos: POSITION;
float2 Txr1: TEXCOORD0;
float2 Txr2: TEXCOORD1;
float2 Txr3: TEXCOORD2;
};

VS_OUTPUT mainVS(
float4 inPos: POSITION,
float2 Txr1: TEXCOORD0
)
{
VS_OUTPUT Out;

// Output our transformed and projected vertex
// position and texture coordinate
Out.Pos = mul(inPos,matWorldViewProj);
Out.Txr1 = Txr1;
Out.Txr2 = Txr1;
Out.Txr3 = Txr1;

return Out;
}

texture entSkin1;

sampler Texture0 = sampler_state
{
Texture = <entSkin1>;
};

texture entSkin2;

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

texture entSkin3;

sampler Texture2 = sampler_state
{
Texture = <entSkin3>;
};

float4 mainPS(float2 inTxr1: TEXCOORD0, float2 inTxr2: TEXCOORD1, float2 inTxr3: TEXCOORD2) : COLOR
{
// Output
float4 color1 = tex2D(Texture1,inTxr2);
float4 color2 = tex2D(Texture2,inTxr3);
float4 blended = lerp(color1,color2,mtlSkill1);// uses a value between 1 and 0, for example 0.5

return tex2D(Texture0,inTxr1)*blended;
}

//--------------------------------------------------------------//
// Technique Section for MyEffectGroup
//--------------------------------------------------------------//
technique MyEffect
{
pass Pass_0
{
VertexShader = compile vs_1_1 mainVS();
PixelShader = compile ps_1_1 mainPS();
}

}


Any help would be greatly appreciated

Cheers


No rest for the wicked.
__________________________

Ironbound Studios
__________________________
Re: change smoothly between textures [Re: Nagashi] #96410
11/04/06 20:44
11/04/06 20:44
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Just set material.skill1 = value;, or set it in the material definition (both in cscript). Change the float4 to a float (it's a single value), and try 'mtlskill1' instead of 'mtlSkill1' (capital letters) if it still doesn't work (not sure which one it is, but it doesn't work if you use the wrong one).

Re: change smoothly between textures [Re: Excessus] #96411
11/04/06 21:12
11/04/06 21:12
Joined: Oct 2002
Posts: 150
Prince Edward Island, Canada
Nagashi Offline
Member
Nagashi  Offline
Member

Joined: Oct 2002
Posts: 150
Prince Edward Island, Canada
I have tried this with both float and float4 I'm setting the value as you would expect like this;

Code:


material tester
{
//skill1 = 0.5; also tried setting it here.
effect = "ati.fx";
}

action test_shader
{
tester.skill1 = 0.5;
my.material = tester;
}




This does not work for me, I have also just tried changing the case to mtlskin1 in stead of mtlSkin1 though I believe it should be mtlSkin1 not the lower case. I should also mention the problem seems to be in the shader it’s self since the above method dose pass a value along to the shader… the problem is any thing above 0 is treated as 1 so there is no distinction between 0.1, and 1. I believe the problem lies in calling the variable as a float… for which I have no solution.

cheers


No rest for the wicked.
__________________________

Ironbound Studios
__________________________
Re: change smoothly between textures [Re: Nagashi] #96412
11/04/06 21:18
11/04/06 21:18
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Ah, forgot that: use the float(var) instruction. I think this means you can't set them in the material definition, but have to do it somewhere else in your code:
material.skill1 = float(0.5);

This is from the manual:
Quote:

The skills are _not_ automatically converted to float. This has to be done by C-Script through float(), floatd() or floatr() instructions.




Re: change smoothly between textures [Re: Excessus] #96413
11/04/06 21:46
11/04/06 21:46
Joined: Oct 2002
Posts: 150
Prince Edward Island, Canada
Nagashi Offline
Member
Nagashi  Offline
Member

Joined: Oct 2002
Posts: 150
Prince Edward Island, Canada
Thanks for the quick replies… I tired this as well… it won’t work ether; I think the problem is that changing the value to a float breaks the shader. Though I have tried using int instead of float neither seem to work.

cheers


No rest for the wicked.
__________________________

Ironbound Studios
__________________________
Re: change smoothly between textures [Re: Nagashi] #96414
11/04/06 21:56
11/04/06 21:56
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Hmm, the following code is from a shader I've made and it works:
Code:

// C-script:
var SunColor[4] = 0.8, 0.8, 0.7, 1.0;

material* TempMaterial;
function SetMtlSunColor(mtrl)
{
TempMaterial = mtrl;
TempMaterial.skill1 = float(SunColor[0]);
TempMaterial.skill2 = float(SunColor[1]);
TempMaterial.skill3 = float(SunColor[2]);
TempMaterial.skill4 = float(SunColor[3]);
}

..
SetMtlSunColor(mtlMatte_20_H);
SetMtlSunColor(mtlShiny1_20_H);

// HLSL:
const half4 vecSkill1;
..



Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

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