We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › transparency cam problem
Page Index Toggle Pages: 1
transparency cam problem (Read 407 times)
transparency cam problem
Sep 3rd, 2008, 6:10am
 
I just started to translate some sketches from 2d to 3d and was wondering why transparency only works when looking from one side. I thought maybe it has something to do with using a camera or lightsources. dont know how all this works yet... So is it more useful to move the cam instead of the objects like i did? Anything i have to take care of when using lightsources or cams etc. ?

here is a sketch where you can see the transparency problem. maybe its easy to explain using this example.

Thanks!

import processing.opengl.*;
void setup(){
 size(600,600,OPENGL);

}
float rx,ry;
void draw(){
 lights();
rx+=((width/2-mouseX)*0.01f-rx)*0.1f;
 ry+=((height/2-mouseY)*0.01f-ry)*0.1f;
 rotateY(rx);
 rotateX(ry);

 randomSeed(10);
 background(241);
  noStroke();
 smooth();
 translate(width/2,height/2);
 segment(260 ,0,1600,10);


}
void segment(int resolution,int start, int end, int radius){
 beginShape(QUAD_STRIP);
 for(int i=0;i<resolution;i++){
   float d=radians(map(i,0,resolution-1,start,end));
  fill(map(i,0,resolution,0,255));
float xx = random(1.2,6.5);

  float lerpX = map(xx,1.2,6.5,0,1);
//   fill(lerpColor(#ff0000,#4400ff,lerpX),100);
  fill(255-xx*170,20);

  strokeWeight(0.4);
  stroke(lerpColor(#ff0000,#4400ff,lerpX),100);
   vertex(sin(d)*(radius+i),cos(d)*(radius+i), i*4);
   vertex(sin(d)*((radius*xx)+i),cos(d)*((radius*xx)+i), i*4);
 }
 endShape();
}
Re: transparency cam problem
Reply #1 - Sep 3rd, 2008, 10:59am
 
it's a problem with the drawing order - the furthest away things need drawing first for transparency to work.

change the for loop to this to see what i mean

for(int i=resolution;i>=0;i--){

and the transparency will still only work when looking from the one direction but it'll be the other direction.

nice sketch btw.
Page Index Toggle Pages: 1