|
Bug with fx on skins when different number of entity skins?
#372660
06/03/11 13:34
06/03/11 13:34
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
OP
Serious User
|
OP
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
Hey guys,
I'm trying to create a custom shader but having a few issues.
I've narrowed it down to having a different number of skins on the model though in my eyes this shouldn't make any difference.
I have two models both identical except for the number of skins they have (one with 5 and the other with 9).
With the shader I've got an fx applied to skin 2 to which mixes skin 3 with the R channel of skin 2, skin 4 with the G channel of skin 2, and skin 5 with the B channel of skin 2.
This all works fine, but, when I have 9 skins on the model, it doesn't do any mixing as expected.
I use <entSkin1> through <entSkin4> in the shader which in my understanding should always be skins 2,3,4 and 5 resepectively.
Anybody able to shed some light on this? I can send an example of what the hell I'm on about if it wil help.
Thanks in advance!
|
|
|
Re: Bug with fx on skins when different number of entity skins?
[Re: MrGuest]
#372710
06/03/11 19:00
06/03/11 19:00
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
I use <entSkin1> through <entSkin4> in the shader which in my understanding should always be skins 2,3,4 and 5 resepectively. Why shouldn´t this start with 1? And when using 9 skins, which of them are applied to what? What are the shaders passes called? Best would be if you could provide some basic example project.
|
|
|
Re: Bug with fx on skins when different number of entity skins?
[Re: Slin]
#372790
06/04/11 13:06
06/04/11 13:06
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
OP
Serious User
|
OP
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
The model has three parts, Skin1 is applied to area 1, with no fx Skin2 is applied to area 2 Skin3, 4 and 5 are patterns mixed with skin2 as shown above Skin6 is applied to area 3 Skin7, 8 and 9 are patterns mixed with skin6 as similarly to skin2.
technique techMain {
pass outline {
CullMode = CW;
AlphaTestEnable = TRUE;
AlphaFunc = GREATER;
AlphaRef = 1;
ZWriteEnable = TRUE;
VertexShader = compile vs_3_0 outlineVS();
PixelShader = compile ps_3_0 outlinePS();
}
pass one {
CullMode = CCW;
AlphaTestEnable = FALSE;
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}
void VS (in float4 inPos : POSITION,
in float3 inNormal : NORMAL,
in float2 inTex : TEXCOORD0,
in float4 inTangent : TEXCOORD2,
out float4 outPos : POSITION,
out float2 outTex : TEXCOORD0,
out float3 outViewDir: TEXCOORD1,
out float3 outLight1 : TEXCOORD2,
out float3 outLight2 : TEXCOORD3,
out float3 outLight3 : TEXCOORD4,
out float3 outLight4 : TEXCOORD5,
out float3 worldPos : TEXCOORD6,
out float2 logoTex : TEXCOORD7) {
outPos = mul(inPos, matWorldViewProj);
outTex = inTex;
matTangent[0] = mul(inTangent.xyz, matWorld);
matTangent[1] = mul(cross(inTangent.xyz, inNormal)*inTangent.w, matWorld);
matTangent[2] = mul(inNormal, matWorld);
// tangent stuff
worldPos = mul(inPos, matWorld);
outViewDir = normalize(mul(matTangent, (vecViewPos - worldPos)));
outLight1 = normalize(mul(matTangent, (vecLightPos[0] - worldPos)));
outLight2 = normalize(mul(matTangent, (vecLightPos[1] - worldPos)));
outLight3 = normalize(mul(matTangent, (vecLightPos[2] - worldPos)));
outLight4 = normalize(mul(matTangent, (vecLightPos[3] - worldPos)));
}
float4 PS (in float2 inTex : TEXCOORD0,
in float3 inView : TEXCOORD1,
in float4 inLight1: TEXCOORD2,
in float4 inLight2: TEXCOORD3,
in float4 inLight3: TEXCOORD4,
in float4 inLight4: TEXCOORD5,
in float3 pos : TEXCOORD6,
in float2 logoTex : TEXCOORD7) : COLOR0 {
float4 mixer = tex2D(MixSkinBase, inTex);
float4 colourR = tex2D(PatternR, inTex * matEffect1[0].w);
float4 colourG = tex2D(PatternG, inTex * matEffect1[1].w);
float4 colourB = tex2D(PatternB, inTex * matEffect1[2].w);
colourR.rgb = lerp(matEffect1[0].xyz, matEffect2[0].xyz, colourR.a) * mixer.r;
colourG.rgb = lerp(matEffect1[1].xyz, matEffect2[1].xyz, colourG.a) * mixer.g;
colourB.rgb = lerp(matEffect1[2].xyz, matEffect2[2].xyz, colourB.a) * mixer.b;
float4 finalColour;
finalColour.rgb = colourR.rgb + colourG.rgb + colourB.rgb;
finalColour.a = 1.0;
float4 logoR = tex2D(Logo, inTex);
float4 logoG = tex2D(Logo, inTex);
float4 logoB = tex2D(Logo, inTex);
logoR.rgb = matEffect5[0].xyz * logoR.r;
logoG.rgb = matEffect5[1].xyz * logoG.g;
logoB.rgb = matEffect5[2].xyz * logoB.b;
float4 logoFinal;
logoFinal.rgb = logoR.rgb + logoG.rgb + logoB.rgb;
finalColour.rgb = lerp(finalColour.rgb, logoFinal.rgb, logoR.a * matEffect5[0].w);
// do lighting
float4 norm = tex2D(NormSamplerN, inTex);
norm.rgb = norm.rgb * 2 - 1;
norm.g *= -1;
float4 lighting = doLightSpec(pos, inView, inLight1, norm, 0, norm.a) + doLightSpec(pos, inView, inLight2, norm, 1, norm.a) + doLightSpec(pos, inView, inLight3, norm, 2, norm.a) + doLightSpec(pos, inView, inLight4, norm, 3, norm.a);
finalColour.rgb *= (lighting * DIFFUSE + AMBIENCE);
return finalColour;
}
I've changed the entSkin1 to 4 to mtlSkin1 to 4 and this now works... I can send a working (and unworking) version via email as the model supplied is not for commercial use and only for testing purposes.
|
|
|
|