Last active
February 12, 2025 12:59
-
-
Save companje/78346b42683972c3e99e352a0b8d902e to your computer and use it in GitHub Desktop.
CubeMap camera FOV 90 (stretched)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PImage earth; | |
PShape globe; | |
PGraphics fbo[] = new PGraphics[6]; | |
int cubemapSize = 512; | |
PVector eye = new PVector(0, 0, 0); | |
PVector up[] = { | |
new PVector(0, -1, 0), // +X | |
new PVector(0, -1, 0), // -X | |
new PVector(0, 0, 1), // +Y | |
new PVector(0, 0, -1), // -Y | |
new PVector(0, -1, 0), // +Z | |
new PVector(0, -1, 0) // -Z | |
}; | |
PVector center[] = { | |
new PVector(1, 0, 0), // +X | |
new PVector(-1, 0, 0), // -X | |
new PVector(0, 1, 0), // +Y | |
new PVector(0, -1, 0), // -Y | |
new PVector(0, 0, 1), // +Z | |
new PVector(0, 0, -1) // -Z | |
}; | |
void setup() { | |
size(950, 150, P3D); | |
earth = loadImage("BeachBallColor.jpg"); | |
globe = createShape(SPHERE, 180); | |
globe.setTexture(earth); | |
for (int i = 0; i < 6; i++) { | |
fbo[i] = createGraphics(cubemapSize, cubemapSize, P3D); | |
} | |
} | |
void draw() { | |
background(0); | |
for (int i = 0; i < 6; i++) { | |
render(i); | |
} | |
for (int i = 0; i < 6; i++) { | |
image(fbo[i], i*160, 0, 150, 150); | |
} | |
} | |
void render(int i) { | |
fbo[i].beginDraw(); | |
fbo[i].camera(eye.x, eye.y, eye.z, center[i].x, center[i].y, center[i].z, up[i].x, up[i].y, up[i].z); | |
fbo[i].perspective(PI/2, 1.0, 1, 1000); | |
fbo[i].background(0); | |
fbo[i].shape(globe); | |
fbo[i].hint(DISABLE_DEPTH_TEST); | |
fbo[i].translate(0, 0, 185); | |
fbo[i].textSize(100); | |
fbo[i].fill(255, 255, 0); | |
fbo[i].text("HALLO", 0, 0); | |
fbo[i].endDraw(); | |
} |
Author
companje
commented
Feb 12, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment