Fog Of War Transparency With Software

Started by AGP, October 12, 2017, 03:02:14 AM

Previous topic - Next topic

AGP

I''m writing a strategy game and can't seem to properly paint a transparent PNG on my fog (so that its edges are rounded). The logic for the texture placement is sound and has been tested. But all I get is solid black.


if (!TextureManager.getInstance().containsTexture("fog-top")) {
     TextureManager.getInstance().addTexture("fog-top", new Texture("Assets"+File.separator+"fog-top.png", true));
     TextureManager.getInstance().addTexture("fog-left", new Texture("Assets"+File.separator+"fog-left.png", true));
     TextureManager.getInstance().addTexture("fog-right", new Texture("Assets"+File.separator+"fog-right.png", true));
     TextureManager.getInstance().addTexture("fog-bottom", new Texture("Assets"+File.separator+"fog-bottom.png", true));
}

EgonOlsen

Then most likely your objects aren't rendered with transparency enabled or your textures' alpha channel is off.

AGP

The textures are right. I set transparency to 0.

EgonOlsen

Can you upload such a texture for me to see?


EgonOlsen

That texture has an alpha channel assigned to it that makes the white part transparent. I would guess that you actually want it the other way around?

AGP

No, those are the edges of the fog of war. The fog is black, naturally.

EgonOlsen

I can't see anything wrong with it nor with the rendering itself in my simple test case. Do you have a screen shot that shows the problem? Just to be sure that we are talking about the same thing here.


EgonOlsen

There quads don't seem to have any transparency applied to it. Alpha channel aside, they should be transparent anyway with a value of 0.

AGP


EgonOlsen

Doesn't look like it. Do you have a test case?

AGP

I wrote a simple test and transparency worked. So then I wrote the following method, and all I get are "End of printOddTransparencies()" prints. So now I'm stumped.


     public void printOddTransparencies(World theWorld) {
for (int y = 0; y < planes[0].length; y++)
     for (int x = 0; x < planes.length; x++)
if (theWorld.containsObject(planes[x][y]) && planes[x][y].getTransparency() != 0)
     System.out.println("Odd transparency at ("+x+", "+y+"): "+planes[x][y].getTransparency());
System.out.println("End of printOddTransparencies()");
     }

EgonOlsen

Maybe the texture itself hasn't been loaded properly? Albeit that doesn't explain why it's pitch black, but just to be sure...

AGP

I tested both the application logic (by replacing them with solid-color textures) and the same loading line (TextureManager.getInstance().addTexture("fog-left.png", new Texture("Assets"+File.separator+"fog-left.png", true))). Could it be relative to the number of polygons, or the sheer scale of the world? Maybe force-sorting the transparency list would fix it. Because number of polygons and size of the world are the only two different things between my test and the actual game.