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 & HelpPrograms › texture perspective
Page Index Toggle Pages: 1
texture perspective (Read 1444 times)
texture perspective
Jun 1st, 2010, 6:25am

I'm actuallly learning how 2D textures works within P3D.
I've tried something really simple, create a texture and map over a square. The result is kinda weird, got some perspective distortion.

After read a bit of opengl tutorials, this doesn't seems to be that weird.
I think i've to use glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST) in opengl to get ride of it but what for P3D ?

Does Processing have any core functions to handle that ?

Here's the source code:
PGraphics b;
int l = 24;

void setup()
  size(200, 200, P3D);
  b = createGraphics(l*2, l*2, P3D);

void draw()
  //generate the texture
  b.rect(0, 0, l, l);
  b.rect(l, l, l, l);
  b.rect(l, 0, l, l);
  b.rect(0, l, l, l);

  //basic tranformations
  translate(width/2, height/2);

  vertex(l, -l, -l, 0, 0);
  vertex(-l, -l, -l, 0, 1);
  vertex(-l, -l, l, 1, 1);
  vertex(l, -l, l, 1, 0);
  image(b, 0 ,0);

Re: texture perspective
Reply #1 - Jun 1st, 2010, 2:57pm
did you see the texture examples? it mentions the problem there.

the way around it is to split the quad up into smaller pieces, that way the distortion is minimised. it's barely noticeable on the third example.

Re: texture perspective
Reply #2 - Jun 1st, 2010, 4:06pm
its the same with lightning. you can see the difference by changing the mousepos. you get much better results when you subdivide the shape


void setup(){
size(500, 500, P3D);

void draw(){

pointLight(151, 202, 226, 235, 440, 80);
pointLight(251, 22, 226, 205, 240, 80);
pointLight( 151, 222, 6, 305, 140, 80);

fill(215,220,210 );
int res = 1+mouseX/50;

for(int i = 0; i<res; i++){
for(int j = 0; j<=res; j++){


Page Index Toggle Pages: 1