Jump to content
The Dark Mod Forums

backfacing textures


Mr Lemony Fresh

Recommended Posts

I'm just wondering whether Doom 3 supports backfacing faces. Not asking for another feature, I just want to know my limitations.

 

As said, the 'twosided' keyword will be shown on both faces, just be careful about using it on super complex geometry. Not 100% sure that it works on patches either, but I don't see why not.

Link to comment
Share on other sites

Patches, brushes and models are identical from the Doom 3 renderer's point of view. The only difference is how the geometry is specified (and whether it is optimised during map compilation).

 

According to the documentation, "twosided" should turn off shadows. It sounds like something odd is going on if a twosided material is producing shadows on certain hardware.

Link to comment
Share on other sites

The twosided keyword tended to produce unpredictable effects on models, so I stopped using it.

Link to comment
Share on other sites

As said, the 'twosided' keyword will be shown on both faces, just be careful about using it on super complex geometry. Not 100% sure that it works on patches either, but I don't see why not.

 

Yes it does very useful for single patch windows

I always assumed I'd taste like boot leather.

 

Link to comment
Share on other sites

Springheel, I'm wondering whether you can help me test my model when I complete the UVW to see if 2 sided faces will work well? My model is coming along pretty suitable to go into a mission, but the last model I put in game was a Quake 2 player model XD I'm damn determined to see this character model through to production whether our mission is good or not!

 

EDIT: I'll create a basic text diffuse map and alpha map, and i just want to see how it looks in game, so getting it into the dark mod might need a little assistance since I'm new to it.

Edited by Mr Lemony Fresh
18588.png
Link to comment
Share on other sites

Springheel, I'm wondering whether you can help me test my model when I complete the UVW

 

Sure thing. Just let me know when you're ready.

Link to comment
Share on other sites

A word of caution about the "twosided" keyword. All what it does is that at load time doom duplicates all faces, the flips the normals.

 

That means two things:

 

* if you later switch the model via skin to onesided, it will still be twosided

* there are now two surfaces, one original and one flipped, and they will be rendered in two drawcalls per light instead of one. That means essentially if you have a model with a single surface (glass window f.i). you just doubled the drawcalls (and polys!) it has. So it means it will render twice as slow.

 

So it might be better to just duplicate the faces by yourself, that way at least you get everything done in one drawcall.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

We'll have to put you on Mastermind - "tels answering questions on Doom3 rendering" I can see it all now! :laugh:

 

Alex, I'll take "Visportals" for 500 :D

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

A word of caution about the "twosided" keyword. All what it does is that at load time doom duplicates all faces, the flips the normals.

 

I'm curious -- how did you discover this? Is it exposed in the code at some level? It seems an odd thing to do, certainly, given that GL provides full control over whether backface culling is used or not.

 

* there are now two surfaces, one original and one flipped, and they will be rendered in two drawcalls per light instead of one. That means essentially if you have a model with a single surface (glass window f.i). you just doubled the drawcalls (and polys!) it has. So it means it will render twice as slow.

 

So it might be better to just duplicate the faces by yourself, that way at least you get everything done in one drawcall.

 

I'm not sure I understand this suggestion: how is duplicating the front and back faces manually any different to what Doom 3 is doing automatically? It's not going to render both the front and the back polygons simultaneously, because only one of them has its normal pointing towards the viewer at any one time.

Link to comment
Share on other sites

I'm curious -- how did you discover this? Is it exposed in the code at some level? It seems an odd thing to do, certainly, given that GL provides full control over whether backface culling is used or not.

 

I discovered this while working on this:

 

http://forums.thedarkmod.com/topic/11372-improving-the-improved-lod-system/page__view__findpost__p__234712__hl__LODE__fromsearch__1 (Internal link only, sorry public :)

 

It is tracked as bug here:

 

http://bugs.angua.at/view.php?id=2297

 

Technical explanation:

 

When the code loads a model, it has for instance, one surface, lets call it "A". After load, the code calls FinishSurfaces(). This does, among other things like calculating shadows, duplicate twosided surfaces. It does so by creating another surface on the model, copy the first surface, then flip it around. (I am unsure if it just flips the tri indexes and the normals, or if it does something more complicated).

 

I guess the reason that is uses two surfaces is that you can always throw away the second surface, and end up with the original model. The code never does this, tho, and there are remarks inside the engine code to that effect, too.

 

The effect is that you have now a model with:

 

* one base surface (A)

* one extra surface, B

 

