Shaders - How to setup so that Apha works
Re: Shaders - How to setup so that Apha works
Okay, I have to upload it somewhere, can´t just paste it here...
-
chronologicaldot
- Competition winner
- Posts: 699
- Joined: Mon Sep 10, 2012 8:51 am
Re: Shaders - How to setup so that Apha works
Ah - so we're seeing mesh triangles, whereas the sphere looks like it is perfect (instead of being composed of triangles). Since the curvature of the sphere is softer than the torus, I imagine more faces on the torus would smooth it out like the sphere and make the problem go away / be reduced.
Re: Shaders - How to setup so that Apha works
Thanks for that, unfortunately the triangles are quite similar in size, and in debug mode equally visible.
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Shaders - How to setup so that Apha works
I assume you mean patches, which are not exactly aligned to the triangles?! I doubt that this has anything to do with the polygons, it's merely in the shader.
Re: Shaders - How to setup so that Apha works
So what you mean by "its in the shader" is that the pixel shader math is causing these effects that don´t show unless the alpha is set, and which almost disappear if ZWrite is disabled?
The shader is the classic Gooch produced by 3D Labs, why should it shade the curves of the circle without problems under alpha but the donut not?
Anyway its just setting the alpha to a fixed value... but its clear that the alpha under Irrlicht works on each mesh surface in a additive manner, that must be a known problem in CG modelling right?
We´d all appreciate a little more of an idea of these matters which must be all old ground for CG experts.
The shader is the classic Gooch produced by 3D Labs, why should it shade the curves of the circle without problems under alpha but the donut not?
Anyway its just setting the alpha to a fixed value... but its clear that the alpha under Irrlicht works on each mesh surface in a additive manner, that must be a known problem in CG modelling right?
We´d all appreciate a little more of an idea of these matters which must be all old ground for CG experts.
Re: Shaders - How to setup so that Apha works
don't think it's in the shader, irrlicht does not handle shaders properly when used with the EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_TRANSPARENT_ADD_COLORit's merely in the shader.

shader version behind native irrlicht in front
Re: Shaders - How to setup so that Apha works
Who deleted the picture of the issue, and why?
The issue is far from resolved!
Pitcure :
http://i.imgur.com/MNV8o.jpg
The issue is far from resolved!
Pitcure :

http://i.imgur.com/MNV8o.jpg
Last edited by robmar on Tue Jan 08, 2013 10:51 am, edited 1 time in total.
Re: Shaders - How to setup so that Apha works
The link is still there... but you shouldn't use commons.wikimedia.org/ as image-dumping website :-)
Use imgur for example - that will stay a little longer (although also not infinite).
Use imgur for example - that will stay a little longer (although also not infinite).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Shaders - How to setup so that Apha works
Thanks, updated!
So does anyone have any views on the alpha blending that is causing these variations in transparency, which seems to be caused when two mesh surfaces of the same object overlap?
So does anyone have any views on the alpha blending that is causing these variations in transparency, which seems to be caused when two mesh surfaces of the same object overlap?
Re: Shaders - How to setup so that Apha works
It's not a problem, it's how it's supposed to work. Think of the torus as a glass object, with 1mm thick walls, with air inside it.Anyway its just setting the alpha to a fixed value... but its clear that the alpha under Irrlicht works on each mesh surface in a additive manner, that must be a known problem in CG modelling right?
With that visualization, it should be clear why both surfaces need to be additive - this is what's expected from glass objects, it's how they act in the real world
The problem your arrow highlights, I don't think alpha blending can cause artifacts like that. You should never enable zwrite for transparent objects, that's why it's also a toggle in the driver making extra sure you really want to do that.
Re: Shaders - How to setup so that Apha works
Anyway, for your desired effect (one alpha for the whole object, to fade it out), you need to only draw its front face. With alpha blending, without Z writing.
One way to do it: first render the object to the Z-buffer only. You do this by disabling color and alpha writes in all its materials.
Then, when you render it again with the color & alpha writes enabled, only one face will be drawn, giving you the "single-alpha" effect.
One way to do it: first render the object to the Z-buffer only. You do this by disabling color and alpha writes in all its materials.
Then, when you render it again with the color & alpha writes enabled, only one face will be drawn, giving you the "single-alpha" effect.
Re: Shaders - How to setup so that Apha works
okay, that sounds more like it!
but how to do it?
I have many objects, background and foreground, and the shader-fader objects, so its not so simple, especially to keep FPS from collapsing.
What happens if I have "normal" objects overlapping the fading ones? How do I do the passes then?
So Irrlicht renders only front faces of a mesh when Z-write is off?
With Z-write enabled I get this:-

but how to do it?
I have many objects, background and foreground, and the shader-fader objects, so its not so simple, especially to keep FPS from collapsing.
What happens if I have "normal" objects overlapping the fading ones? How do I do the passes then?
So Irrlicht renders only front faces of a mesh when Z-write is off?
With Z-write enabled I get this:-

Re: Shaders - How to setup so that Apha works
And with Z-write disabled, I get this, back faces are being rendered, and I can see that the shader is now unable to determine surface Z-position correctly to produce the shading effect.

So my shader won´t render in color correctly, as it uses the Z-position to calculate shading... though the camera object looks better, its still rendering as a glass box.
The donut still looks very messed up... is it something in the mesh file, a .b3d (for some reason its b3d!)
How else can this be done? To get one transparency, as objects in the real-world are not all glass shells!

So my shader won´t render in color correctly, as it uses the Z-position to calculate shading... though the camera object looks better, its still rendering as a glass box.
The donut still looks very messed up... is it something in the mesh file, a .b3d (for some reason its b3d!)
How else can this be done? To get one transparency, as objects in the real-world are not all glass shells!
