Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


eastcowboy

Member Since 22 Aug 2006
Offline Last Active Oct 15 2014 03:29 AM

Posts I've Made

In Topic: May I use Warcraft3 models/textures/etc. in my Android/iOS Game?

25 February 2014 - 10:29 AM

 

Thank you. I've read them now.

I will consider to find some other free assets.

 

Have you considered creating your own assets?

 

Not yet.

Currently our team have only 2 programmers and no artist.

If we don't managed to find some assets, we may consider to spend some money and let someone to help us.


In Topic: May I use Warcraft3 models/textures/etc. in my Android/iOS Game?

22 February 2014 - 10:39 AM

Thank you. I've read them now.

I will consider to find some other free assets.


In Topic: problem writing complex vertex shader

28 July 2013 - 09:38 AM

Yes the 'AncientOfLore.mdx' has many bones. When I found this for the first time, I am surprised too.

Once again the Warcraft3's model do not obey the rule they've made in the <Warcraft III Art Tools Documention.pdf>.

According to the documention, a building should have at most 15 bones. And a really big unit should have at most 30 bones.

 

By the way, OpenGL 2.0 spec is released on the year 2004. Warcraft3 is released before that. So I think Warcraft3 is not using a shader to do the bone animation.

 

I've noticed that, not all the bones are used by the mesh. Some of the bones are used for attaching another model, or used by a particle emitter, etc.

For example, when an AncientOfLore tree was badly damaged, some places of the tree body will be on fire. Each place uses a particle emitter to draw the fire, and a particle emitter needs a bone. Simply speaking, 6 places of fire will use 6 bones.

We can ignore these bones when we are loading bone matrices to the shader.

 

There is a concept named "geoset" in the Warcraft3's model. A geoset contains data like vertex positions, texture coords, normals, and the indices of bone matrix. One model may have one or more geoset(s).

Before today I thought that each vertex in each geoset can be linked to any bone of this model. When I see these words "split the mesh" I guess we may make use of the geoset directly, rather than split the mesh by an algorithm.

So I did a simple test.

The 'AncientOfLore.mdx' model has 12 geosets. And in the animation sequence "stand work alternate" there're 6 of them are visible(The documention says that one model should have at most 5 visible geosets!). The number of bones used in each geoset are: 27, 62, 3, 3, 8, 2. All these numbers are much lesser than 202.

But for OpenGL ES, the 62 bones is still too many and will need to split into smaller parts.

 

So if I need to display an 'AncientOfLore.mdx' on my Android phone, I have to design an algorithm to split a geoset into two or more small geosets.

The next step is to design and implement this algorithm. I think that will not be easy for me. But I'll try it.


In Topic: problem writing complex vertex shader

25 July 2013 - 12:38 PM

Here's some snapshot of my test program.

I'd like to share my happy feeling with you. Thank you again.

Attached File  testGL.01.png   101.8KB   8 downloads

Attached File  testGL.02.png   50.72KB   6 downloads

Attached File  testGL.03.png   50.07KB   5 downloads

Attached File  testGL.04.png   93.95KB   6 downloads


In Topic: problem writing complex vertex shader

25 July 2013 - 12:25 PM

Koehler, thank you very much for your reply. It helps me a lot.

Especially the 'dot product', that is wonderful.

 

But let me point out this.

The code "vec4 p = vec4(0,0,0,1);" you wrote, will actually be "vec4 p = vec4(0,0,0,0);". Or the transformation will not be correct.

 

Based on your idea, I've changed my source code.

I'm not very famillar about OpenGL version 2.0 and above. Fortunately I did it with a success:).

And there're still some issues that need to be think about.

 

Let me put my shader source code down here:

(Yes you can see there's something like gl_TextureMatrix and gl_ModelViewProjectionMatrix. That's because the first version of my program is written on an old PC witch only supports OpenGL 1.4. I'll modify these when necessary)

/* vertex shader */
uniform mat4 u_matrix_list[202];
attribute vec3 a_position;
attribute vec2 a_texcoord;
attribute vec4 a_mat_indices;
attribute vec4 a_mat_weights;
varying vec2 v_texcoord;
void main() {
  v_texcoord = (gl_TextureMatrix[0] * vec4(a_texcoord, 0.0, 1.0)).xy;
  vec4 p0 = vec4(a_position, 1.0);
  vec4 p = vec4(0.0, 0.0, 0.0, 0.0);
  p += (u_matrix_list[(int)a_mat_indices[0]] * p0) * a_mat_weights[0];
  p += (u_matrix_list[(int)a_mat_indices[1]] * p0) * a_mat_weights[1];
  p += (u_matrix_list[(int)a_mat_indices[2]] * p0) * a_mat_weights[2];
  p += (u_matrix_list[(int)a_mat_indices[3]] * p0) * a_mat_weights[3];
  p /= dot(a_mat_weights, a_mat_weights);
  gl_Position = gl_ModelViewProjectionMatrix * p;
};

/* fragment shader */
uniform sampler2D tex;
uniform vec4 u_color;
varying vec2 v_texcoord;
void main() {
  gl_FragColor = u_color * texture2D(tex, v_texcoord);
}

Issues:

1. I wrote "uniform mat4 u_matrix_list[202];", this is a very large array for GPU.

    I found that many of Warcraft3's unit model have less than 100 bones. For example a water elemental has 69 bones, and a footman has 49 bones.

    But the buildings' model have many more bones. When I use the model 'AncientOfLore.mdx' for test. I found that it has 202 bones. So I declared such a large array. According to the MDX format, there can be up to 256 nodes(since the node's ID is a BYTE). But when I wrote "uniform mat4 u_matrix_list[256];" the glLinkProgram fails, with an error message "error C6007: Constant register limit exceeded; more than 1024 constant registers needed to compiled program".

   I hear that if we store a mat4 as 3 vec4, it may save some space. But that may not be enough. The OpenGL ES 2.0 only ensure to have 128 vec4 uniform variables (glGetIntegeri with GL_MAX_VERTEX_UNIFORM_VECTORS), so we can only use 128 / 3 = 42 bones or less?

  Or we can try to use a texture to store some more data. The book <OpenGL ES 2.0 Programming Guide> says that "Samplers in a vertex shader are optional". The POWERVR SGX seems to support it. But we need some more information to decide whether or not to use it.

 

2. Yes, the <Warcraft III Art Tools Documention.pdf> says that "Up to four bones can influence one vertex.". So we can use an vec4 attribute to simulate an float[4] array.

    But I found there're some exceptions. For example a water elemetal has some vertices that are influenced by up to 6 bones. This is not very critical because we can add 2 more attribute to fix it.

    In my test I just use the first 4 bones, and ignore the last 2, it looks fine without any obvious problem. So let's just ignore it for now:)


PARTNERS