FAQ  •  Register  •  Login

Doom 3 engine release and game code

Moderator: Inside3D Admins

<<

mh

User avatar

Posts: 2172

Joined: Sat Jan 12, 2008 1:38 am

Post Thu Nov 24, 2011 2:00 am

Re: Doom 3 engine release and game code

I found the part of the code that was changed; look in draw_common.cpp and find this:
  Code:
   // patent-free work around
   if (!external)
   {
      // "preload" the stencil buffer with the number of volumes
      // that get clipped by the near or far clip plane
      qglStencilOp (GL_KEEP, tr.stencilDecr, tr.stencilDecr);
      GL_Cull (CT_FRONT_SIDED);
      RB_DrawShadowElementsWithCounters (tri, numIndexes);
      qglStencilOp (GL_KEEP, tr.stencilIncr, tr.stencilIncr);
      GL_Cull (CT_BACK_SIDED);
      RB_DrawShadowElementsWithCounters (tri, numIndexes);
   }

The reverse is really only relevant if the view is inside a shadow volume so in the common case it's not actually needed at all. No, the original code isn't there. Performance drops off maybe 25% or a little more for me with the new code.

Interesting that huge chunks of the console code are almost unchanged from Quake.
Like the fifth day of playing 24-hour Scrabble when you don't want to use any letters because each one means a world to you because you're so deranged.
<<

mh

User avatar

Posts: 2172

Joined: Sat Jan 12, 2008 1:38 am

Post Thu Nov 24, 2011 3:16 am

Re: Doom 3 engine release and game code

glStencilOpSeparate. :)

Available on all hardware with OpenGL 2.0 or better, halves the number of passes needed to draw shadows, runs maybe 1.5 x faster on average (and even faster in scenes with heavy shadows, like the first map with the dropship).
  Code:
      if (!external)
      {
         qglStencilOpSeparate (backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, tr.stencilDecr, tr.stencilDecr);
         qglStencilOpSeparate (backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, tr.stencilIncr, tr.stencilIncr);

         RB_DrawShadowElementsWithCounters (tri, numIndexes);
      }

      qglStencilOpSeparate (backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, GL_KEEP, tr.stencilIncr);
      qglStencilOpSeparate (backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, GL_KEEP, tr.stencilDecr);

      RB_DrawShadowElementsWithCounters (tri, numIndexes);

You watching this, Spike. :twisted:
Like the fifth day of playing 24-hour Scrabble when you don't want to use any letters because each one means a world to you because you're so deranged.
<<

mh

User avatar

Posts: 2172

Joined: Sat Jan 12, 2008 1:38 am

Post Thu Nov 24, 2011 3:40 am

Re: Doom 3 engine release and game code

Interesting...

Here's the GL calls that the original code made; this was for the non-reverse case:
  Code:
glActiveStencilFaceEXT(GL_BACK)
glStencilOp(GL_KEEP,GL_KEEP,GL_INCR_WRAP)
glActiveStencilFaceEXT(GL_FRONT)
glStencilOp(GL_KEEP,GL_KEEP,GL_DECR_WRAP)
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)
glDisable(GL_CULL_FACE)
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER,270)
glDrawElements(GL_TRIANGLES,480,GL_UNSIGNED_INT,0x0000) VP=5
And here's what Carmack's reverse looked like:
  Code:
glActiveStencilFaceEXT(GL_BACK)
glStencilOp(GL_KEEP,GL_DECR_WRAP,GL_KEEP)
glActiveStencilFaceEXT(GL_FRONT)
glStencilOp(GL_KEEP,GL_INCR_WRAP,GL_KEEP)
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)
glDisable(GL_CULL_FACE)
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER,2208)
glDrawElements(GL_TRIANGLES,444,GL_UNSIGNED_INT,0x0000) VP=5  Time= 12us

It seems as though quite a lot more was changed for the released code than we were given to understand.....

Just tried out the reverse with glStencilOpSeparate and yes, it works.
Like the fifth day of playing 24-hour Scrabble when you don't want to use any letters because each one means a world to you because you're so deranged.
<<

Spike

Posts: 2084

Joined: Fri Nov 05, 2004 3:12 am

Location: UK

Post Thu Nov 24, 2011 6:10 am

Re: Doom 3 engine release and game code

your 'original code' uses calls to glActiveStencilFaceEXT, which is the nvidia-specific form of glStencilOpSeparateATI which was made core in gl3.

almost sounds like the patentless code supports only the common fallback case?
<<

mh

User avatar

Posts: 2172

Joined: Sat Jan 12, 2008 1:38 am

Post Thu Nov 24, 2011 10:05 am

Re: Doom 3 engine release and game code

The original code came from a GLIntercept log while the engine was running so I'm pretty certain that it's the Real Thing.

Guess you're right about the patentless code though.
Like the fifth day of playing 24-hour Scrabble when you don't want to use any letters because each one means a world to you because you're so deranged.
<<

mh

User avatar

