[FIXED] Holes in terrain texture. Related to voidwater.

[FIXED] Holes in terrain texture. Related to voidwater.

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

Post Reply
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

[FIXED] Holes in terrain texture. Related to voidwater.

Post by Beherith »

Image

Wierd ass bug. I get holes in my texture if shadows are off. Texture made with mapconv.
User avatar
bartvbl
Posts: 346
Joined: 21 Mar 2009, 15:55

Re: Holes in terrain texture.

Post by bartvbl »

dont know: but could this be rounding errors?
Maybe those holes are caused by rounding some vital part of the texturemap?
Or perhaps noise on the textureMap?
very strange, idd...
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: Holes in terrain texture.

Post by TheFatController »

I noticed these and thought you'd used a widget to add reflective ice crystals onto the meteor :P
User avatar
bartvbl
Posts: 346
Joined: 21 Mar 2009, 15:55

Re: Holes in terrain texture.

Post by bartvbl »

it looks like the error is in the black layer, which is perhaps (it is?) placed on top of the original texture layer of the map.
Maybe because of noise small parts come through?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Holes in terrain texture.

Post by Beherith »

So, Smoth told me that holes are caused by texture being fully black in that area.

So I added voidwater to one of my test maps, which have a black and white checkerboard pattern, and the black bits were not transparent with shadows on or off.
So I recompiled apophis with no texture point being at 0,0,0 and it still has the same holes.

The only seemingly relevant engine code I could find was:
if (mapInfo->map.voidWater && !waterDrawn) {
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.9f);
}
Could someone explain to me what this is supposed to do?
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: Holes in terrain texture.

Post by very_bad_soldier »

Beherith wrote: glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.9f);
Could someone explain to me what this is supposed to do?
Probably someone can explain better but AFAIK the first line just enables the alpha test. So for every processed pixel the alpha test will be executed.
The second line defines to conditions for the alpha test. So in this case, only if the alpha value of the current pixel is greater than 0.9 the pixel will be rendered, otherwise discarded.

EDIT:
Well, let me guess, you did know that already. What you need is an interpretation, right? 8)
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Holes in terrain texture. [update]

Post by Beherith »

Yeah, got that far myself too, just dunno how alpha vals are calced for the texture in this case.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Holes in terrain texture. [update]

Post by jK »

without knowing why it works with shadows, i assume your alpha in the map texture is just wrong (make it binary: 1 or 0, nothing between).
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Holes in terrain texture. [update]

Post by Beherith »

My map texture is a 24 bit BMP. Thats more or less all that mapconv is willing to eat. I never used any image file with an alpha channel in it.

Didnt even know you could use alpha in a map texture...

Edit: Ok i tested some more, mapconv eats 32bit bmp with alpha channel. I set the alpha to a variety of levels, but mainly min-max. Still nothing ingame; no transparency.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Holes in terrain texture. [update]

Post by Argh »

Doesn't the engine use alpha testing on quads being submitted to the shader? That's probably where it's going wrong. Either that, or the shader's goofy, but I doubt it.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Holes in terrain texture. [update]

Post by Beherith »

Tested that too, map comes out black as 0.0.0 on screenie, yet still no holes.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Holes in terrain texture. [update]

Post by Argh »

OK, so no alpha test. Must be a bug in the shader, then. Lemme go read it for a minute.

<reads>

This is interesting- ground only seems to use a vertex program, no fragment program. And it expects a shadowmap. Perhaps the shadowmap being all zero'd is causing t he problem.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Holes in terrain texture. [update]

Post by Beherith »

This still doesnt explain the non-deterministic nature of the bug. I know ive seen it before, not just on apophis, but the scale of the bug this time is way bigger than previously.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Holes in terrain texture. [update]

Post by Argh »

Theory: perhaps it's related to the skybox or detail texture?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Holes in terrain texture. [update]

Post by Beherith »

I used the skybox and detail tex and lighting from Apophis. The test map has a gradient color and hmap, so it should theoretically reproduce this effect.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Holes in terrain texture. [update]

Post by Argh »

Hmm. The holes really look like a problem with the fragments getting discarded, though I simply don't see how that can be happening shader-side, unless an input variable is returning zero on the alpha.

I'd have to read the engine source to have a clue- there has to be something resulting in fragment culling going on, or the holes wouldn't be happening.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Holes in terrain texture

Post by Beherith »

As a test, I turned off voidwater in Apophis, and the holes were gone.
But I cant make more asteroid maps until this issue is resolved :(
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Holes in terrain texture. [update]

Post by jK »

Beherith wrote:My map texture is a 24 bit BMP. Thats more or less all that mapconv is willing to eat. I never used any image file with an alpha channel in it.

Didnt even know you could use alpha in a map texture...

Edit: Ok i tested some more, mapconv eats 32bit bmp with alpha channel. I set the alpha to a variety of levels, but mainly min-max. Still nothing ingame; no transparency.
Hmmm I never worked with any of the map convertes.

The source code says that if voidwater is used the alpha channel of final fragment/pixel (which includes the map texture) is used to create holes in the terrain, this automatically affects any terrain underwater ('cuz of the lightmap texture, which is multiplied with all other texture stages, saves the terrain depth in its alpha channel).
I always disliked this because ALPHA_TEST is evil, but I thought perhaps someone wants to make holes in the terrain (above water!), so I never touched that stuff. But now it seems mapconv doesn't even support this o_O

Note: OpenGL-wise there is a much faster way to hide underwater terrain than using ALPHA_TEST.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Holes in terrain texture. Related to voidwater.

Post by Argh »

Aha, so that's what's up. Okie doke. It would be really cool, to have holes.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: [FIXED] Holes in terrain texture. Related to voidwater.

Post by Beherith »

Found the bug. I was using the param -dxt1 passed to nvdxt; which defaults to dxt1c: meaning color only. Then nvdxt added a bogus noise alpha map.
Using the param -dxt1a meant that it uses the alpha supplied in image.

So in all, terrain CAN be made transparent, but only if voidwater is enabled. But this behaiviour is still bugged, because turning shadows on disables the alpha test for terrain textures.
Post Reply

Return to “Help & Bugs”