Shaders [SOLVED] Is this where I use vertex buffers?

hippyman

Member
I'm messing around with the FBX SDK and I was just wondering how I was supposed to render the models. My assumption is that it will be rendered by a shader and the documentation for GMS mentions that vertex buffers are used for this.

So is the basic idea that I just fill the vertex buffer with the data I need (transform, skeleton, anims, etc) and pass the buffer to a shader?

I'm hoping that some of the more experienced 3D and shader people can help me better understand how these things work together. Maybe even point me to some decent guides/articles that discuss rendering models with shaders in detail. I tried looking but was having a hard time finding anything helpful. I'm not the most experienced with shaders. I've messed with Xor's shader tutorials and I've done things like port a simple shader from ShaderToys to GM but it's still gibberish to me.

Any help would be greatly appreciated.
 

GMWolf

aka fel666
You don't need a shader to draw a vertex buffer, if you vertex buffer contains position, texcoord, normal and colour information.

The first step is to define a vertex format, with all the information you would like to store for each vertex.
You then build vertex buffers using that format.
Finally, to draw the vertex buffer, you use vertex_submit.

If you do not want to store colour, normals, a c in the vertex buffer, you will need to create a shader that only accepts the information you need.
This is as easy as using the default shader, and commenting out the normal and colour parts, for example.

Then all you do is set the shader, then submit the vertex buffer like before, before resetting the shader.
 

hippyman

Member
So are vertex buffers basically the same thing as primitives with the only difference being that vertex buffers are for 3D and primitives are for 2D?
 

orange451

Member
Vertex buffers could also be used for 2d rendering as well. In fact, they're the fastest way to draw a mesh onto the screen with Game Maker at the moment, so they're probably a lot faster than primitives (assuming they haven't been converted to use vertex buffers under-the-hood).
 

hippyman

Member
That's pretty neat and something I didn't know. I just messed around with them in GMS and I think I have it figured out.

So basically I would let the FBX sdk handle any processing, like animations, and then just fill a GM buffer with the current data and put that buffer in a vertex buffer and render it. Could it really be that simple?
 

GMWolf

aka fel666
That's pretty neat and something I didn't know. I just messed around with them in GMS and I think I have it figured out.

So basically I would let the FBX sdk handle any processing, like animations, and then just fill a GM buffer with the current data and put that buffer in a vertex buffer and render it. Could it really be that simple?
If the data you are given is in raw format, then yeah.
 

GMWolf

aka fel666
I'm still unsure as I just begun messing with the sdk but what do you mean by raw format?
if you can have a buffer that is just [X,Y,Z, textureX, textureY, normalX, normalY, normalZ, colorR, colorG, colorB]* then in should work.

In other words, if the buffer matches the buffer format, it is indeed that easy.
 

hippyman

Member
if you can have a buffer that is just [X,Y,Z, textureX, textureY, normalX, normalY, normalZ, colorR, colorG, colorB]* then in should work.

In other words, if the buffer matches the buffer format, it is indeed that easy.
Well couldn't I just make a vertex format to match the format used with FBX?
 

GMWolf

aka fel666
Well couldn't I just make a vertex format to match the format used with FBX?
Yes, assuming the FBX buffer you get is a simple list of vertex data.

some formats will first have a list of points and their positions, followed by a list of triangles, and the indices of the points that makes them. That will not work.
 

hippyman

Member
Aaah I see what you mean. I've never messed with any other formats so I'm new to this. I'm still unsure on how the FBX sdk handles everything. Now that I've got an idea on how I'm going to render the models, I just need to start reading up some more in the FBX documentation. I appreciate the help guys. I think I can probably mark this as solved.
 
Top