Hi All
I know this is a long shot but any help would be great.
Does anyone still use or have used Nuclear Basic/ Fusion that can help?
I still really like the language and still use it. But need help in hardware skinning for animated entities I cant seem to send the bone information over to the shader.
These are the commands I've found that might help but can't figure out how to use them.
GetSurfaceBoneOffsetMatrix( Surf, mat, boneind )
GetSurfaceBoneCount(Surf)
GetSurfaceBone(Surf,boneind)
GetEntMatrix( handle, inmat, global=False )
SetShaderMatrixArray(handle, pname$, mat,[cnt=1] )
Here is the shader I am using.
float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "object";
string ScriptOrder = "standard";
string ScriptOutput = "color";
string Script = "Technique=Technique?Skinned;";
> = 1.0;
float4x4 wvp : WorldViewProjection < string UIWidget = "None"; > ;
float4x4 worldI : WorldInverse < string UIWidget = "None"; > ;
float4x4 worldIT : WorldInverseTranspose < string UIWidget = "None"; > ;
float4x4 viewInv : ViewInverse < string UIWidget = "None"; > ;
float4x4 world : World;
// array for bones matrices
uniform float4x3 bonesMatrixArray[60];
extern int NumVertInfluences = 3;//<--- Normally set dynamically.
// ambeint light
float4 ambientLight = float4(1,0,0,1);
texture diffuseTexture : TEXTURE_0;
sampler diffuseSampler : register(s0) = sampler_state
{
Texture = <diffuseTexture>;
};
// Vertex shader input data structure
struct VSINPUT
{
float4 Position : POSITION;
float4 BlendWeights : BLENDWEIGHT;
float4 BlendIndices : BLENDINDICES;
float3 Normal : NORMAL;
float3 texCoords : TEXCOORD0;
};
// Vertex shader output data structure
struct VSOUTPUT
{
float4 Position : POSITION;
float3 Normal : COLOR0;
float2 texCoords : TEXCOORD0;
};
// skinning vertex shader
VSOUTPUT VSMain(VSINPUT Input)
{
// Output object
VSOUTPUT Output;
// Clear vertex position and normal
Output.Normal = float3(0.0f, 0.0f, 0.0f);
Output.Position = float4(0.0f, 0.0f, 0.0f, 0.0f);
// extract bones indicies and weights from vertex
float lastWeight = 0.0f;
float4 blendPos = Input.Position;
// This next code segment computes formula (3).
for (int i = 0; i < NumVertInfluences; ++i)
{
blendPos += float4(mul(bonesMatrixArray[Input.BlendIndices[i]], Input.Position).xyz, 1.0)*Input.BlendWeights[i];//Input.BlendWeights[i] * mul(Input.Position, bonesMatrixArray[Input.BlendIndices[i]]);
}
Output.Position = mul(blendPos, wvp);
// transform normal
float3 norm = Input.Normal;
for (i = 0; i < NumVertInfluences; ++i)
{
norm += mul((float3x3)bonesMatrixArray[Input.BlendIndices[i]], Input.Normal) *
Input.BlendWeights[i];
}
Output.Normal = normalize(norm);
Output.texCoords = Input.texCoords;
// return result
return Output;
}
// skinning simple pixel shader
float4 PSMain(float2 texCoords : TEXCOORD0) : COLOR0
{
// just return diffuse color
return ambientLight * tex2D(diffuseSampler, texCoords);
}
// skinning tchnique
technique Skinned
{
pass p1
{
VertexShader = compile vs_3_0 VSMain();
PixelShader = compile ps_3_0 PSMain();
}
}