shader / slab transparency behavior

    Jun 27 2013 | 3:13 pm
    FORUM -
    Been banging my head against this one for a couple of days so I figured it's time to buck up and ask -
    I've got a simple shader that creates an alpha-blended circle (soft circle goes from param-defined color in the center to transparent at the edges).
    I'm using that shader on a slab and getting the color param just fine but no alpha. I was able to confirm the alpha is calculated properly by testing the shader with calculated alpha on all channels (commented line in the shader below).
    I know it's something simple in my implementation that's preventing alpha from being used but I'm at a loss where to look next.
    Any help would be appreciated.
    varying vec4 vertexPosition; uniform vec4 circleColor; uniform float intensity; uniform float circleSizeModifier;
    void main() { vec4 center = vec4(0.0,0.0,0.0,0.0);
    vec4 position = vec4(vertexPosition.x, vertexPosition.y * .75, vertexPosition.z, vertexPosition.a); float alpha = distance(position.xy, center.xy); alpha = alpha * circleSizeModifier; alpha = pow(alpha , intensity);
    alpha = pow(alpha ,-1.0);
    gl_FragColor = vec4(circleColor.x, circleColor.y, circleColor.z, alpha * circleColor.a);
    // gl_FragColor = vec4(alpha, alpha, alpha, alpha * circleColor.a);
    VERT SHADERvarying vec4 vertexPosition;
    void main() {
    gl_Position = ftransform(); vertexPosition = gl_Position;

    • Jun 27 2013 | 3:45 pm
      to enable transparency on any opengl object, you must set @depth_enable 0 and @blend_enable 1 (there's some exceptions, but not relevant in your case). you then control the layering order with the @layer attribute.
      generally, opaque objects are drawn first and transparent objects last.
    • Jun 27 2013 | 7:15 pm
      BOOM Rob strikes again!
      Thanks Rob!!