Jump to content
The Dark Mod Forums

TDM - What Are You Working On?


Mr Mike

Recommended Posts

  • Replies 175
  • Created
  • Last Reply

Top Posters In This Topic

It looks like you're modelling the leaves with a low number of polygons rather than an alphatest map... Is there a reason why?

 

 

THATS what they are called then. Know any good tutorials for alphatest maps? You are right, the leaves are polys,the whole plant is way too hi-poly but I just wanted to see the design completed. But I have a problem and need help desperately. I cannot get my VIPER window to render objects at all. After rendering the object, when I go to press render in VIPER nothing happens. DId I shut something off or what the heck? This is driving me nutz!

Edited by Maximius
Link to comment
Share on other sites

Unfortunately, I know very little about 3D modelling, so I can't help you there. But if you have any questions about how to create an alpha-tested material or how D3 renders things...

 

 

I'd love to start making alpha test transparencies or whatever the hell they are, whats a good tutorial to get me started? And what software do you make alphatests with? Is it Lightwave or something else? Remember, I know very little about stuff like this so please don't assume I know what you are referring to most of the time.

Link to comment
Share on other sites

Ok, I'll try to be comprehensive then... (if there's any part that needs better explaning, feel free to ask)

 

The Alpha Channel

 

In most pictures, each pixel's color is composed of 3 numbers: red, green and blue. Another way to think of a color picture is as composed of 3 greyscale images. For example the following color picture

post-244-1168452656_thumb.jpg

is composed of:

post-244-1168452663_thumb.jpg (red)

post-244-1168452669_thumb.jpg (green)

post-244-1168452674_thumb.jpg (blue)

Each of these separate greyscale images is called a "channel". Notice how the bluish sections are bright on the blue channel, and the orangish sections are bright on the red and green channels. (since yellow/orange is a mixture of red and green)

 

For transparency, another channel is added to the picture, called the "alpha" channel. A pixel with a high alpha value is more opaque, and a pixel with a low alpha value is more transparent. In truth, the alpha channel doesn't need to be used to store transparency information - it's just an invisible extra channel that can be used for whatever you want to use it for - but typically it's interpreted as opacity.

 

Materials

 

To make a regular material that interacts with lighting, you need to create 3 pictures... the diffuse-map, the specular-map (optional) and the normal-map. (actually all of them are optional, but almost all textures have a diffuse and normal map) Then, inside a file named materials/anything_you_want_to_name_the_file.mtr, you add a material declaration. An example material declaration would be:

textures/mymaterial
{
// Uses "textures/mymaterial_local.tga" as the normal-map.
bumpmap textures/mymaterial_local
// Uses "textures/mymaterial.tga" as the diffuse-map.
diffusemap textures/mymaterial
// Uses "textures/mymaterial_s.tga" as the specular-map.
specularmap textures/mymaterial_local_s
}

 

Note that "bumpmap textures/mymaterial_local" is a shortcut for:

{
blend bumpmap
map textures/mymaterial_local
}

The same goes for the other keywords.

 

Alpha-testing

 

