1 registered members (TipmyPip),
18,574
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Normalmapping (in development)
[Re: PHeMoX]
#117191
03/26/07 04:27
03/26/07 04:27
|
Joined: Jul 2000
Posts: 28,024 Frankfurt
jcl

Chief Engineer
|

Chief Engineer
Joined: Jul 2000
Posts: 28,024
Frankfurt
|
Phemox: You need the current Gamestudio version for this shader. MaxF: Here's an indoor version that supports the static environment light and one dynamic light: Code:
MATERIAL mtl_bumpspecular { effect= " #include <transform> #include <fog> #include <pos> #include <normal> #include <tangent> #define INDOOR #ifdef INDOOR #include <light> #else float4 vecSunDir; float4 vecSunColor; #endif float4 vecLight;
texture entSkin1; // texture texture entSkin2; // normal map const float facAmbient = 0.2; // factors to play with const float facBump = 0.5; const float facSpecular = 2.0;
sampler sBaseTex = sampler_state { Texture = <entSkin1>; }; sampler sBump = sampler_state { Texture = <entSkin2>; };
struct out_specular { float4 Pos: POSITION; float Fog: FOG; float4 Color: COLOR0; float4 Ambient: COLOR1; float2 Tex: TEXCOORD0; float2 Bump: TEXCOORD1; float3 Light: TEXCOORD2; float3 Halfway:TEXCOORD3; };
out_specular vs_specular( in float4 inPos: POSITION, in float3 inNormal: NORMAL, in float2 inTex: TEXCOORD0, in float3 inTangent: TEXCOORD2) { out_specular Out;
Out.Pos = DoTransform(inPos); Out.Tex = inTex; Out.Bump = inTex; // different coordinate sets required for ps_1_1 Out.Ambient = facAmbient*vecLight; Out.Fog = DoFog(inPos);
float3 P = DoPos(inPos); #ifdef INDOOR float3 LDir = normalize(vecLightPos[0].xyz - P); float fDist = length(vecLightPos[0].xyz - P)/vecLightPos[0].w; if (fDist < 1.f) fDist = 1.f - fDist; else fDist = 0.f; Out.Color = facSpecular*fDist*vecLightColor[0]; #else float3 LDir = -vecSunDir; Out.Color = facSpecular*vecSunColor; #endif CreateTangents(inNormal,inTangent); // transform the output values into the 0..1 range Out.Light = facBump*DoTangent(LDir) * 0.5 + 0.5;
float3 EyeDir = normalize(vecViewPos - P) + LDir; Out.Halfway = DoTangent(EyeDir) * 0.5 + 0.5;
return Out; }
float4 ps_specular(out_specular In): COLOR { float4 base = tex2D(sBaseTex,In.Tex); float3 bumpNormal = tex2D(sBump,In.Bump); float light = saturate(dot(In.Halfway*2 - 1,bumpNormal*2 - 1)); light *= light; light *= light; light *= light; light *= light; light += saturate(dot(In.Light*2 - 1,bumpNormal*2 - 1)); return base * (In.Ambient + light*In.Color); }
technique specular { pass One { VertexShader = compile vs_1_1 vs_specular(); PixelShader = compile ps_1_1 ps_specular(); } }
"; }
|
|
|
Re: Normalmapping (in development)
[Re: jcl]
#117193
03/26/07 14:55
03/26/07 14:55
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
Quote:
Phemox: You need the current Gamestudio version for this shader.
Mmm, current version, which one would that be? A6.50.6? Because I thought I had installed that one, anyways I'll re-update then, thanks! 
Cheers
|
|
|
Re: Normalmapping (in development)
[Re: jcl]
#117194
03/27/07 04:10
03/27/07 04:10
|
Joined: Jul 2002
Posts: 1,364 Minbar
MaxF
OP
Serious User
|
OP
Serious User
Joined: Jul 2002
Posts: 1,364
Minbar
|
Hi JCL  On the left the old outside code, looks ok does not react to lights On the right the new one you just posted, it does not matter how many times I play with the following: const float facAmbient = 0.8; // factors to play with const float facBump = 0.8; const float facSpecular = 0.8; Does not change anything, I would like it to look like the one on the left but work with (I like the specular highlights) with color level / dynamic lights. I must be doing something wrong 
|
|
|
Re: Normalmapping (in development)
[Re: jcl]
#117199
03/28/07 00:35
03/28/07 00:35
|
Joined: Jul 2002
Posts: 1,364 Minbar
MaxF
OP
Serious User
|
OP
Serious User
Joined: Jul 2002
Posts: 1,364
Minbar
|
OK I sent you the level by email. to jcl conitec
Last edited by MaxF; 03/28/07 00:58.
|
|
|
|