Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Glsl geometry shader difficulties


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Misantes   GDNet+   -  Reputation: 1192

Like
0Likes
Like

Posted 12 August 2014 - 09:23 PM

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)
    {
        discard;
    }

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:

https://github.com/Hobogames/Problems/blob/master/GFragmentShader.fragmentshader

https://github.com/Hobogames/Problems/blob/master/GVertexShader.vertexshader

https://github.com/Hobogames/Problems/blob/master/GeometryShader.geometryshader

 

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


Edited by Misantes, 12 August 2014 - 09:30 PM.

Beginner here <- please take any opinions with grain of salt :P


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS