Shaders - How to setup so that Apha works
Shaders - How to setup so that Apha works
I´ve been trying to use the Alpha byte on the output of shaders in GLSL and HLSL, and noticed that its necessary to set the material type on loading the shader.
I´m not sure which material type to use, as I can´t find a material that allows the alpha byte on the PS shader to simply work.
Does anyone know how the alpha can be activated, so that color.a works?
I´m not sure which material type to use, as I can´t find a material that allows the alpha byte on the PS shader to simply work.
Does anyone know how the alpha can be activated, so that color.a works?
Re: Shaders - How to setup so that Apha works
The EMT_TRANSPARENT_ALPHA_CHANNEL type.
Re: Shaders - How to setup so that Apha works
If you are using 1.8 you also need to set the blen operation
Re: Shaders - How to setup so that Apha works
I tried with EMT_TRANSPARENT_ALPHA_CHANNEL, but the rendering is showing artifacts, parts correctly transparent and shaded, other parts showing the lines of triangles that make up the object.
I´m using 1.7.3. Can´t upgrade to 1.8 as the shadows are now too slow.
Any idea why triangles should show when alpha is below 1.0 (object debug is not set)?
I´m using 1.7.3. Can´t upgrade to 1.8 as the shadows are now too slow.
Any idea why triangles should show when alpha is below 1.0 (object debug is not set)?
-
- 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
Yes, only at alpha == 0.0 the triangle won't show at all, in all other situations the poly will blend with varying transparency.
Re: Shaders - How to setup so that Apha works
had similar problems
http://irrlicht.sourceforge.net/forum/v ... =1&t=45238
the issue seems to be alpha shader are not sorted correctly as per "native" irrlicht materials, the solution is to set the material ZWriteEnable to false. may work for you.
http://irrlicht.sourceforge.net/forum/v ... =1&t=45238
the issue seems to be alpha shader are not sorted correctly as per "native" irrlicht materials, the solution is to set the material ZWriteEnable to false. may work for you.
Re: Shaders - How to setup so that Apha works
@Klunk: Thanks for that!
@Hybrid: Come on, spill the beans! How about an understandable explanation as to why the Polys should be blending with "varying" transparency?
Is there a work-around such that the shader alpha will work correctly without nasty unexpected artifacts?
@Hybrid: Come on, spill the beans! How about an understandable explanation as to why the Polys should be blending with "varying" transparency?
Is there a work-around such that the shader alpha will work correctly without nasty unexpected artifacts?
Re: Shaders - How to setup so that Apha works
@Klunk: Disabling ZWrite on the objects fixed it, but of course now the rendering sequence isn´t and won´t be correct, and a cube that is behind the shader rendered objects is rendered "incorrectly" over them.
Anyone know how to fix this issue? ... without destroying z-order rendering!! ahhhhh!
Anyone know how to fix this issue? ... without destroying z-order rendering!! ahhhhh!
-
- 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
Well, transparency is not arbitrary, but changes based on the alpha value. As it should be. Sorting happens based on the base material setting. If base material is using blending, it will be sorted into the transparent render phase, i.e. back to front and after all solid elements. If this does not work, just adjust example 10 to show this problem and we can see if there's something to fix.
Re: Shaders - How to setup so that Apha works
To produce the issue I just set the shader color Alpha to 0.5 and load the torus.b3d mesh from nVidia´s samples, this donout shows the issue, but the standard cube and spherescenenode does not.
Looking closer I´m not sure these are the poly´s as such showing, but some variation in blending between them along the donout´s body.
There seems to be a cumulative (additive) blending of the meshes´ surfaces, resulting in transparency changes where there are overlapping polys... rather than the color.alpha simply affecting the whole of the object shape, it seems to be applied to each mesh surface and added to any overlapping mesh segment, and on more compelx shapes, where there is overlap, the transparency changes, giving a patchy effect.
Does that give enough clue to the problem?
Looking closer I´m not sure these are the poly´s as such showing, but some variation in blending between them along the donout´s body.
There seems to be a cumulative (additive) blending of the meshes´ surfaces, resulting in transparency changes where there are overlapping polys... rather than the color.alpha simply affecting the whole of the object shape, it seems to be applied to each mesh surface and added to any overlapping mesh segment, and on more compelx shapes, where there is overlap, the transparency changes, giving a patchy effect.
Does that give enough clue to the problem?
Last edited by robmar on Mon Jan 07, 2013 5:22 pm, edited 1 time in total.
Re: Shaders - How to setup so that Apha works
it's an Alpha Sort problem, shaders set to EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_TRANSPARENT_ADD_COLOR are not sorted like the built in materials.
Re: Shaders - How to setup so that Apha works
Z-order sort you mean? Is there a solution that does not involve rewriting large amounts of code?
Re: Shaders - How to setup so that Apha works
Show us a pic of that torus drawing wrong.
If it looks like what I think, you just entered the in-object draw order, which cannot be correct for transparent pixels ever (for an object of any complexity) - it's simply impossible using current technology.
If it looks like what I think, you just entered the in-object draw order, which cannot be correct for transparent pixels ever (for an object of any complexity) - it's simply impossible using current technology.
Re: Shaders - How to setup so that Apha works
If I disable ZWrite, most of these artefacts disapear, however, on the donut, when it´s rotated so that 4 of its surfaces overlap, the transparency level decreases, showing that there is still a cumulative transparency effect related to the number of surfaces in the line of view, if you follow what I´m mean... seems to indicate that alpha works per surface, not per model, which might seem to be a more useful real-world effect.
I mean here I am wanting to make a nice fade-out effect in Irrlicht of a complex mesh, and all the overlapping sub meshes have varied brightness, it looks horrible.... mmm back-culling....??? Nope, that didn´t do anything!
I mean here I am wanting to make a nice fade-out effect in Irrlicht of a complex mesh, and all the overlapping sub meshes have varied brightness, it looks horrible.... mmm back-culling....??? Nope, that didn´t do anything!
Re: Shaders - How to setup so that Apha works
Please, show a picture.