During rendering, each surface is issued in an extra drawcall (since the code can't know that these surfaces could be rendered in one go).

 

The problem with that duplication are:

 

* if you clear out the model data, you need to recreate surface A, and then either: manually recreate surface B, or call the expensive FinishSurfaces() again.

* if you switch the shader of surface A, surface B is still around, so you still get both sides rendered (this came to light - no pun :) while I switched the material from our bushes from onesided to twosided. That looks much better, but it is no no more possible to have none-sided bushes. (The one-sided/two-sided means here that you can look through the bush material, which means you see oth front and back at the same time, thus creating the illusion that it is a round bush. If it is one-sided, you only see ever the front side, and thus if you walk around, faces are constantly appearing on one side and disappearing on the side, that looks rather odd close up.)

 

I'm not sure I understand this suggestion: how is duplicating the front and back faces manually any different to what Doom 3 is doing automatically? It's not going to render both the front and the back polygons simultaneously, because only one of them has its normal pointing towards the viewer at any one time.

 

Actually, if you have a two-sided material, you do have both front-facing polygons (the original) and back-facing ones (the copy), and thus it might render them simlultanously. Thik a cylinder (where you can see both front and back if the material is transparent). You are right, ona window it wouldn't render both at the same time, but and thats the important bit, it still issues the drawcall. That is because the renderer doesn't know which side will be visible, that is what the graphic hardware decides during rendering.

 

Now the 100$ question: how does duplicating the surface yourself save the drawcall? Easy, you duplicate all tris, flip them around, and then assign them the same shader as the original. During load, you end up with a model with one surface A with twice the amounts of tris and if the shader is one-sided (which you must ensure!) D3 does no duplicating, thus only one surface on the model.

 

I did describe the entire process and effect here:

 

http://forums.thedarkmod.com/topic/11760-making-lod-models/page__view__findpost__p__232759

 

I hope I explained this in an understandable way :)

 

 

Edit: There might be a confusion here with "backsided" polygons. Whether a polygon/triangle is "backsided" e.g. facing away from the camera (player) is determined during rendering, but the CPU still has the GPU to tell "please check if it needs to be rendered, and if so, render it". Think of a transparent window with two sides, depending on which side you are on, only one side is rendered (the side you look at), but discovering which side that is can only be done by "attempting to render both, and then culling one". If you walk around the window, suddenly the other side gets culled and you see the one that was hidden at first.

 

Or in other words: whether the window material is "two-sided with a single polygon (that gets duplicated at load time)", or "one-sided with two manually flipped polygons back-to-back" doesn't matter during rendering, you see the same result. Except in the first case, the window is drawn in two steps (drawcalls), and in the second case it is drawn in one step (drawcall).

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Easy, you duplicate all tris, flip them around, and then assign them the same shader as the original.

 

This will result in z-fighting if you don't move them slightly apart.

Link to comment
Share on other sites

This will result in z-fighting if you don't move them slightly apart.

 

I don't think so, because the flipped-around face is not visible from one side.

 

Here is a drawing (for instance for glass panes in windows):

 

post-144-129146934705_thumb.png

 

And here for a two-sided cylinder (which our bush models essentially are, even tho the cylinder is wider at the top than at the botton):

 

post-144-129146919157_thumb.png

 

Sometimes I think people still didn't clearly understand this issue and how it works :) I hope this clears it finally up.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

I don't think so, because the flipped-around face is not visible from one side.

 

You can probably get away with it if the polys aren't shadowcasting, but otherwise the shadow-volume from the back-face z-fights with the front-face. That's why the two-sided keyword turns off shadows automatically.

Link to comment
Share on other sites

I hope I explained this in an understandable way :)

 

Yes, I understand now, thanks. It is certainly more complicated than what I imagined, which was that the twoSided keyword simply turns off backface culling and shadow-volume generation for affected surfaces. I guess this also explains why somebody was seeing inconsistent shadow results when using twoSided materials on an SLI setup.

 

It still seems odd that Doom 3 renders the backsided faces in a separate draw call though, rather than batching them with the corresponding materials on the original mesh (thereby achieving the same result as your manual doubling suggestion).

Link to comment
Share on other sites

You can probably get away with it if the polys aren't shadowcasting, but otherwise the shadow-volume from the back-face z-fights with the front-face. That's why the two-sided keyword turns off shadows automatically.

 

Yeah, but if you are using the two-sided keyword for "transparent" surfaces, they don't cast shadows, anyway!

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Yes, I understand now, thanks. It is certainly more complicated than what I imagined, which was that the twoSided keyword simply turns off backface culling and shadow-volume generation for affected surfaces. I guess this also explains why somebody was seeing inconsistent shadow results when using twoSided materials on an SLI setup.

 

It still seems odd that Doom 3 renders the backsided faces in a separate draw call though, rather than batching them with the corresponding materials on the original mesh (thereby achieving the same result as your manual doubling suggestion).

 

Maybe whoever coded that stumbled over the fact that you can't change the allocation of triangles for a surface easily - you can either throw it away and recreate it, or add a new surface, but there is no method that says "change the allocated number to be N * 2".

 

Or they coded it the easy way and didn't think of the drawcalls. Or there is another reason we don't see :)

 

Anyway, it is certainly complicated :)

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 1 reply
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...