Hello,
I wanted to add shadows to my sketch, however I only found ways in P2D to use the blur shader examples, and i don’t know on how a shader could be translated to processing.
This is my code (i wanted to add shadows):
float angleX = 0;
float angleY = 0;
float cameraDistance = 300;
PShader shadowShader;
void setup() {
size(800, 600, P3D);
shadowShader = loadShader("shadow_shader.glsl");
}
void draw() {
background(255);
shader(shadowShader);
perspective(radians(45), float(width) / float(height), 1, 1000);
float camX = cameraDistance * cos(radians(angleY)) * sin(radians(angleX));
float camY = cameraDistance * sin(radians(angleY));
float camZ = cameraDistance * cos(radians(angleY)) * cos(radians(angleX));
camera(camX, camY, camZ, 0, 0, 0, 0, 1, 0);
fill(200);
beginShape();
vertex(-100, 0, -100);
vertex(100, 0, -100);
vertex(100, 0, 100);
vertex(-100, 0, 100);
endShape(CLOSE);
translate(0, -50, 0);
box(30);
resetShader();
}
void mouseDragged() {
angleX += radians((pmouseX - mouseX) * 5);
angleY += radians((mouseY - pmouseY) * 5);
}
Thanks for any help