Author Topic: Rendering G3D Properly  (Read 2228 times)

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Rendering G3D Properly
« on: 21 August 2012, 12:54:41 »
Ludum Dare 24 approaches fast (tell me if you want to join the usual team; please please do!).

I want to fully understand how to properly render G3D V4 files.

The properties flag has 0x01 for 'draw team colour through transparent parts of texture'.  Is this correct?

And what does properties 0x02 'two-sided' mean?  Does it mean to enable/disable GL_CULL_FACE?

What's the winding? GL_CCW?

How do you ensure that you draw the semi-transparent bits and the opaque bits in the right order etc?

And so on!  What else should I know/do?

I will be sharing my webGL loader, obviously: github, and eventually if gh-pages builds, online too.  I had to do some surgery to binary-load floats properly and fast.  DataView API is too new for most browsers and TypedArray.set() has bugs on my FireFox etc.

(I've run G3dScan auto-optimise.  Can, before eh Friday, it have a way to auto join meshes that are in the same texture and have the same flags etc and are compatible for joining?  With big webGL scenes, the number of drawElements calls is actually a factor.  One thing is sure- Mr War isn't going to optimise them in Blender)
« Last Edit: 21 August 2012, 14:13:00 by will »

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Rendering G3D Properly
« Reply #1 on: 21 August 2012, 20:36:16 »
A few answers from the megaglest code: (think GAE is the same here)

   if(renderMode==rmSelection && mesh->getNoSelect()==true)
   {// don't render this and do nothing
      return;
   }

   //set cull face
   if(mesh->getTwoSided()) {
      glDisable(GL_CULL_FACE);
   }
   else{
      glEnable(GL_CULL_FACE);
   }

   //set color
   if(renderColors) {
      Vec4f color(mesh->getDiffuseColor(), mesh->getOpacity());
      glColor4fv(color.ptr());
   }

textureFlags currently only seems to indicate if the mesh has a texture (1) or not (0)

and each time we render its always:

glFrontFace(GL_CCW);

wciow

  • Behemoth
  • *******
  • Posts: 968
    • View Profile
Re: Rendering G3D Properly
« Reply #2 on: 21 August 2012, 21:24:58 »
(I've run G3dScan auto-optimise.  Can, before eh Friday, it have a way to auto join meshes that are in the same texture and have the same flags etc and are compatible for joining?  With big webGL scenes, the number of drawElements calls is actually a factor.  One thing is sure- Mr War isn't going to optimise them in Blender)

How many models do you need optimizing? If its a small number I can do it by hand in Blender for you.
Check out my new Goblin faction - https://forum.megaglest.org/index.php?topic=9658.0

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Rendering G3D Properly
« Reply #3 on: 23 August 2012, 07:20:16 »
Yeah its a puzzle that https://github.com/williame/barebones.js doesn't render the G3D properly :(

LD is this weekend, and we haven't made any models yet.

We are leaning towards making a real nano-RTS, so we'll have lots of models.

 

anything