Very nice "Dangerous, Demented Asylum Dweller" The Glitch! Lovely! I just know that's yours!
Also absolutely beautiful looking "Winged Sonja" Mel!
O.K.
I'm looking at The Glitch's HWS-HLSL shader.. Looks cool, but I cant learn from it as I cant see his "Calling Function",
so here is my "less professional" version..
It comes from the old example (24. Hardware Skinning) but I altered it somewhat..
My normals don't get sent to the shader in an animated way
so Lighting isn't even attempted.
(you'll see in the shader that I ignored them completely)
I know nothing of the 4 X 3 Mat issue yet, but here is my altered HLSL shader.
(maybe you guys can give some pointers)
So, here goes.. Your wise comments would be appreciated!
"HWSkin.hlsl":
Code: Select all
// HLSL VERTEX PROGRAM (Ja, we know we have more bones in GLSL, but this concerns HLSL)
#define MAX_JOINT_NUM 57 // 57 is MAX before compilation fails.. Got it up to 62!!
#define MAX_LIGHT_NUM 8
float4x4 JointTransform[MAX_JOINT_NUM]; // WE HAD 16 X 62 = 992.. So how does this impact on Hardware "Registers"??
float4x4 mWorldViewProj;
float4x4 mWorld;
// THESE DONT WORK IN HERE SO I DROPPED THEM TOTALLY..
// Anyway, I don't think Vertex Programs is the right place for lighting.
// I'll worry about lighting in the Fragment Shader when the Normals are sent
// to the Vertex Program "properly animated".
// I can do lighting pefectly in GLSL and HLSL but NOT under H/W Skinning activated.
// (is hardware skinning really all that hot? I don't seem to see much of a frame rate improvement?)
// Getting rid of lights to see if we can get more bones in.. We could (hey hey!), but NOT ENOUGH!!
// This I tried after Mel's comment on "Max Registers" being exceeded.
// float3 lightPosArray[MAX_LIGHT_NUM]; (In a perfect world this happens in the Fragment Shader..)
// float4 lightColorArray[MAX_LIGHT_NUM];
// ----------------------------------- ---- --- -- -
struct VS_OUTPUT
{float4 Position : POSITION0;
float2 TexCoords : TEXCOORD0;
float2 TexCoords2 : TEXCOORD1;
float4 Color : COLOR0; // In this implementation Vertex Colour, it seems, is used for Weights and Indices..
// How it is this structured ?..(i ain't got a clue)
};
// ----------------------------------- ---- --- -- -
VS_OUTPUT vertexMain (float3 Position : POSITION0,
float2 TexCoords : TEXCOORD0,
float2 TexCoords2 : TEXCOORD1, // Is this used?
float4 Color : COLOR0,
float3 VertexNormal : NORMAL
)
{VS_OUTPUT OUT;
float4 MeshPos = float4(Position.x,Position.y,Position.z,1.0);
float4x4 ModelTransform = mWorldViewProj;
int verCol = int(Color.r * 255.9); // What is the "255.9" all about?
float4x4 matTran = JointTransform[verCol - 1]; // O.K. this facilitates an array of SIXTEEN Values!
// DO WE REALLY NEED ALL 16 VALUES..
// OR.. Could we have a longer array of simple floats..
// BUT! Indices are INTEGERS and Weights are FLOATS!! (clue?)
// How do we RESTRUCTURE this there..
// I have no idea what's going on here!
// Is the following still relevant in this HWS discussion?
verCol = int(Color.g * 255.9);
if(verCol != 0) {matTran += JointTransform[verCol - 1];}
verCol = int(Color.b * 255.9);
if(verCol != 0) {matTran += JointTransform[verCol - 1];}
verCol = int(Color.a * 255.9);
if(verCol != 0) {matTran += JointTransform[verCol - 1]; }
// Apply final transformation.
ModelTransform = mul(matTran, ModelTransform);
OUT.Position = mul(MeshPos, ModelTransform);
OUT.TexCoords = TexCoords;
OUT.TexCoords2 = TexCoords2;
float4 finalCol = float4(1,1,1,1);
// All Light stuff disabled as they just complicate things unecessarily..
OUT.Color = clamp(finalCol,0.3,1.0);
// This "should" just render the normals so we have something to look at as I have no real lighting in HWS yet..
OUT.Color.x = (VertexNormal.x / 2.0) + 0.5;
OUT.Color.y = (VertexNormal.y / 2.0) + 0.5;
OUT.Color.z = (VertexNormal.z / 2.0) + 0.5;
// OFF-TOPIC..
// I consider the fact that Irrlicht insists on rendering textures when in shader mode
// (even if none have been specified, see GLSL) a serious Irrlicht bug because this makes it
// so I can't set a DIFFERENT "Diffuse" image for the model if I should want to..
return(OUT);
}