Posts: 2172

Joined: Sat Jan 12, 2008 1:38 am

Post Thu Nov 24, 2011 7:15 pm

Re: Doom 3 engine release and game code

Spike wrote:your 'original code' uses calls to glActiveStencilFaceEXT, which is the nvidia-specific form of glStencilOpSeparateATI which was made core in gl3.

almost sounds like the patentless code supports only the common fallback case?


According to http://www.opengl.org/sdk/docs/man/xhtml/glStencilOpSeparate.xml glStencilOpSeparate went core in 2.0, making it safer to use and less likely to need fallbacks.
Like the fifth day of playing 24-hour Scrabble when you don't want to use any letters because each one means a world to you because you're so deranged.
<<

reckless

Posts: 1651

Joined: Thu Jan 24, 2008 12:04 pm

Location: inside tha debugger

Post Thu Nov 24, 2011 11:25 pm

Re: Doom 3 engine release and game code

agh :S missed the release.

Just returned from the hospital after having my gall bladder removed cause of a nasty infection.

Looking forward to play around with this though :) hmm some of the function names look suspiciously familiar ?.
Productivity is a state of mind.
<<

frag.machine

User avatar

Posts: 1486

Joined: Sat Nov 25, 2006 1:49 pm

Post Fri Nov 25, 2011 2:02 am

Re: Doom 3 engine release and game code

reckless wrote:agh :S missed the release.

Just returned from the hospital after having my gall bladder removed cause of a nasty infection.

Looking forward to play around with this though :) hmm some of the function names look suspiciously familiar ?.



Gall bladder ? Wow! Hope everything is ok now. :( My sister got some gall bladder issues years ago, luckily she got fine quickly (no surgery was required).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
<<

qbism

User avatar

Posts: 811

Joined: Thu Nov 04, 2004 5:51 am

Post Fri Nov 25, 2011 3:00 am

Re: Doom 3 engine release and game code

mh wrote:Interesting. Seems the editor uses MFC which won't work with Express. And, since the editor is integrated into the engine, it means that some surgery is required.


How is this handled in the Linux build? No editor in Linux?

Get well soon, reckless.
<<

Eluan

Posts: 10

Joined: Sun Jun 15, 2008 9:03 am

Location: Florianópolis, Brazil

Post Fri Nov 25, 2011 3:37 am

Re: Doom 3 engine release and game code

Nice to see so much Quake code into Doom3, especially that QuakeC is back! (well, more or less...)
<<

mh

User avatar

Posts: 2172

Joined: Sat Jan 12, 2008 1:38 am

Post Fri Nov 25, 2011 10:31 am

Re: Doom 3 engine release and game code

qbism wrote:
mh wrote:Interesting. Seems the editor uses MFC which won't work with Express. And, since the editor is integrated into the engine, it means that some surgery is required.


How is this handled in the Linux build? No editor in Linux?

Get well soon, reckless.

edit_stub.cpp:
  Code:
void   RadiantInit( void ) { common->Printf( "The level editor Radiant only runs on Win32\n" ); }


And for every other tool.
Like the fifth day of playing 24-hour Scrabble when you don't want to use any letters because each one means a world to you because you're so deranged.
<<

reckless

Posts: 1651

Joined: Thu Jan 24, 2008 12:04 pm

Location: inside tha debugger

Post Fri Nov 25, 2011 2:48 pm

Re: Doom 3 engine release and game code

thanks guys :) im ok just some aches in my stomach so i should be fine again in a few weeks.

hmm is'nt radiant based on gtk ? if it is it should work fine on linux.
Productivity is a state of mind.
<<

mh

User avatar

Posts: 2172

Joined: Sat Jan 12, 2008 1:38 am

Post Fri Nov 25, 2011 5:28 pm

Re: Doom 3 engine release and game code

Not this Radiant; this one is heavily MFC.
Like the fifth day of playing 24-hour Scrabble when you don't want to use any letters because each one means a world to you because you're so deranged.
<<

reckless

Posts: 1651

Joined: Thu Jan 24, 2008 12:04 pm

Location: inside tha debugger

Post Fri Nov 25, 2011 6:57 pm

Re: Doom 3 engine release and game code

Hmm ok well i bet the linux guys can whip something up, maybe modify gtkradiant ?.

Taking a quick stroll through the source since i cannot sit before my PC for very long at a time yet, it builds fine though it coughs a bit on some paths that the danish version of win7 does not have but else it seems to compile.

I understand that carmacks reverse was taken out though since its the Z-Fail method which rick also used in his early shadow volume code (long before carmack or creative) i dunno if were trespassing into creative land if we just slam together our own versions of the Z-Fail method ?.
Productivity is a state of mind.
<<

Spirit

Posts: 867

Joined: Sat Nov 20, 2004 9:00 pm

Post Fri Nov 25, 2011 7:01 pm

Re: Doom 3 engine release and game code

Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
PreviousNext

Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.
Icons provided by Aha Soft