Multiple transparency

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Multiple transparency

Post by Auradrummer »

Hello guys,

I made a shader with help of Nespa using reflection and transparency. I want now know if is possible to render those clipped polygons. Using OpenGL. Take a look.

Image
Uploaded with ImageShack.us

How can I solve this?
Professional Software Developer and Amateur Game Designer ;-)
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

material settings: material flags , normals, z-buffer.....

If You have applied the shader to the sphere, You must apply the shader to the alls objects inside of the sphere. The shader is rendered the last, so, if the objects inside are not rendered again, they will be cliped.
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Post by Auradrummer »

Hi Nespa,

I don't think is this. I did the following, make a sphere, copied it, flipped normals and paste inside. This is the same material. There is some way to order the engine to render the inner sphere after the outer?
Professional Software Developer and Amateur Game Designer ;-)
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

I have not alls the informations about your sphere to analyze what is happend.
I'm afraid i didn't understood what polygons in your sphere are clipped, they are separate objects or belong of the same object(sphere)?

If it is about the behind polygons around of the sphere, set flags frontface and backface too.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

The transparent polygons are drawn last, and without ZBuffering. You would have to draw the inner sphere BEFORE to the outer one, so the transparency is correctly drawn.

The transparency is an important issue in 3d engines because it doesn't get along well with the ZBuffering, and normaly, the way to deal with it is to delay the rendering of the transparent objects to the last part of the render, where they will be sorted back to front and drawn over the solid objects.

The problem is that this z-sorting is done only with the objects, and not with the faces that compose them, so, is posible that some faces are drawn incorrectly, and that is what happens with your screenshot.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Post by Auradrummer »

Hi guys,

I'll take a look at the stack overflow. But I'll explain better what is my object.

I'm not using backface culling because the normals was a bit messed (but I was using a bad shader that time).

So I made two spheres one over the other. Exactly the same sphere. But, one of them I flipped the normals, and it is visible from inside, you got?

Thanks for the replies!
Professional Software Developer and Amateur Game Designer ;-)
Kalango
Posts: 157
Joined: Thu Apr 26, 2007 12:46 am

Post by Kalango »

Doesnt irrlicht have polygon offset atribute to avoid z fighting? If it doesnt it nees ASAP...
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Post by Auradrummer »

Tried to use backface culling again.

With your shader, Nespa, worked well. But still with that problem.
Professional Software Developer and Amateur Game Designer ;-)
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

The 1st shader is "one side lighting".
Try a "two sides lighting" shader;

here is the doc:

http://www.gamedev.net/page/resources/_ ... rary-r2428
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Maybe your best option here would be to split the sphere into two separate objects and make sure the fliped sphere is drawn before the other.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Kalango wrote:Doesnt irrlicht have polygon offset atribute to avoid z fighting? If it doesnt it nees ASAP...
Nope.. it is a problem that took me months to fight, ultimately having to modify Irrlicht to make things work as I needed.

From your post, I did a search and found out that openGL does have a polygon offset attribute, and DirectX/Direct3D might too (not sure)... never knew this.
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

build your sphere like that :

-a grid as a separate object;
-many windows as the children of the grid;

-apply the shader to the alls objects in a separate mode;
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

3 objects here:

- sphere1(middle sphere) -> material type : transparent & reflections 2 layers;
material flag : backface ON;frontface ON;

- sphere2(inner sphere) -> material type : solid;
material flag : backface ON;frontface ON;

- sphere3(outer sphere) -> material type : solid;
material flag : backface ON;frontface ON;

Don't apply shader to sphere1;
You can apply shader to sphere2 and sphere3;




Image
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Re: Multiple transparency

Post by Auradrummer »

Hi Nespa,

After a long time, I'm on active again (was dealing with logic). Yes, your suggestion worked very well. I made a bit different:
I used two domes, one for inside another for outside e none for the solid part.

Thanks man!
Professional Software Developer and Amateur Game Designer ;-)
Post Reply