Jump to content
  • Advertisement
Sign in to follow this  
golgoth13

OpenGL Rendering Multiple Materials on the same Mesh?

This topic is 3453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I want to introduce what we know as Clusters in some 3D packages in my 3D engine. The main purpose here is to assign multiple materials on the same mesh. My question is: how do I organize the data and how do I send it to OpenGL?Create a polygon list for each material? Draw the entire mesh then draw over with the polygon list and his associate material? Or maybe, instead of creating a polygon list for each material is there a way to tell OpenGL: draw this list of faces but omit those ones? Some kind of a mask, an array matching a face list, of 0 and -1 for instance… where -1 mean not to draw this face. I m curious… any constructive inputs would be appreciated!

Share this post


Link to post
Share on other sites
Advertisement
If the vertex format/layout is the same across all vertices for all the materials, then you can use one vertex buffer for all the verts, but separate index buffers (one for each material). If the vertex layouts are different (i.e., one material requires vertex color, another requires tangents, etc.), then you'll want separate vertex buffers as well (so you'd have 1 VB and 1 IB per material).

So you'll end up slicing and dicing the mesh in some way shape or form; when you draw, you draw only the polygons affected by the current material.

I use DirectX these days but the ideas are pretty much identical, use VBOs and whatever the equivalent of index buffers are.

Share this post


Link to post
Share on other sites
With a deferrred renderer that would be pretty easy, IMHO. You could use a "material texture" on the mesh and thus render each pixel's material id to the g-buffer. This way you wouldn't be limited to one material per polygon and splitting the mesh.

Share this post


Link to post
Share on other sites
thx for your inputs guys,

I ve read the thread on deferred rendering:

http://www.gamedev.net/community/forums/topic.asp?topic_id=424468

Maybe I ve missed something but while deferred rendering is compared to a forward rendering, I didn’t understand how the deferred renderer worked, did I missed the definition?

Share this post


Link to post
Share on other sites
Deferred rendering is an altogether separate topic, and while a perfectly valid technique under the right circumstances, is probably overkill if you are currently using a forward renderer (which you probably are) and all you want is to add support for multiple materials to your meshes.

Briefly, deferred rendering means you render geometric properties and material info to render targets without performing any lighting (for example, render normals to your render target), then, in later passes, render light volumes projected into screen space, accessing the previous pass's render targets to perform the lighting. If none of this sounds familiar or like something you feel like tackling, I would recommend sticking with my first post.

Share this post


Link to post
Share on other sites
actually, I have use this technique for cinematic in post production but I had no clue it was already popular for real time... as a matter of fact, I m really interested in this topic, that said, I have no clue how it does make multi materials easier to manage, can you elaborate on this?

Any good references on the deferred rendering would be more than welcome as well. I m definitely going to give this deferred rendering a try.

Thx for the insight.

Share this post


Link to post
Share on other sites
Look up these terms on google:

deferred renderer
light-indexed deferred renderer
light pre-pass renderer

Lots of good info there.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!