One of Doom 3's biggest weaknesses is its handling of translucent textures... Doom 3 does no depth-sorting of translucent triangles, and it's not possible to efficiently render shadows on them either. So allowing regular materials to have a full range of transparencies is out of the question and would lead to graphical errors or horrific performance. But it is possible for D3 to efficiently and correctly draw a triangle that consists only of fully opaque and fully translucent areas. This is the purpose of "alpha-testing"... You specify a threshold level of alpha above which a pixel is considered fully opaque, and anything under that level of alpha is considered fully transparent. (it's called alpha-testing, because the alpha channel is tested before deciding whether or not to draw a pixel)

 

To construct an alpha-tested material, you first construct a diffusemap image with an alpha channel, then you create material in which the alphatest keyword is specified in the diffusemap stage. For example:

textures/mymap/leafs
{
bumpmap textures/mymap/leafs_local
{
	blend diffusemap
	map textures/mymap/leafs
	// parts of the image with an alpha of more than 0.5 are opaque
	alphatest 0.5
}
specularmap textures/mymap/leafs_s
}

I think it may be possible to use the alphatest keyword in other stages as well, but I haven't done much experimenting with it, so I don't know for sure.

Link to comment
Share on other sites

Gildoran:

For transparency, another channel is added to the picture, called the "alpha" channel. A pixel with a high alpha value is more opaque, and a pixel with a low alpha value is more transparent. In truth, the alpha channel doesn't need to be used to store transparency information - it's just an invisible extra channel that can be used for whatever you want to use it for - but typically it's interpreted as opacity.

 

So the alpha channel is where the actual pixels of your image are emitted? You say its invisible but you can make it visible if you assign opacity to it, no? Can you color these alpha pixels as well?

 

 

G:To make a regular material that interacts with lighting, you need to create 3 pictures... the diffuse-map, the specular-map (optional) and the normal-map. (actually all of them are optional, but almost all textures have a diffuse and normal map)

 

What software do I use to make these pictures? If some or all are optional, is there another way to do it too? Or is it quicker to only do one?

 

G:Then, inside a file named materials/anything_you_want_to_name_the_file.mtr, you add a material declaration. An example material declaration would be:

textures/mymaterial

 

Where do I do stuff like this? I mean what software do I use to open these files and to enter code.

 

G:

But it is possible for D3 to efficiently and correctly draw a triangle that consists only of fully opaque and fully translucent areas.

 

Shouldn't you stick to four sided figures anyway when modeling? Or are triangles important to alpha test images?

 

G:To construct an alpha-tested material, you first construct a diffusemap image with an alpha channel, then

 

Ill look these terms up on google and see what kind of instructions I can find.

Link to comment
Share on other sites

So the alpha channel is where the actual pixels of your image are emitted? You say its invisible but you can make it visible if you assign opacity to it, no? Can you color these alpha pixels as well?
No, that's not what I meant... I'm probably not doing a good job of conveying the idea. Let me put it another way: Normally a pixel has a color that has 3 components (red, green and blue)... However, when drawing such a pixel, you have no idea how opaque it should be. So somebody got the idea to also store the opacity of a pixel in a fourth color component called "alpha". Such pixels have 4 color components (red, green, blue and alpha).

 

What software do I use to make these pictures? If some or all are optional, is there another way to do it too? Or is it quicker to only do one?
You use image editing programs to make the images. (or in the case of models, you may want to use D3 to render the normalmap) For regular textures you can just use an image editing program to create them all. I highly recommend GIMP, since it's powerful and free. I like to use the GIMP normalmap plugin to generate normalmaps for textures. For information on what diffuse/specular/normal maps are, I recommend looking at the D3 Mod Wiki texturing page. To omit a specularmap, simply omit the specularmap line in the material declaration.

 

Where do I do stuff like this? I mean what software do I use to open these files and to enter code.
Any text-editor will work, though it's a good idea to use one suitable for programming such as notepad (click on the start menu, click "run..." and type "notepad") or Notepad++. I would avoid using Microsoft Word.

 

Shouldn't you stick to four sided figures anyway when modeling? Or are triangles important to alpha test images?
Doom 3 can only render triangles. However, I'm under the impression that quads (four-sided polygons) are often useful for subdivision (high-poly) modelling.
Link to comment
Share on other sites

g:

No, that's not what I meant... I'm probably not doing a good job of conveying the idea. Let me put it another way: Normally a pixel has a color that has 3 components (red, green and blue)... However, when drawing such a pixel, you have no idea how opaque it should be. So somebody got the idea to also store the opacity of a pixel in a fourth color component called "alpha". Such pixels have 4 color components (red, green, blue and alpha).

 

 

Ok that makes sense. The alpha channel controls the opacity of the rest of the channels.

 

g:

You use image editing programs to make the images. (or in the case of models, you may want to use D3 to render the normalmap) For regular textures you can just use an image editing program to create them all. I g:highly recommend GIMP, since it's powerful and free. I like to use the GIMP normalmap plugin to generate normalmaps for textures. For information on what diffuse/specular/normal maps are, I recommend looking at the D3 Mod Wiki texturing page. To omit a specularmap, simply omit the specularmap line in the material declaration.

 

I found this site, can you tell me which file to download, Im totally lost.

 

ftp://ftp.gimp.org/pub/gimp/v2.2/

 

 

g:Any text-editor will work, though it's a good idea to use one suitable for programming such as notepad (click on the start menu, click "run..." and type "notepad") or Notepad++. I would avoid using Microsoft Word.

 

Doom 3 can only render triangles. However, I'm under the impression that quads (four-sided polygons) are often useful for subdivision (high-poly) modelling.

 

If D3 only renders triangles, isnt this a problem for lightwave creations that use mostly quads? Or do you mean when you make something in D3 its only in triangles, that would make more sense I guess.

Edited by Maximius
Link to comment
Share on other sites

Quads should just get converted to two triangles, I believe.

 

As for the GIMP, there's only source code available from that link, which you probably don't want. Try this page instead: http://gimp-win.sourceforge.net/

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Quads should just get converted to two triangles, I believe.

 

Don't you have to triangulate your mesh before you export it? I know this is the case when exporting ASE from Blender, but maybe it is different for LWO files.

Link to comment
Share on other sites

Probably!

 

In 3ds max, what look like quads are actually just two triangles; you can see the difference in the shading, it's just that the edge between them is "hidden". Maybe Lightwave is different, I don't know.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Probably!

 

In 3ds max, what look like quads are actually just two triangles; you can see the difference in the shading, it's just that the edge between them is "hidden". Maybe Lightwave is different, I don't know.

 

 

Crispy, thanks for that link, I got GIMP installed now and I'll start looking at it tonight.

Link to comment
Share on other sites

Alpha-testing

 

One of Doom 3's biggest weaknesses is its handling of translucent textures... Doom 3 does no depth-sorting of translucent triangles, and it's not possible to efficiently render shadows on them either. So allowing regular materials to have a full range of transparencies is out of the question and would lead to graphical errors or horrific performance. But it is possible for D3 to efficiently and correctly draw a triangle that consists only of fully opaque and fully translucent areas. This is the purpose of "alpha-testing"... You specify a threshold level of alpha above which a pixel is considered fully opaque, and anything under that level of alpha is considered fully transparent. (it's called alpha-testing, because the alpha channel is tested before deciding whether or not to draw a pixel)

 

To construct an alpha-tested material, you first construct a diffusemap image with an alpha channel, then you create material in which the alphatest keyword is specified in the diffusemap stage. For example:

textures/mymap/leafs
{
bumpmap textures/mymap/leafs_local
{
	blend diffusemap
	map textures/mymap/leafs
	// parts of the image with an alpha of more than 0.5 are opaque
	alphatest 0.5
}
specularmap textures/mymap/leafs_s
}

I think it may be possible to use the alphatest keyword in other stages as well, but I haven't done much experimenting with it, so I don't know for sure.

Question. Aren't (partially) transparent triangles correctly depth-sorted? As alpha'd triangles aren't rendered as alternately opaque and invisible, it's safe to assume that transparent textures are being correctly blended. Ignoring shadowing, why would it cause errors to correctly render it?

Link to comment
Share on other sites

As far as I know, doom 3 does not depth-sort ANY triangles, including partially transparent ones.

post-244-1168576484_thumb.jpg

The closest thing it has is sorting by category (eg, fully opaque triangles are drawn first, then decals, then glass, etc), but lighting is all drawn before anything else. The reason I say it would either lead to graphical errors or horrific performance is primarily due to shadows.

Link to comment
Share on other sites

It doesn't seem that hard to add a step that tags triangles as transparent--to specifically be ordered from back to front. For the most part, modern engines order polygons front-to-back for culling purposes, although a lot (and I am beginning to suspect D3E) just throw the whole mess at the graphics card for it to work out.

 

By the ways, that picture is fugly--c'mon, ordering isn't that hard, nor is it that resource/time consuming! Every damn frame has to be ordered one way or the other before it can be rendered! Graphics cards order everything front-to-back for culling purposes, and they reorder everything back-to-front (or rather, that which remains) for texturing! It can't be that fucking hard! <_<

 

Edit: As for shadows, probably the best performing way to get a reasonable facsimile of shadowing would be to use a projected texture of the surface, with the alpha map acting as a measure of intensity (transparent for full light, and opaque for none). Well implemented, I don't think that it would look any worse, that is, less realistic, than Doom 3's lighting.

 

I'm a bit fuzzy on how stencil shadows are any different than projected shadows (with the notable exception of the stencil itself), so I don't know how compatible projected textures are with volumetric shadows. Anyways, you can turn off shadowing on the triangles that have that have alpha. Either I'm missing something important, or Carmack is bitching over something that would take a week at most to implement and makes for so much better usability. :unsure:

Link to comment
Share on other sites

As far as I can imagine, Z-ordering from front to back would only be useful for minimizing fill-rate used by pixel-shaders... However, D3 starts by rendering opaque surfaces to the depth buffer and only uses the expensive pixel shaders once the depth-buffer is already filled, which I'm pretty sure is just as effective at minimizing fill-rate used by lighting, and doesn't require sorting all the triangles (which could be expensive). In short, I don't think Z-ordering would improve D3's performance, and it could degrade it.

 

Translucent surfaces ARE tagged as such, and are rendered only after all opaque surfaces have been drawn. I don't know why there's no option to depth-sort them. :(

 

Edit: Projected shadow textures work entirely differently from stencil shadows. The way D3 figures out how bright a light is at a given point works similarly to projected shadow textures. (they project the light texture onto the triangles like how you would normally project a shadow) The way stencil shadows work is more or less the same principle as the point-in-polygon crossing test, except 3D instead of 2D... (you're testing if a pixel is in a shadow polyhedron) Conceptually, you start at the opaque surface, and trace back towards the viewer, counting how many times you enter/exiting a shadow volume... If you exit more shadow volumes than you entered, the point was originally in shadow. (assuming the viewer isn't in shadow too) Fortunately, this can be done very fast on a graphics card using the following method: Start out the stencil buffer at 0. For each triangle of a shadow volume, draw the triangle (taking into account the depth buffer). If the triangle faces towards the viewer, add 1 to the stencil buffer, otherwise subtract 1. Once all shadow triangles are rendered, all positive pixels in the stencil buffer are in shadow and everything else is hit by the light. Again, this doesn't take into account whether the viewer is in shadow, and I haven't yet figured out how to deal with that.

 

It ends up having the advantage of pixel-perfect shadows but the disadvantage that you can't do image processing on the shadow to blur it. (also, pixels are either entirely in shadow or entirely lit)

Link to comment
Share on other sites

Z-ordering--damn, I forget these terms too easily! Z-ordering would mostly become useful when there are a lot of polys that Doom 3 wouldn't cull, like if you had a bunch of monsters in one room. However, that's dependent on how effective graphics cards are at culling unordered polygons. Anyways, I know for a fact that graphics cards are capable of doing some basic z-ordering (the depth buffer determines which poly is in front, doesn't it?), otherwise you'd be seeing z-fighting of distant objects and other such fun errors.

 

Edit: Huh, I always thought that the stencil was used to generate the shadow volume, rather than to emulate raycasting. Wouldn't having the camera in shadow cause the lighting to be screwed up?

Link to comment
Share on other sites

Z-ordering would mostly become useful when there are a lot of polys that Doom 3 wouldn't cull, like if you had a bunch of monsters in one room. However, that's dependent on how effective graphics cards are at culling unordered polygons.
I'm a bit skeptical of that since using Z-ordering to cull triangles sounds like it would take more work than it would save... especially since it's far more work to calculate an animated mesh's triangles than it is to render them. (in D3 I've seen areas with few lights and 100K triangles render at 30 fps because they were having to animate those triangles, and highly lit areas with 300K triangles run at 60 fps because all the meshes were static) But I guess I should go read some articles on culling using Z-sorting...

 

Anyways, I know for a fact that graphics cards are capable of doing some basic z-ordering (the depth buffer determines which poly is in front, doesn't it?), otherwise you'd be seeing z-fighting of distant objects and other such fun errors.
The whole purpose of a depth buffer is so that you don't need to sort triangles. You can draw them in any order and the image will look the same.

Edit: I think I may have misunderstood what you meant by that statement... If you're suggesting that the Z-fighting of distant objects would be because of limited precision of the depth buffer, I don't know anything about how many bits it usually has, so I can't say if I agree or disagree.

 

Edit: Huh, I always thought that the stencil was used to generate the shadow volume, rather than to emulate raycasting.
By rendering the sides of the shadow to the stencil-buffer you can calculate shadows far more quickly than if you were to raytrace each pixel one at a time.

 

Again, this doesn't take into account whether the viewer is in shadow, and I haven't yet figured out how to deal with that.
Wouldn't having the camera in shadow cause the lighting to be screwed up?
With what I've described, yes... D3 somehow accounts for this, but I don't know how.
Link to comment
Share on other sites

D3 somehow accounts for this, but I don't know how.

You have to "cap the shadow volume", apparently. I'm not familiar enough with the algorithm to know exactly what that means.

 

Doom 3 uses a different method, though, called Z-fail to distinguish it from Z-pass (which is, I believe, the method you describe). It's also known as Carmack's Reverse, because Carmack was the person to publicise it.

 

Carmack's Reverse is patented by Creative, the sound card manufacturer, despite a clear example of prior art - apparently prior art doesn't count in the U.S. if it's in the same calendar year as the patent application, even when (as in this case) the prior art was several months previous to the application. This is why Doom 3 includes EAX support; id software agreed to implement EAX support in exchange for being allowed to use the Carmack's Reverse algorithm.

 

For us mere mortals, though, it's unlawful to implement the algorithm without going to Creative on bended knee, and probably paying them a large sum of money for the privilege.

 

I hate software patents.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Nyarthlotep/Gildoran: rendering translucent objects is not a specific problem with Doom 3, it is a very difficult problem to solve in OpenGL at all. The Z buffer does not help, because it turns off the rendering for triangles which are behind other triangles, which is not what you want when the front triangle is translucent.

 

It is certainly NOT something that could be implemented trivially, and you may be sure that if it were, John Carmack would have done so effortlessly. There is a fairly detailed discussion of the problem on the OpenGL wiki: http://www.opengl.org/wiki/index.php/Alpha_Blending

 

For us mere mortals, though, it's unlawful to implement the algorithm without going to Creative on bended knee, and probably paying them a large sum of money for the privilege.

 

Fortunately in dear old Blighty, software patents are illegal, so Creative can kiss my shiny metal ass.

Link to comment
Share on other sites

While I understand that the depth-buffer doesn't help to depth-sort translucent triangles... it would have been nice if there was some way to partially sort them by depth before sending them to the renderer. (with the caveat that pathological cases might not appear correct) I've seen other games that appear to do that pretty well (at least for simple cases)... any ideas what's going on in them?

Link to comment
Share on other sites

There is an interesting NVIDIA paper on how it can be done here:

 

Depth peeling.

 

Given the complexity and the number of extra rendering passes required, it is not difficult to see why id didn't bother to implement it for Doom 3.

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

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...