2 registered members (AbrahamR, AndrewAMD),
1,278
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
PS 1.1 water - Adjusting RGB during runtime
#53154
08/23/05 15:34
08/23/05 15:34
|
Joined: Jun 2003
Posts: 1,017 Germany
Thomas_Nitschke
OP
Senior Developer
|
OP
Senior Developer
Joined: Jun 2003
Posts: 1,017
Germany
|
Hi@all!Ok I've got the following code (by Steempipe) working and set to go: Code:
technique drawWater { pass p0 { AlphaBlendEnable = true; ZwriteEnable = true; ZEnable = true; Sampler[0] = (s_Bump); Sampler[3] = (s_Cube); PixelShaderConstant[0] = float4(0.3,0.4,vecSkill1.x,0.75); VertexShader = compile vs_1_1 WaterBump_VS(); PixelShader = asm { ps.1.1 tex t0 texm3x3pad t1, t0_bx2 texm3x3pad t2, t0_bx2 texm3x3vspec t3, t0_bx2 mul r0, t3, c0 }; } }
The question now is: How could I tell the pixelshader to accept vecSkill1 - 4 in the PixelShaderConstant[0] declaration? Strangely, it actually does accept the skills, but only one at a time, be it r,g,b or alpha. Any of the shader gurus who knows how to do this, any help is appreciated...
Formerly known as The Matrix - ICQ 170408644
I've been here for much longer than most people think. So where's my "Expert" status?
|
|
|
Re: PS 1.1 water - Adjusting RGB during runtime
[Re: ello]
#53156
08/23/05 19:05
08/23/05 19:05
|
Joined: Jun 2003
Posts: 1,017 Germany
Thomas_Nitschke
OP
Senior Developer
|
OP
Senior Developer
Joined: Jun 2003
Posts: 1,017
Germany
|
Thx for your reply, I'll give it a try. I'll let you know if it doesn't work, however EDIT: Oops, nearly forgot to ask... how then can I access these by script? In C-Script, I can only tell him mat_blabla.skill1 = float(blubb), but how would I make him understand I want to change the x,y,z and w components? Ok here goes: ERROR invalid subscript 'w'.. just in case you didn't notice, I'm nOOb to shaders
Last edited by The Matrix; 08/23/05 19:10.
Formerly known as The Matrix - ICQ 170408644
I've been here for much longer than most people think. So where's my "Expert" status?
|
|
|
Re: PS 1.1 water - Adjusting RGB during runtime
[Re: ello]
#53158
08/24/05 11:22
08/24/05 11:22
|
Joined: Jun 2003
Posts: 1,017 Germany
Thomas_Nitschke
OP
Senior Developer
|
OP
Senior Developer
Joined: Jun 2003
Posts: 1,017
Germany
|
Yep just tried it, it's not working though. He keeps telling me "invalid subscript a" which seems logical to me because vecSkill1 is declared as float3, so, even from what I as a noOb do actually understand, it can't contain 4 values, can it?
Concerning vecSkill41-44, I know about those, but whyever only the value of vecskill41 seems to be passed to the shader, the rest is just ignored, no matter to what values I set them...
Formerly known as The Matrix - ICQ 170408644
I've been here for much longer than most people think. So where's my "Expert" status?
|
|
|
Re: PS 1.1 water - Adjusting RGB during runtime
[Re: ello]
#53160
08/25/05 13:54
08/25/05 13:54
|
Joined: Jun 2003
Posts: 1,017 Germany
Thomas_Nitschke
OP
Senior Developer
|
OP
Senior Developer
Joined: Jun 2003
Posts: 1,017
Germany
|
Jap das is nett! I'll post the code here just in case anyone else wants to have a go on it! Code:
material mat_water { power = 10; ambient_red = 0; ambient_green = 0; ambient_blue = 0; diffuse_red = 200; diffuse_blue = 200; diffuse_green = 200; albedo = 50; specular_red = 0; specular_green = 0; specular_blue = 0; emissive_red = 0; emissive_blue = 0; emissive_green = 0; skin1 = sfx_waterBump0; skin2 = sfx_cubemap0; flags = tangent; event = eff_initWater; }
function eff_initWater() { bmap_to_cubemap(mtl.skin2); //bmap_to_mipmap(mtl.Skin1); return(false); }
water.fx:
float4x4 matWorldViewProj; float4x4 matWorld; float4x4 matWorldView; float3 vecViewPos; float3 vecSkill41; float3 vecSkill1; float4 vecFog; Texture mtlSkin1; Texture mtlSkin2;
sampler s_Bump = sampler_state { Texture = (mtlSkin1); MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = WRAP; AddressV = WRAP; }; sampler s_Cube = sampler_state { Texture = (mtlSkin2); MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; }; struct VS_IN { float4 Pos: POSITION; float3 Normal: NORMAL; float2 Bump: TEXCOORD0; float3 Tangent: TEXCOORD1; }; struct VS_OUT { float4 Pos: POSITION; float Fog: FOG; float2 Bump: TEXCOORD0; float4 TanToCube0: TEXCOORD1; float4 TanToCube1: TEXCOORD2; float4 TanToCube2: TEXCOORD3; }; VS_OUT WaterBump_VS(VS_IN IN) { VS_OUT Out; Out.Pos = mul(IN.Pos, matWorldViewProj); float2 WaveDir; WaveDir.x = 5*IN.Bump.x; WaveDir.x += 0.01*vecSkill41.x; WaveDir.y = 5*IN.Bump.y; WaveDir.y += 0.01*vecSkill41.x; Out.Bump = WaveDir.xy; float3x3 ObjToTan; ObjToTan[0] = IN.Tangent, ObjToTan[1] = cross(IN.Normal, IN.Tangent); ObjToTan[2] = 5*IN.Normal; Out.TanToCube0.xyz = mul(ObjToTan, matWorld[0].xyz); Out.TanToCube1.xyz = mul(ObjToTan, matWorld[1].xyz); Out.TanToCube2.xyz = mul(ObjToTan, matWorld[2].xyz); float3 PositionWorld = mul(IN.Pos, matWorld); float3 ViewerDir = normalize(vecViewPos - PositionWorld); Out.TanToCube0.w = ViewerDir.x; Out.TanToCube1.w = ViewerDir.y; Out.TanToCube2.w = ViewerDir.z; float ofog = 1 - (distance(PositionWorld, vecViewPos) - vecFog.x) * vecFog.z; Out.Fog = ofog; return Out; } technique drawWater { pass p0 { AlphaBlendEnable = true; ZwriteEnable = true; ZEnable = true; Sampler[0] = (s_Bump); Sampler[3] = (s_Cube); PixelShaderConstant[0] = {0.3,0.3,0.4,0.50}; //PixelShaderConstant[0] = float4(vecSkill1.r,vecSkill1.g,vecSkill1.b,vecSkill1.a); VertexShader = compile vs_1_1 WaterBump_VS(); PixelShader = asm { ps.1.1 tex t0 texm3x3pad t1, t0_bx2 texm3x3pad t2, t0_bx2 texm3x3vspec t3, t0_bx2 mul r0, t3, c0 }; } } technique fallback { pass p0 { Texture[0] = <mtlSkin1>; } }
Last edited by The Matrix; 08/25/05 13:56.
Formerly known as The Matrix - ICQ 170408644
I've been here for much longer than most people think. So where's my "Expert" status?
|
|
|
Re: PS 1.1 water - Adjusting RGB during runtime
[Re: Thomas_Nitschke]
#53161
08/26/05 09:24
08/26/05 09:24
|
Joined: Oct 2002
Posts: 8,939 planet.earth
ello
Senior Expert
|
Senior Expert
Joined: Oct 2002
Posts: 8,939
planet.earth
|
PixelShaderConstant[0] = float4(vecSkill41.r,vecSkill41.g,vecSkill41.b,1);
and what you have to do is to create an action for your model and set the skills there (my.skill41=float(... and so on)
i just did a quick test using random numbers and it works fine
and btw, you didnt assign the fx-file to the material (effect="water.fx";)
Last edited by ello; 08/26/05 09:29.
www.earthcontrol.dequoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
|
|
|
Re: PS 1.1 water - Adjusting RGB during runtime
[Re: ello]
#53162
08/26/05 15:23
08/26/05 15:23
|
Joined: Jun 2003
Posts: 1,017 Germany
Thomas_Nitschke
OP
Senior Developer
|
OP
Senior Developer
Joined: Jun 2003
Posts: 1,017
Germany
|
Yep, that works! Thanks a lot Is there a way to do this with the alpha value, too? If I try using vecSkill1.a or something of the like, it keeps telling me "invalid subscript: a"... This is not too important, though. BTW, I did assign the FX file, just I did it with a helper function and not directly.
Formerly known as The Matrix - ICQ 170408644
I've been here for much longer than most people think. So where's my "Expert" status?
|
|
|
|