Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 4 core/src/processing/core/PGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -2664,8 +2664,8 @@ public void arc(float a, float b, float c, float d,
}

if (stop - start > TWO_PI) {
start = 0;
stop = TWO_PI;
// don't change start, it is visible in PIE mode
stop = start + TWO_PI;
}
arcImpl(x, y, w, h, start, stop, mode);
}
Expand Down
31 changes: 31 additions & 0 deletions 31 core/src/processing/opengl/LightFrag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Part of the Processing project - http://processing.org

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
License version 2.1 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

varying vec4 vertColor;
varying vec4 backVertColor;

void main() {
gl_FragColor = gl_FrontFacing ? vertColor : backVertColor;
}
44 changes: 27 additions & 17 deletions 44 core/src/processing/opengl/LightVert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ attribute vec4 emissive;
attribute float shininess;

varying vec4 vertColor;
varying vec4 backVertColor;

const float zero_float = 0.0;
const float one_float = 1.0;
Expand Down Expand Up @@ -82,17 +83,17 @@ void main() {

// Normal vector in eye coordinates
vec3 ecNormal = normalize(normalMatrix * normal);

if (dot(-one_float * ecVertex, ecNormal) < zero_float) {
// If normal is away from camera, choose its opposite.
// If we add backface culling, this will be backfacing
ecNormal *= -one_float;
}
vec3 ecNormalInv = ecNormal * -one_float;

// Light calculations
vec3 totalAmbient = vec3(0, 0, 0);
vec3 totalDiffuse = vec3(0, 0, 0);
vec3 totalSpecular = vec3(0, 0, 0);

vec3 totalFrontDiffuse = vec3(0, 0, 0);
vec3 totalFrontSpecular = vec3(0, 0, 0);

vec3 totalBackDiffuse = vec3(0, 0, 0);
vec3 totalBackSpecular = vec3(0, 0, 0);

for (int i = 0; i < 8; i++) {
if (lightCount == i) break;

Expand All @@ -118,24 +119,33 @@ void main() {
: one_float;

if (any(greaterThan(lightAmbient[i], zero_vec3))) {
totalAmbient += lightAmbient[i] * falloff;
totalAmbient += lightAmbient[i] * falloff;
}

if (any(greaterThan(lightDiffuse[i], zero_vec3))) {
totalDiffuse += lightDiffuse[i] * falloff * spotf *
lambertFactor(lightDir, ecNormal);
totalFrontDiffuse += lightDiffuse[i] * falloff * spotf *
lambertFactor(lightDir, ecNormal);
totalBackDiffuse += lightDiffuse[i] * falloff * spotf *
lambertFactor(lightDir, ecNormalInv);
}

if (any(greaterThan(lightSpecular[i], zero_vec3))) {
totalSpecular += lightSpecular[i] * falloff * spotf *
blinnPhongFactor(lightDir, ecVertex, ecNormal, shininess);
totalFrontSpecular += lightSpecular[i] * falloff * spotf *
blinnPhongFactor(lightDir, ecVertex, ecNormal, shininess);
totalBackSpecular += lightSpecular[i] * falloff * spotf *
blinnPhongFactor(lightDir, ecVertex, ecNormalInv, shininess);
}
}

// Calculating final color as result of all lights (plus emissive term).
// Transparency is determined exclusively by the diffuse component.
vertColor = vec4(totalAmbient, 0) * ambient +
vec4(totalDiffuse, 1) * color +
vec4(totalSpecular, 0) * specular +
vec4(emissive.rgb, 0);
vertColor = vec4(totalAmbient, 0) * ambient +
vec4(totalFrontDiffuse, 1) * color +
vec4(totalFrontSpecular, 0) * specular +
vec4(emissive.rgb, 0);

backVertColor = vec4(totalAmbient, 0) * ambient +
vec4(totalBackDiffuse, 1) * color +
vec4(totalBackSpecular, 0) * specular +
vec4(emissive.rgb, 0);
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.