mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
updated DomeProjection example with simplified shader use
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
void initCubeMap() {
|
||||
gridTex = loadImage("grid.png");
|
||||
sphereDetail(50);
|
||||
domeSphere = createShape(SPHERE, height/2.0f);
|
||||
domeSphere.setTexture(gridTex);
|
||||
domeSphere.rotateX(HALF_PI);
|
||||
domeSphere.setStroke(false);
|
||||
|
||||
@@ -42,7 +40,7 @@ void initCubeMap() {
|
||||
|
||||
// Load cubemap shader.
|
||||
cubemapShader = loadShader("cubemapfrag.glsl", "cubemapvert.glsl");
|
||||
cubemapShader.set("EnvMap", 1);
|
||||
cubemapShader.set("cubemap", 1);
|
||||
}
|
||||
|
||||
void drawCubeMap() {
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.nio.IntBuffer;
|
||||
|
||||
PShader cubemapShader;
|
||||
PShape domeSphere;
|
||||
PImage gridTex;
|
||||
|
||||
IntBuffer fbo;
|
||||
IntBuffer rbo;
|
||||
|
||||
@@ -1 +1 @@
|
||||
uniform sampler2D texture;
uniform samplerCube EnvMap;
varying vec3 reflectDir;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexCoord;
void main() {
// gl_FragColor = texture2D(texture, vertTexCoord.st) * vertColor;
vec3 envColor = vec3(textureCube(EnvMap, reflectDir));
gl_FragColor = vec4(envColor, 1.0);
}
/*
void main() {
// Look up environment map value in cube map
vec3 envColor = vec3(textureCube(EnvMap, ReflectDir));
gl_FragColor = vec4(envColor, 1.0);
}
*/
|
||||
uniform samplerCube cubemap;
varying vec3 reflectDir;
void main() {
vec3 color = vec3(textureCube(cubemap, reflectDir));
gl_FragColor = vec4(color, 1.0);
}
|
||||
@@ -1 +1 @@
|
||||
#define PROCESSING_TEXTURE_SHADER
uniform mat4 transform;
uniform mat4 modelview;
uniform mat4 texMatrix;
attribute vec4 vertex;
attribute vec4 color;
attribute vec2 texCoord;
attribute vec3 normal;
varying vec4 vertColor;
varying vec4 vertTexCoord;
uniform mat3 normalMatrix;
varying vec3 reflectDir;
void main() {
gl_Position = transform * vertex;
vec3 ecNormal = normalize(normalMatrix * normal); // Vertex in eye coordinates
vec3 ecVertex = vec3(modelview * vertex); // Normal vector in eye coordinates
vec3 eyeDir = ecVertex.xyz;
reflectDir = reflect(eyeDir, ecNormal);
vertColor = color;
vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
}
/*
varying vec3 ReflectDir;
void main() {
gl_Position = ftransform();
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
vec4 pos = gl_ModelViewMatrix * gl_Vertex;
vec3 eyeDir = pos.xyz;
ReflectDir = reflect(eyeDir, normal);
}
*/
|
||||
uniform mat4 transform;
uniform mat4 modelview;
uniform mat3 normalMatrix;
attribute vec4 vertex;
attribute vec3 normal;
varying vec3 reflectDir;
void main() {
gl_Position = transform * vertex;
vec3 ecNormal = normalize(normalMatrix * normal); // Vertex in eye coordinates
vec3 ecVertex = vec3(modelview * vertex); // Normal vector in eye coordinates
vec3 eyeDir = ecVertex.xyz;
reflectDir = reflect(eyeDir, ecNormal);
}
|
||||
Reference in New Issue
Block a user