This file contains 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
void clip( float clipValue, float alphaThreshold, int type ) | |
{ | |
// switch operation because were only value checking type | |
switch( type ) | |
{ | |
case 0: // 0 means less than | |
if( clipValue < alphaThreshold ) discard; | |
break; | |
case 1: // 1 means greater than |
This file contains 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
vec2 radialShear( vec2 uv, vec2 center, vec2 strength, vec2 offset ) | |
{ | |
vec2 delta = uv - center; | |
float delta2 = dot( delta.xy, delta.xy ); | |
vec2 deltaOffset = delta2 * strength; | |
return uv + vec2( delta.y, -delta.x) * deltaOffset + offset; | |
} |
This file contains 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
vec2 twirl( vec2 uv, vec2 center, float strength, vec2 offset ) | |
{ | |
vec2 delta = uv - center; | |
float angle = strength * length(delta); | |
float x = cos(angle) * delta.x - sin(angle) * delta.y; | |
float y = sin(angle) * delta.x + cos(angle) * delta.y; | |
return vec2(x + center.x + offset.x, y + center.y + offset.y); | |
} |
This file contains 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
float random(vec2 n) { | |
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); | |
} | |
float interpolate( float a, float b, float t ) | |
{ | |
return ( 1.0 - t ) * a + ( t * b ); | |
} | |
float valueNoise( vec2 uv ) |
This file contains 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
float negate( float value ) | |
{ | |
return -1.0 * value; | |
} |
This file contains 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
out vec3 vWorldSpaceNormal; | |
void main() | |
{ | |
vec4 worldSpaceNormal = modelMatrix * vec4( normal, 0.0 ); | |
vWorldSpaceNormal = normalize( worldSpaceNormal.xyz ); | |
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); | |
This file contains 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
/* calculate view position of the camera */ | |
out vec3 vViewDirection; | |
void main() | |
{ | |
vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); | |
This file contains 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
/* calculate surface normals shader material three.js */ | |
out vec3 vSurfaceNormal; | |
void main() | |
{ | |
vSurfaceNormal = normalize( normalMatrix * normal ); | |
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1. ); |
This file contains 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
/* Fragment shader | |
// | |
// Screen space | |
// | |
*/ | |
uniform vec2 uResolution; // screen width and height | |
void main() | |
{ |
This file contains 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
out vec2 vWorldUv; | |
void main() | |
{ | |
vec4 objectSpace = modelMatrix * vec4( position, 1.0 ); | |
vWorldUv = vec2( objectSpace.x, objectSpace.z ); | |
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); |
NewerOlder