|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: xXxGuitar511]
#118000
03/22/07 01:17
03/22/07 01:17
|
Joined: Aug 2001
Posts: 2,320 Alberta, Canada
William
Expert
|
Expert
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
|
Quote:
struct VS_OUTPUT0 { float4 Pos : POSITION; float2 Tex : TEXCOORD0; float3 View : TEXCOORD1; float3 Light1 : TEXCOORD2; float Att1 : TEXCOORD3; float3 Sun : TEXCOORD6; float3 Light2 : TEXCOORD4; float Att2 : TEXCOORD5;
float Fog : FOG; };
VS_OUTPUT0 VS_PASS0(float4 Pos : POSITION, float2 texcoord0 : TEXCOORD0, float3 Normal : NORMAL, float3 Tangent : TEXCOORD0 ) { VS_OUTPUT0 Out = (VS_OUTPUT0)0; Out.Pos = mul(Pos, matWorldViewProj); // transform Position // compute the 3x3 tranform matrix // to transform from world space to tangent space float3x3 worldToTangentSpace; worldToTangentSpace[0] = mul(Tangent, matWorld); worldToTangentSpace[1] = mul(cross(Tangent, Normal), matWorld); worldToTangentSpace[2] = mul(Normal, matWorld); Out.Tex = texcoord0.xy;
float3 PosWorld = mul(Pos, matWorld);
float3 Viewer = PosWorld - vecViewPos; Out.View = mul(worldToTangentSpace, - Viewer); // V
Out.Sun = mul(worldToTangentSpace, -vecSunDir);
//light 1 float3 Light1 = PosWorld - vecLightPos[0] ; Out.Light1.xyz = mul(worldToTangentSpace, -Light1); // L Out.Att1 = distance(PosWorld,vecLightPos[0])/vecLightPos[0].w; // Point light
//light 2 float3 Light2 = PosWorld - vecLightPos[1] ; Out.Light2.xyz = mul(worldToTangentSpace, -Light2); // L Out.Att2 = distance(PosWorld,vecLightPos[1])/vecLightPos[1].w; // Point light
float ofog = 1 - (distance(PosWorld, vecViewPos) - vecFog.x) * (vecFog.z); Out.Fog = ofog;
return Out; }
I tried adding it, but it gives an error and defaults to vertex lighting material. Then I added "float3 Sun : TEXCOORD6;" and theres no error, but it doesn't show the first light properly(and still no sun). I've also tried messing in the PS part and edited out light1 and put in Sun instead, but no luck. Am I messing things up?
|
|
|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: William]
#118001
03/22/07 14:10
03/22/07 14:10
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
I added some stuff, I'm gonna go "debug" it...
I'll post my results soon...
xXxGuitar511 - Programmer
|
|
|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: William]
#118003
03/24/07 16:26
03/24/07 16:26
|
Joined: Jul 2002
Posts: 1,364 Minbar
MaxF
Serious User
|
Serious User
Joined: Jul 2002
Posts: 1,364
Minbar
|
Hi Its not working for me, it looks like the model is not change by the shader What I'm doing wrong? 1) Put the shader in a fx file 2) wrote a wdl with the following statement: material mat_nm3lights { effect = "nm3light.fx"; } 3) attached material in WED to model
|
|
|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: MaxF]
#118004
03/24/07 18:09
03/24/07 18:09
|
Joined: Aug 2006
Posts: 652 Netherlands
bstudio
User
|
User
Joined: Aug 2006
Posts: 652
Netherlands
|
did you include a light near the model (dynamic light that is)
BASIC programmers never die, they GOSUB and don't RETURN.
|
|
|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: bstudio]
#118005
03/24/07 20:31
03/24/07 20:31
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
add in effect_load() in a starter function Code:
string fxNM3Light = "nm3light.fx";
material mat_nm3lights { effect = fxNM3Light; }
starter loadFX { effect_load(mat_nm3lights, fxNM3Light); }
xXxGuitar511 - Programmer
|
|
|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: xXxGuitar511]
#118006
03/26/07 03:26
03/26/07 03:26
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
just thought I'd let you know I'm still workin on this. I accidently coppied it onto my work drive instead of my thumbdrive, so I havn't been able to work on it this weekend. So far I [theoretically] have 5 lights in one pass. It should work, but needs to be tested. I did this by copying the light AttenuationX into the LightX:TEXCOORDX. I'll be at work tomorrow, and post my results...
xXxGuitar511 - Programmer
|
|
|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: William]
#118008
03/26/07 06:41
03/26/07 06:41
|
Joined: Aug 2006
Posts: 652 Netherlands
bstudio
User
|
User
Joined: Aug 2006
Posts: 652
Netherlands
|
starter is no longer used as a function, to use a starter function use this: Code:
function LoadFX_startup() { effect_load(mat_nm3lights, fxNM3Light); }
BASIC programmers never die, they GOSUB and don't RETURN.
|
|
|
Re: [Supply] Matt's NormalMapping shader with 3 li
[Re: bstudio]
#118009
03/26/07 13:15
03/26/07 13:15
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
@bstudio: Thanks, I had heard of this update, but never got around to actually using it. I'll remember that...
@William: It's not required, it's just an optimization. Using less passes, yet still getting the same effect = better speeds... correct? I currently only have 5 lights, but it still has room for more in its pass... (1 or 2 texcoords left)
xXxGuitar511 - Programmer
|
|
|
|