Vertex Shader problem

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Vertex Shader problem

Post by HexiDave »

I've run into a bit of a problem using a Cg shader to take care of hardware skinning:
Image

You can see in the top-right on the terrain... something a bit odd happens. This PLSM2 terrain, but Vertex shading on the terrain is off. The thing that gets me is that I've done all the same things to the arms and legs as I did to the head of the model as far as changing textures and animating, but neither the head nor the chest (I haven't done anything extra with the chest) have this problem. My Arms, Legs and Helmet were comprised of several pieces, but I added them together (into Arms, Legs and Helmet pieces.)
When I turn off the shader and use default skinning, nothing goes wrong. When I use 4 weight skinning program, it changes a little bit, but not much. When I edit Example_Basic.cg and remove everything but the vertex math, it still happens.

The skeleton has more than 24 bones BUT the none of the meshes has 24 bones influencing it. Furthermore, the animations go off without a hitch - it's the terrain that gets weird.

The material script is here - I use Maya 7.0 to export and edit it:

Code: Select all

vertex_program HardwareSkinningOneWeight cg
{
   source Example_Basic.cg
   entry_point hardwareSkinningOneWeight_vp
   includes_skeletal_animation true
   profiles vs_1_1
}


material ArmsPhong
{
	technique
	{
		pass
		{
			vertex_program_ref HardwareSkinningOneWeight
			{
				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
				param_named_auto viewProjectionMatrix viewproj_matrix
				param_named_auto lightPos[0] light_position 0
				param_named_auto lightPos[1] light_position 1
				param_named_auto lightDiffuseColour[0] light_diffuse_colour 0
				param_named_auto lightDiffuseColour[1] light_diffuse_colour 1
				param_named_auto ambient ambient_light_colour
			
			}


			texture_unit
			{
				texture armor_arms.dds
				tex_coord_set 0
				colour_op modulate
			}
		}
	}
	technique
	{
		pass
		{
			ambient 1 1 1 1
			diffuse 1 1 1 1
			specular 0.5 0.5 0.5 20
			emissive 0 0 0

			texture_unit
			{
				texture armor_arms.dds
				tex_coord_set 0
				colour_op modulate
			}
		}
	}
}
The only things I can think of are that the vertex program doesn't support my mesh (it's all rigid, 1-influence per vertex) or I need to do something with the material of the ground.

Anyone have any past experience or input on this? This is basically my last major obstacle before I can move into the real nitty-gritty of the game.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

When vertex shaded, some pieces of your model doesn't appear over terrain.

When no terrain they appears ?
When not vertex shaded they appears ?
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Oh I'm sorry, no - that was just my character's arms - I was trying to isolate the problem to one piece and see what was different, I was working on the arms in that picture.

I'm going to try something weird today to see if I get any results, but I'm not exactly hopeful - I've tried about 20 different things. The only part of the vertex program in Example_Basic.cg that actually causes this is the initial transforms, so something is wrong with my model that the vertex shader doesn't like - going to have to try really hard to solve this one.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

So problem is that you don't success on applying hardware animation on your model ?
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Actually the hardware animation works just fine (get a nice speed boost) without deforming the model in any way. I'm going to have to try another model, but I have to skin it. If it does it there too, then (I'm going to kick my monitor) I'll have to determine if it's just that Example_Basic.cg doesn't do the math that my mesh needs or that my skeleton is too big (but that would baffle me as the head and chest are both attached to the same skeleton.)
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Also, I should note- when I turn VertexCompression on in PLSM2 the terrain, where the problem occurs, goes invisible. So, something is wrong with the texture coordinates or something - I haven't got a clue what's causing it.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Actually the hardware animation works just fine (get a nice speed boost) without deforming the model in any way.
do models have normals ?
Also, I should note- when I turn VertexCompression on in PLSM2 the terrain, where the problem occurs, goes invisible. So, something is wrong with the texture coordinates or something - I haven't got a clue what's causing it.
In plsm2 or in any scene manager ?
Post Reply