LotusExigeS1

has anyone managed to get diffuse working in HLSL for an animated skinned mesh

I really hope so because I cant get mine working, it just looks weird. can someone please let me know the secret. FYI - the animation is working great with the vertex shader applying the bone transformations, etc ... its just the lighting I need sorting now :O)

Thanks,

Dave.



Re: Game Technologies: Graphics Diffuse HLSL for Skinned Mesh

BLANC Guillaume

There's no big difference between a static and a skinned lighting algorithm. You simply have to take care of the coordinate system you're using cos skinning is usualy done in world space and lighting in object space. Even if that's not exactly your case, that's the sort of things (coordinate system stuff) that might be a bit confusing when going from static to skinned.
I think you should have a look to the Direct3D sample "SkinnedMesh" which does that very well.






Re: Game Technologies: Graphics Diffuse HLSL for Skinned Mesh

LotusExigeS1

The version in the SDK (the one I have) doesnt do any lighting in vs/ps, it appears to be done in the ff pipeline. I have managed to create a pixel shader and vertex shader that animates perfectly, but the example that I used only uses a light direction for the diffuse, I need to use a light at an x,y,z and then calculate the diffuse with that. Is there an easy calculation for working out a direction from the vertex position (x,y,z) and the light position (x,y,z). Sorry is this is b@ll@cks, I am new to this ....



Re: Game Technologies: Graphics Diffuse HLSL for Skinned Mesh

bcristian

You might want to get the directional lighting sorted out first (i.e. the case with the light being characterized just by direction and color), because that's the simplest to write and debug, while allowing you to determine what you're doing wrong. Once you get that to work, you can easily change it to do point lighting.

The two common mistakes in computing lighting on a skinned mesh are:

  • mixing coordinate systems, e.g. using world-space vertex position and normal with camera-space light parameters.
  • using the pre-skinning vertex position and normal (transformed or not) for the lighting computation.