Weird Behaviour Line Rendering Alpha Value

edited May 2014 in Using Processing

Hey All

I am rendering a couple of lines with alpha value and therfore I stuck with a weird issue:

If I render ca 500 lines in a for loop, and above some other 500 also in a for loop, the alpha behaviour is as exspected.
If I make a class for the lines and render the class 500 times, the alpha value is also some kind of white. Its like rendereing white lines and above the alpha color. Its like the lines are clipping the lines beneath. Anybody knows how to get this fixed? Thanks

import peasy.*;
PeasyCam cam;
ArrayList lines;
LineRender render;

void setup() {
  size(1000, 800, OPENGL);  
  smooth(4);

  cam = new PeasyCam(this, width/2, height/2, 0, 5000);
  cam.setMinimumDistance(0);
  cam.setMaximumDistance(1000);
  lines=new ArrayList();

  for (int i=0;i<500 ;i++) {
    LineRender lr =new LineRender();
    lines.add(lr);
  }

}


void draw() {
  blendMode(BLEND);
  hint(ENABLE_DEPTH_TEST);

  background(255);
  strokeWeight(2);

  //-> they should be transparent but aparently they are clipping the lines beneath
  stroke(255, 20, 0, 0);
  for (int i = 0; i < lines.size(); i++) {
    LineRender l = (LineRender) lines.get(i);
    l.render();
  }

  stroke(20, 20, 255, 20);
  for (int i=0;i<500 ;i++) {
    line(0, 0, 100, 1000+10*i, 1000, 10*i);
  }

  strokeWeight(1);
  stroke(0, 255, 0, 20);
  for (int i=0;i<500 ;i++) {
    line(1000, 0, 10, 1, 1000, 10*i);
  }
}



// -------- Line render class ---------------
class LineRender {

  float x1,y1,z1,x2,y2,z2;

  LineRender(){
  x1=0;
  y1=0;
  z1=0;
  x2=1000+random(300);
  y2=1000+random(300);
  z2=1000+random(300);

  }

  void render() {
    line(x1,y1,z1,x2,y2,z2);
  }
}
Tagged:

Answers

  • Transparency in OpenGL is a bit problematic, you should make a search, the topic comes up regularly.

Sign In or Register to comment.