Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Alpha Blended Textures problem  (Read 917 times)
0 Members and 1 Guest are viewing this topic.
Offline MercyfulGPF

Junior Newbie




I don't GIF a PNG what format...


« Posted 2004-06-08 19:38:29 »

Hello, all

I am trying to get two transparent (alpha channel) objects to overlay each other.

Two objects are created with transparent textures from 32BPP TGA files (24BPP + alpha channel).

When looking through transparent parts of the objects, any solid objects behind it will be visible, but other transparent (alpha-mapped) objects sometimes disappear, depending, apparently, on the angle.

I tried playing around with settings, giving functions different parameters in hopes of fixing the  problem, but nothing works. Any suggestions anybody?

Sergey

Repentance for sin is motivated by fear of punishment rather than by love for god
(c)
Offline aNt

Senior Member




AFK


« Reply #1 - Posted 2004-06-11 07:53:21 »

same problem here. with png its very odd.
Offline aNt

Senior Member




AFK


« Reply #2 - Posted 2004-06-11 09:37:13 »

for your every day objects

  // src=BLEND_SRC_ALPHA, dst=BLEND_ONE_MINUS_SRC_ALPHA

good for particles

   // src=BLEND_SRC_ALPHA, dst=BLEND_ONE

but i do get a strange outline on objects where things should still be a smooth aplha blend.
its as if u cant see past areas that the edges of the textures alpha.
This only happens at some angles- even with billboards. very odd

im loading textures like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
texture = (Texture2D) tloalder.constructTexture(
        bufferedImage,
        "RGBA",
        false,
        Texture.BASE_LEVEL,
        Texture.BASE_LEVEL_LINEAR,
        Texture.WRAP,
        false,
        TextureLoader.SCALE_DRAW_BEST);

looking into this more at the moment.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline MercyfulGPF

Junior Newbie




I don't GIF a PNG what format...


« Reply #3 - Posted 2004-06-11 12:15:42 »

Fixed it.

Well, it seems that every OpenGL based engine has the same problem, I don't know about Direct X, but the "problem" is related to the depth Z-buffer.
To solve the problem I created RenderingAttributes and set setDepthBufferWriteEnable(false) on it, then I enabled sorting on Transparency attributes, and finally I set the View transparency policy to:

view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_BOUNDING_SPHERE_AND_EYE_RAY_INTERSECTION)

This fixes the problem as long as the polygons don't intersect, and as long as they are not very close to each other. Xith will sort all the polygons in the scene BACK to FRONT, but this sometimes doesn't work as expected. The way around this problem is to create bounding sphere for every transparent geometry and position them along one axis in the required order.


Sergey

Repentance for sin is motivated by fear of punishment rather than by love for god
(c)
Offline aNt

Senior Member




AFK


« Reply #4 - Posted 2004-06-11 16:14:41 »

cool nice one- now only if i could sort of this bounds
problem on a BillBoard Sad sodding things just vanish..

setDepthBufferWriteEnable(false) works great!
thanks again....
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #5 - Posted 2004-06-13 09:15:00 »

Hi,

Quote
Well, it seems that every OpenGL based engine has the same problem, I don't know about Direct X, but the "problem" is related to the depth Z-buffer.


Yes, rendering the transaprent objects is tricky for both OpenGL and DirectX, especially if you want to corectly render intersecting semi-transparent polygons or self-intersecting surfaces.

Currently to render semi-transparent shapes in Xith3D, you have to

1. Ensure that they will render on Transparent rendering pass (for example, set BLENDED transparency mode for TransparencyAttributes)

2. Ensure that geometry sort is enabled

3. Disable depth buffer writes for transparent objects

4. Choose the transparency sorting policy (check source and JavaDoc for details on each sorting policy).

Quote
I enabled sorting on Transparency attributes, and finally I set the View transparency policy to:

view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_BOUNDING_SPHERE _AND_EYE_RAY_INTERSECTION)

This fixes the problem as long as the polygons don't intersect, and as long as they are not very close to each other. Xith will sort all the polygons in the scene BACK to FRONT, but this sometimes doesn't work as expected.


TRANSPARENCY_SORT_BOUNDING_SPHERE _AND_EYE_RAY_INTERSECTION is a best and reasonably fast implementation I found for geometry sorting. If you have a better idea for it, lets discuss it - would be really great if we can enhance the transparency rendering [one of the approaches is to use more complicated bounding shapes, but this degrades performance very much].

To completely solve this kind of problems, we should implement some of multipass/miltiphase techniques for transparency rendering, which implements per-fragment (per-pixel) depth sorting and works perfect in every case, including intersecting polygons and self-intersecting surfaces. The good example for such technique is depth peeling, but it works efficiently only on newer hardware and requires more rendering passes.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline aNt

Senior Member




AFK


« Reply #6 - Posted 2004-06-14 05:53:18 »

if its faster cant we added it with a flag so if users
dont have the hardware they can roll with the
none hardware version

a hardware version sounds great to me mind.
and ied love it!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (13 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (31 views)
2014-08-16 06:45:27

Tekkerue (31 views)
2014-08-16 06:22:17

Tekkerue (19 views)
2014-08-16 06:20:21

Tekkerue (29 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (42 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!