## Recommended Posts

Misantes    2092

edit*

I'm just an idiot who was rendering things in the wrong order. Everything is working great, minus my brain, apparently. Had I figured this out 2 minutes sooner, I could have saved the mods the trouble of deleting this post >.<

Mods, feel free to delete this if needed, I'll leave everything up as a warning to always check your render order, but otherwise the rest of the post is moot.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Hi,

So, this week I've started delving into glsl shaders. I'm using the book "GLSL Essentials" by packt publishing. I've successfully gotten my geometry shader up and running as a particle generator. The tutorial example works great. however, it generates the transparent portions of the image by:

if(color.a < 0.3)
{
}


This is great for the tutorial image. But, for anything semi-complex like a smoke or fire, or really anything other than basic geometric shapes, it seems like a blunt tool that results in an ugly result, cutting out too much/too little and leaving a jagged image.

Previously (on the advice of some kind soul on these forums), I would simply set the alpha thusly:

vec4 MaterialDiffuseColor = texture( textureSampler, UV );
color.a = MaterialDiffuseColor.a;

However, doing things the same way in the fragment shader no longer works when paired with a geometry shader, and I'm a little lost as to why.

My initial impressions are that the way I'm passing in the UV coordinates is problematic somehow. However, again, as the image appears in-game, minus the transparent bits, I feel like I could rule this out.

my blendfunc for these is set:

 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


Is there some fundamental piece of opengl/glsl I'm missing as to why the same method wouldn't work when the fragment shader is paired with a geometry shader? I've made a normal particle generator that renders the images perfectly, though it's entirely CPU side, and therefore gets a little resource heavy rather quickly if overused. So, I'd like to figure out how to do this GPU side. And, I believe I grasp the concept of the geometry shader, but I'm borking up some of the details.

posting the vertex, geometry and fragment shader here in this post seems overkill. You can find them:

Anyhow, thanks in advance for any help offered. I truly appreciate it!

Edited by Misantes