|
Normalmapping (in development)
#117150
03/13/07 13:47
03/13/07 13:47
|
Joined: Jul 2002
Posts: 1,364 Minbar
MaxF
OP
Serious User
|
OP
Serious User
Joined: Jul 2002
Posts: 1,364
Minbar
|
Hi Is this coming out soon, I've tried 2 shaders from the forum and all I get is a black (very dark) model. In this day and age it should be already a basic thing and specially for people like me who can't work out what I'm doing wrong 
|
|
|
Re: Normalmapping (in development)
[Re: Mondivirtuali]
#117152
03/13/07 14:13
03/13/07 14:13
|
Joined: Jul 2000
Posts: 28,024 Frankfurt
jcl

Chief Engineer
|

Chief Engineer
Joined: Jul 2000
Posts: 28,024
Frankfurt
|
Well, you don't need to wait for the templates, normalmapping is simple: Code:
MATERIAL mtl_bump { //Normal Map must be on Skin2 effect= " #include <transform> #include <fog> #include <pos> #include <normal> #include <tangent>
float4 vecSunDir; float4 vecColor;
texture entSkin1; // texture texture entSkin2; // normal map
sampler sBaseTex = sampler_state { Texture = <entSkin1>; }; sampler sBump = sampler_state { Texture = <entSkin2>; };
struct out_bump { float4 Pos: POSITION; float Fog: FOG; float4 Color: COLOR; float2 Tex: TEXCOORD0; float2 Bump: TEXCOORD1; float3 Normal: TEXCOORD2; float3 Light: TEXCOORD3; };
out_bump vs_bump( in float4 inPos: POSITION, in float3 inNormal: NORMAL, in float2 inTex: TEXCOORD0, in float3 inTangent: TEXCOORD2) { out_bump Out;
Out.Pos = DoTransform(inPos); Out.Tex = inTex; Out.Bump = inTex; // different coordinates required for ps_1_1 Out.Color = float4(1.0,1.0,1.0,1.0); Out.Fog = DoFog(inPos); CreateTangents(inNormal,inTangent); float3 N = matTangent[2]; // transform the output values into the 0..1 range Out.Light = DoTangent(-vecSunDir) * 0.5 + 0.5; Out.Normal = DoTangent(N) * 0.5 + 0.5;
return Out; }
float4 ps_bump(out_bump In): COLOR { float4 base = tex2D(sBaseTex,In.Tex); float3 bumpNormal = tex2D(sBump,In.Bump); float diffuse = saturate(dot(In.Light*2 - 1,bumpNormal*2 - 1)); #ifdef SHADOW diffuse *= saturate(4 * dot(In.Light*2 - 1,In.Normal*2 - 1)); #endif return base * diffuse; }
technique bump { pass One { VertexShader = compile vs_1_1 vs_bump(); PixelShader = compile ps_1_1 ps_bump(); } }
"; }
You need 6.50, the template6 file "default.fx" must be in the path, and the model must have a normal map on its second skin. You can also save the effect to an .fx file and assign it to the model directly in MED.
|
|
|
Re: Normalmapping (in development)
[Re: DWilki]
#117154
03/13/07 15:40
03/13/07 15:40
|
Joined: Jul 2002
Posts: 1,364 Minbar
MaxF
OP
Serious User
|
OP
Serious User
Joined: Jul 2002
Posts: 1,364
Minbar
|
Hi JCL Easy for a guy like you  Thanks for the code will play with it, so you must use templates!
|
|
|
Re: Normalmapping (in development)
[Re: lostclimate]
#117156
03/13/07 18:52
03/13/07 18:52
|
Joined: Jul 2002
Posts: 1,364 Minbar
MaxF
OP
Serious User
|
OP
Serious User
Joined: Jul 2002
Posts: 1,364
Minbar
|
I was talking about the shader code
Last edited by MaxF; 03/13/07 18:52.
|
|
|
Re: Normalmapping (in development)
[Re: TWO]
#117159
03/13/07 22:10
03/13/07 22:10
|
Joined: Oct 2005
Posts: 528 Italy
Mondivirtuali
User
|
User
Joined: Oct 2005
Posts: 528
Italy
|
Okay, shader code done. It called mt_material1.fx Then I try this: I put two skins in the same (static model)(from Med), one is the normal map (obteined with Gimp from the first skin) . Then I include the nm.fx in the try.wdl , include material.wdl in the project and assign the mt_material1 at the model. It appairs the same (?), perhaps the two skins should named "entskin"? I should miss some passages here.
Last edited by Mondivirtuali; 03/13/07 22:12.
|
|
|
|