renamed modelview and projection matrices in the shaders

This commit is contained in:
codeanticode
2013-02-05 16:24:42 -05:00
parent 39ea20a326
commit 17f86c313e
12 changed files with 45 additions and 45 deletions
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,8 +18,8 @@
Boston, MA 02111-1307 USA
*/
uniform mat4 modelviewMatrix;
uniform mat4 projectionMatrix;
uniform mat4 modelview;
uniform mat4 projection;
uniform vec4 viewport;
uniform int perspective;
@@ -44,20 +44,20 @@ vec4 windowToClipVector(vec2 window, vec4 viewport, float clip_w) {
void main() {
vec4 pos_p = inVertex;
vec4 v_p = modelviewMatrix * pos_p;
vec4 v_p = modelview * pos_p;
// Moving vertices slightly toward the camera
// to avoid depth-fighting with the fill triangles.
// Discussed here:
// http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848
v_p.xyz = v_p.xyz * scale;
vec4 clip_p = projectionMatrix * v_p;
vec4 clip_p = projection * v_p;
float thickness = inLine.w;
if (thickness != 0.0) {
vec4 pos_q = vec4(inLine.xyz, 1);
vec4 v_q = modelviewMatrix * pos_q;
vec4 v_q = modelview * pos_q;
v_q.xyz = v_q.xyz * scale;
vec4 clip_q = projectionMatrix * v_q;
vec4 clip_q = projection * v_q;
vec3 window_p = clipToWindow(clip_p, viewport);
vec3 window_q = clipToWindow(clip_q, viewport);
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2012 Ben Fry and Casey Reas
Copyright (c) 2012-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
+18 -18
View File
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-12 Ben Fry and Casey Reas
Copyright (c) 2004-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -6470,10 +6470,10 @@ public class PGraphicsOpenGL extends PGraphics {
protected class BaseShader extends PShader {
protected int transformMatrixLoc;
protected int modelviewMatrixLoc;
protected int projectionMatrixLoc;
protected int bufferSamplerLoc;
protected int transformLoc;
protected int modelviewLoc;
protected int projectionLoc;
protected int bufferLoc;
protected int viewportLoc;
public BaseShader(PApplet parent) {
@@ -6490,16 +6490,16 @@ public class PGraphicsOpenGL extends PGraphics {
@Override
public void loadUniforms() {
transformMatrixLoc = getUniformLoc("transform");
modelviewMatrixLoc = getUniformLoc("modelviewMatrix");
projectionMatrixLoc = getUniformLoc("projectionMatrix");
transformLoc = getUniformLoc("transform");
modelviewLoc = getUniformLoc("modelview");
projectionLoc = getUniformLoc("projection");
viewportLoc = getUniformLoc("viewport");
bufferSamplerLoc = getUniformLoc("buffer");
bufferLoc = getUniformLoc("buffer");
}
@Override
public void unbind() {
if (-1 < bufferSamplerLoc) {
if (-1 < bufferLoc) {
pgl.needFBOLayer();
pgl.activeTexture(PGL.TEXTURE0 + lastTexUnit);
pgCurrent.unbindBackTexture();
@@ -6512,19 +6512,19 @@ public class PGraphicsOpenGL extends PGraphics {
}
protected void setCommonUniforms() {
if (-1 < transformMatrixLoc) {
if (-1 < transformLoc) {
pgCurrent.updateGLProjmodelview();
setUniformMatrix(transformMatrixLoc, pgCurrent.glProjmodelview);
setUniformMatrix(transformLoc, pgCurrent.glProjmodelview);
}
if (-1 < modelviewMatrixLoc) {
if (-1 < modelviewLoc) {
pgCurrent.updateGLModelview();
setUniformMatrix(modelviewMatrixLoc, pgCurrent.glModelview);
setUniformMatrix(modelviewLoc, pgCurrent.glModelview);
}
if (-1 < projectionMatrixLoc) {
if (-1 < projectionLoc) {
pgCurrent.updateGLProjection();
setUniformMatrix(projectionMatrixLoc, pgCurrent.glProjection);
setUniformMatrix(projectionLoc, pgCurrent.glProjection);
}
if (-1 < viewportLoc) {
@@ -6535,8 +6535,8 @@ public class PGraphicsOpenGL extends PGraphics {
setUniformValue(viewportLoc, x, y, w, h);
}
if (-1 < bufferSamplerLoc) {
setUniformValue(bufferSamplerLoc, lastTexUnit);
if (-1 < bufferLoc) {
setUniformValue(bufferLoc, lastTexUnit);
pgl.activeTexture(PGL.TEXTURE0 + lastTexUnit);
pgCurrent.bindBackTexture();
}
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,8 +18,8 @@
Boston, MA 02111-1307 USA
*/
uniform mat4 projectionMatrix;
uniform mat4 modelviewMatrix;
uniform mat4 projection;
uniform mat4 modelview;
uniform vec4 viewport;
uniform int perspective;
@@ -36,13 +36,13 @@ vec4 windowToClipVector(vec2 window, vec4 viewport, float clip_w) {
}
void main() {
vec4 pos = modelviewMatrix * inVertex;
vec4 clip = projectionMatrix * pos;
vec4 pos = modelview * inVertex;
vec4 clip = projection * pos;
if (0 < perspective) {
// Perspective correction (points will look thiner as they move away
// from the view position).
gl_Position = clip + projectionMatrix * vec4(inPoint.xy, 0, 0);
gl_Position = clip + projection * vec4(inPoint.xy, 0, 0);
} else {
// No perspective correction.
vec4 offset = windowToClipVector(inPoint.xy, viewport, clip.w);
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,7 +18,7 @@
Boston, MA 02111-1307 USA
*/
uniform mat4 modelviewMatrix;
uniform mat4 modelview;
uniform mat4 transform;
uniform mat3 normalMatrix;
@@ -76,7 +76,7 @@ void main() {
gl_Position = transform * inVertex;
// Vertex in eye coordinates
vec3 ecVertex = vec3(modelviewMatrix * inVertex);
vec3 ecVertex = vec3(modelview * inVertex);
// Normal vector in eye coordinates
vec3 ecNormal = normalize(normalMatrix * inNormal);
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -1,7 +1,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
Copyright (c) 2011-13 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,7 +18,7 @@
Boston, MA 02111-1307 USA
*/
uniform mat4 modelviewMatrix;
uniform mat4 modelview;
uniform mat4 transform;
uniform mat3 normalMatrix;
uniform mat4 texcoordMatrix;
@@ -76,10 +76,10 @@ float blinnPhongFactor(vec3 lightDir, vec3 vertPos, vec3 vecNormal, float shine)
void main() {
// Vertex in clip coordinates
gl_Position = projmodelviewMatrix * inVertex;
gl_Position = transform * inVertex;
// Vertex in eye coordinates
vec3 ecVertex = vec3(modelviewMatrix * inVertex);
vec3 ecVertex = vec3(modelview * inVertex);
// Normal vector in eye coordinates
vec3 ecNormal = normalize(normalMatrix * inNormal);