Forum

Doom 3 engine release and game code

Discuss programming topics for any language, any source base. If it is programming related but doesn't fit in one of the below categories, it goes here.

Moderator: InsideQC Admins

Re: Doom 3 engine release and game code

Postby mh » Thu Nov 24, 2011 2:00 am

I found the part of the code that was changed; look in draw_common.cpp and find this:
Code: Select all
   // 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.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby mh » Thu Nov 24, 2011 3:16 am

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: Select all
      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:
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby mh » Thu Nov 24, 2011 3:40 am

Interesting...

Here's the GL calls that the original code made; this was for the non-reverse case:
Code: Select all
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: Select all
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.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby Spike » Thu Nov 24, 2011 6:10 am

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?
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Doom 3 engine release and game code

Postby mh » Thu Nov 24, 2011 10:05 am

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.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby mh » Thu Nov 24, 2011 7:15 pm

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.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby revelator » Thu Nov 24, 2011 11:25 pm

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.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby frag.machine » Fri Nov 25, 2011 2:02 am

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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Doom 3 engine release and game code

Postby qbism » Fri Nov 25, 2011 3:00 am

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.
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: Doom 3 engine release and game code

Postby Eluan » Fri Nov 25, 2011 3:37 am

Nice to see so much Quake code into Doom3, especially that QuakeC is back! (well, more or less...)
Eluan
 
Posts: 10
Joined: Sun Jun 15, 2008 9:03 am
Location: Florianópolis, Brazil

Re: Doom 3 engine release and game code

Postby mh » Fri Nov 25, 2011 10:31 am

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: Select all
void   RadiantInit( void ) { common->Printf( "The level editor Radiant only runs on Win32\n" ); }


And for every other tool.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby revelator » Fri Nov 25, 2011 2:48 pm

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.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby mh » Fri Nov 25, 2011 5:28 pm

Not this Radiant; this one is heavily MFC.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby revelator » Fri Nov 25, 2011 6:57 pm

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.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby Spirit » Fri Nov 25, 2011 7:01 pm

Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

PreviousNext

Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest