mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Remove trailing spaces
This commit is contained in:
@ -17,9 +17,9 @@ void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture(texture0, fragTexCoord);
|
||||
|
||||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
|
||||
finalColor = texelColor*colDiffuse;
|
||||
}
|
||||
|
||||
|
||||
@ -13,14 +13,14 @@ uniform mat4 mvp;
|
||||
out vec2 fragTexCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
// Send vertex attributes to fragment shader
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
||||
@ -24,7 +24,7 @@ void main()
|
||||
{
|
||||
// Compute MVP for current instance
|
||||
mat4 mvpi = mvp*instanceTransform;
|
||||
|
||||
|
||||
// Send vertex attributes to fragment shader
|
||||
fragPosition = vec3(mvpi*vec4(vertexPosition, 1.0));
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
@ -13,9 +13,9 @@ out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const vec2 size = vec2(800, 450); // render size
|
||||
const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance
|
||||
const float quality = 2.5; // lower = smaller glow, better quality
|
||||
const vec2 size = vec2(800, 450); // Framebuffer size
|
||||
const float samples = 5.0; // Pixels per axis; higher = bigger glow, worse performance
|
||||
const float quality = 2.5; // Defines size factor: Lower = smaller glow, better quality
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@ -24,8 +24,8 @@ void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec3 texelColor = texture(texture0, fragTexCoord).rgb*weight[0];
|
||||
|
||||
for (int i = 1; i < 3; i++)
|
||||
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
texelColor += texture(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
|
||||
texelColor += texture(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
|
||||
|
||||
@ -22,6 +22,6 @@ void main()
|
||||
|
||||
float x = fract(fragTexCoord.s);
|
||||
float final = smoothstep(divider - 0.1, divider + 0.1, x);
|
||||
|
||||
|
||||
finalColor = mix(texelColor0, texelColor1, final);
|
||||
}
|
||||
@ -24,22 +24,22 @@ void main()
|
||||
vec3 tc = vec3(1.0, 1.0, 1.0);
|
||||
float lum = length(texture(texture0, fragTexCoord).rgb);
|
||||
|
||||
if (lum < lumThreshold01)
|
||||
if (lum < lumThreshold01)
|
||||
{
|
||||
if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
if (lum < lumThreshold02)
|
||||
if (lum < lumThreshold02)
|
||||
{
|
||||
if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
if (lum < lumThreshold03)
|
||||
if (lum < lumThreshold03)
|
||||
{
|
||||
if (mod(gl_FragCoord.x + gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
if (lum < lumThreshold04)
|
||||
if (lum < lumThreshold04)
|
||||
{
|
||||
if (mod(gl_FragCoord.x - gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ vec4 PostFX(sampler2D tex, vec2 uv)
|
||||
if (invert == 1) c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
|
||||
else c = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@ -18,21 +18,21 @@ vec2 VectorRotateTime(vec2 v, float speed)
|
||||
{
|
||||
float time = uTime*speed;
|
||||
float localTime = fract(time); // The time domain this works on is 1 sec.
|
||||
|
||||
|
||||
if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
|
||||
else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4*sin(2*PI*localTime - PI/2);
|
||||
else if ((localTime >= 0.50) && (localTime < 0.75)) angle = PI*0.25;
|
||||
else if ((localTime >= 0.75) && (localTime < 1.00)) angle = PI/4*sin(2*PI*localTime);
|
||||
|
||||
|
||||
// Rotate vector by angle
|
||||
v -= 0.5;
|
||||
v = mat2(cos(angle), -sin(angle), sin(angle), cos(angle))*v;
|
||||
v += 0.5;
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
float Rectangle(in vec2 st, in float size, in float fill)
|
||||
float Rectangle(in vec2 st, in float size, in float fill)
|
||||
{
|
||||
float roundSize = 0.5 - size/2.0;
|
||||
float left = step(roundSize, st.x);
|
||||
@ -44,7 +44,7 @@ float Rectangle(in vec2 st, in float size, in float fill)
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
{
|
||||
vec2 fragPos = fragTexCoord;
|
||||
fragPos.xy += uTime/9.0;
|
||||
|
||||
@ -53,7 +53,7 @@ void main()
|
||||
vec2 fpos = fract(fragPos); // Get the fractional coords
|
||||
|
||||
fpos = VectorRotateTime(fpos, 0.2);
|
||||
|
||||
|
||||
float alpha = Rectangle(fpos, 0.216, 1.0);
|
||||
vec3 color = vec3(0.3, 0.3, 0.3);
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ void main()
|
||||
|
||||
// Linearize depth value
|
||||
float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear));
|
||||
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(depth, depth, depth, 1.0f);
|
||||
}
|
||||
@ -24,13 +24,13 @@ void main()
|
||||
// The following two variables need to be set per eye
|
||||
vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
|
||||
vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
|
||||
|
||||
|
||||
// Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter)
|
||||
vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1]
|
||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||
vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq);
|
||||
//vec2 tc = LensCenter + Scale*theta1;
|
||||
|
||||
|
||||
// Detect whether blue texture coordinates are out of range since these will scaled out the furthest
|
||||
vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq);
|
||||
vec2 tcBlue = LensCenter + Scale*thetaBlue;
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
Each integer is tested to see if it is a prime number. Primes are colored white.
|
||||
Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer.
|
||||
|
||||
You can change the scale variable to make a larger or smaller grid.
|
||||
You can change the scale variable to make a larger or smaller grid.
|
||||
Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers.
|
||||
|
||||
WARNING: If you make scale too large, your GPU may bog down!
|
||||
@ -28,11 +28,11 @@ vec4 Colorizer(float counter, float maxSize)
|
||||
{
|
||||
float red = 0.0, green = 0.0, blue = 0.0;
|
||||
float normsize = counter/maxSize;
|
||||
|
||||
|
||||
red = smoothstep(0.3, 0.7, normsize);
|
||||
green = sin(3.14159*normsize);
|
||||
blue = 1.0 - smoothstep(0.0, 0.4, normsize);
|
||||
|
||||
|
||||
return vec4(0.8*red, 0.8*green, 0.8*blue, 1.0);
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ void main()
|
||||
if ((value == 0) || (value == 1) || (value == 2)) finalColor = vec4(1.0);
|
||||
else
|
||||
{
|
||||
for (int i = 2; (i < max(2, sqrt(value) + 1)); i++)
|
||||
for (int i = 2; (i < max(2, sqrt(value) + 1)); i++)
|
||||
{
|
||||
if ((value - i*floor(float(value)/float(i))) == 0)
|
||||
{
|
||||
|
||||
@ -7,7 +7,7 @@ out vec4 fragColor;
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float PI = 3.1415926535;
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ void main()
|
||||
if (lights[i].enabled == 1)
|
||||
{
|
||||
vec3 light = vec3(0.0);
|
||||
|
||||
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
|
||||
if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition);
|
||||
|
||||
@ -70,10 +70,10 @@ void main()
|
||||
|
||||
finalColor = (texelColor*((colDiffuse + vec4(specular,1))*vec4(lightDot, 1.0)));
|
||||
finalColor += texelColor*(ambient/10.0);
|
||||
|
||||
|
||||
// Gamma correction
|
||||
finalColor = pow(finalColor, vec4(1.0/2.2));
|
||||
|
||||
|
||||
// Fog calculation
|
||||
float dist = length(viewPos - fragPosition);
|
||||
|
||||
|
||||
@ -17,10 +17,10 @@ void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture(texture0, fragTexCoord)*colDiffuse*fragColor;
|
||||
|
||||
|
||||
// Convert texel color to grayscale using NTSC conversion weights
|
||||
float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(gray, gray, gray, texelColor.a);
|
||||
}
|
||||
@ -51,7 +51,7 @@ void main()
|
||||
We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
|
||||
And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power).
|
||||
*************************************************************************************************/
|
||||
|
||||
|
||||
// The pixel coordinates are scaled so they are on the mandelbrot scale
|
||||
// NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom
|
||||
vec2 z = vec2((fragTexCoord.x + offset.x/screenDims.x)*2.5/zoom, (fragTexCoord.y + offset.y/screenDims.y)*1.5/zoom);
|
||||
@ -60,18 +60,18 @@ void main()
|
||||
for (iterations = 0; iterations < MAX_ITERATIONS; iterations++)
|
||||
{
|
||||
z = ComplexSquare(z) + c; // Iterate function
|
||||
|
||||
|
||||
if (dot(z, z) > 4.0) break;
|
||||
}
|
||||
|
||||
|
||||
// Another few iterations decreases errors in the smoothing calculation.
|
||||
// See http://linas.org/art-gallery/escape/escape.html for more information.
|
||||
z = ComplexSquare(z) + c;
|
||||
z = ComplexSquare(z) + c;
|
||||
|
||||
|
||||
// This last part smooths the color (again see link above).
|
||||
float smoothVal = float(iterations) + 1.0 - (log(log(length(z)))/log(2.0));
|
||||
|
||||
|
||||
// Normalize the value so it is between 0 and 1.
|
||||
float norm = smoothVal/float(MAX_ITERATIONS);
|
||||
|
||||
|
||||
@ -54,17 +54,17 @@ void main()
|
||||
if (lights[i].enabled == 1)
|
||||
{
|
||||
vec3 light = vec3(0.0);
|
||||
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL)
|
||||
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL)
|
||||
{
|
||||
light = -normalize(lights[i].target - lights[i].position);
|
||||
}
|
||||
|
||||
if (lights[i].type == LIGHT_POINT)
|
||||
|
||||
if (lights[i].type == LIGHT_POINT)
|
||||
{
|
||||
light = normalize(lights[i].position - fragPosition);
|
||||
}
|
||||
|
||||
|
||||
float NdotL = max(dot(normal, light), 0.0);
|
||||
lightDot += lights[i].color.rgb*NdotL;
|
||||
|
||||
@ -76,7 +76,7 @@ void main()
|
||||
|
||||
finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
|
||||
finalColor += texelColor*(ambient/10.0)*colDiffuse;
|
||||
|
||||
|
||||
// Gamma correction
|
||||
finalColor = pow(finalColor, vec4(1.0/2.2));
|
||||
}
|
||||
|
||||
@ -17,19 +17,19 @@ out vec4 finalColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture(texture0, fragTexCoord); // Get texel color
|
||||
vec2 texelScale = vec2(0.0);
|
||||
vec4 texel = texture(texture0, fragTexCoord); // Get texel color
|
||||
vec2 texelScale = vec2(0.0);
|
||||
texelScale.x = outlineSize/textureSize.x;
|
||||
texelScale.y = outlineSize/textureSize.y;
|
||||
|
||||
// We sample four corner texels, but only for the alpha channel (this is for the outline)
|
||||
vec4 corners = vec4(0.0);
|
||||
corners.x = texture(texture0, fragTexCoord + vec2(texelScale.x, texelScale.y)).a;
|
||||
corners.y = texture(texture0, fragTexCoord + vec2(texelScale.x, -texelScale.y)).a;
|
||||
corners.z = texture(texture0, fragTexCoord + vec2(-texelScale.x, texelScale.y)).a;
|
||||
corners.w = texture(texture0, fragTexCoord + vec2(-texelScale.x, -texelScale.y)).a;
|
||||
|
||||
float outline = min(dot(corners, vec4(1.0)), 1.0);
|
||||
vec4 color = mix(vec4(0.0), outlineColor, outline);
|
||||
finalColor = mix(color, texel, texel.a);
|
||||
// We sample four corner texels, but only for the alpha channel (this is for the outline)
|
||||
vec4 corners = vec4(0.0);
|
||||
corners.x = texture(texture0, fragTexCoord + vec2(texelScale.x, texelScale.y)).a;
|
||||
corners.y = texture(texture0, fragTexCoord + vec2(texelScale.x, -texelScale.y)).a;
|
||||
corners.z = texture(texture0, fragTexCoord + vec2(-texelScale.x, texelScale.y)).a;
|
||||
corners.w = texture(texture0, fragTexCoord + vec2(-texelScale.x, -texelScale.y)).a;
|
||||
|
||||
float outline = min(dot(corners, vec4(1.0)), 1.0);
|
||||
vec4 color = mix(vec4(0.0), outlineColor, outline);
|
||||
finalColor = mix(color, texel, texel.a);
|
||||
}
|
||||
@ -15,12 +15,12 @@ out vec4 finalColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// To show overdraw, we just render all the fragments
|
||||
// To show overdraw, we just render all the fragments
|
||||
// with a solid color and some transparency
|
||||
|
||||
// NOTE: This is not a postpro render,
|
||||
|
||||
// NOTE: This is not a postpro render,
|
||||
// it will only render all screen texture in a plain color
|
||||
|
||||
|
||||
finalColor = vec4(1.0, 0.0, 0.0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
@ -20,12 +20,12 @@ void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec3 texelColor = texture(texture0, fragTexCoord.xy).rgb;
|
||||
|
||||
|
||||
texelColor = pow(texelColor, vec3(gamma, gamma, gamma));
|
||||
texelColor = texelColor*numColors;
|
||||
texelColor = floor(texelColor);
|
||||
texelColor = texelColor/numColors;
|
||||
texelColor = pow(texelColor, vec3(1.0/gamma));
|
||||
|
||||
|
||||
finalColor = vec4(texelColor, 1.0);
|
||||
}
|
||||
@ -21,12 +21,12 @@ void main()
|
||||
colors[0] = vec3(0.0, 0.0, 1.0);
|
||||
colors[1] = vec3(1.0, 1.0, 0.0);
|
||||
colors[2] = vec3(1.0, 0.0, 0.0);
|
||||
|
||||
|
||||
float lum = (texelColor.r + texelColor.g + texelColor.b)/3.0;
|
||||
|
||||
|
||||
int ix = (lum < 0.5)? 0:1;
|
||||
|
||||
|
||||
vec3 tc = mix(colors[ix], colors[ix + 1], (lum - float(ix)*0.5)/0.5);
|
||||
|
||||
|
||||
finalColor = vec4(tc, 1.0);
|
||||
}
|
||||
@ -8,7 +8,7 @@ in vec4 fragColor;
|
||||
out vec4 finalColor;
|
||||
|
||||
uniform vec3 viewEye;
|
||||
uniform vec3 viewCenter;
|
||||
uniform vec3 viewCenter;
|
||||
uniform float runTime;
|
||||
uniform vec2 resolution;
|
||||
|
||||
@ -32,7 +32,7 @@ uniform vec2 resolution;
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// A list of useful distance function to simple primitives, and an example on how to
|
||||
// A list of useful distance function to simple primitives, and an example on how to
|
||||
// do some interesting boolean operations, repetition and displacement.
|
||||
//
|
||||
// More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
|
||||
@ -143,7 +143,7 @@ float sdPryamid4(vec3 p, vec3 h ) // h = { cos a, sin a, height }
|
||||
{
|
||||
// Tetrahedron = Octahedron - Cube
|
||||
float box = sdBox( p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z) );
|
||||
|
||||
|
||||
float d = 0.0;
|
||||
d = max( d, abs( dot(p, vec3( -h.x, h.y, 0 )) ));
|
||||
d = max( d, abs( dot(p, vec3( h.x, h.y, 0 )) ));
|
||||
@ -238,7 +238,7 @@ vec2 map( in vec3 pos )
|
||||
res = opU( res, vec2( 0.5*sdTorus( opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7 ) );
|
||||
res = opU( res, vec2( sdConeSection( pos-vec3( 0.0,0.35,-2.0), 0.15, 0.2, 0.1 ), 13.67 ) );
|
||||
res = opU( res, vec2( sdEllipsoid( pos-vec3( 1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05) ), 43.17 ) );
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -246,14 +246,14 @@ vec2 castRay( in vec3 ro, in vec3 rd )
|
||||
{
|
||||
float tmin = 0.2;
|
||||
float tmax = 30.0;
|
||||
|
||||
|
||||
#if 1
|
||||
// bounding volume
|
||||
float tp1 = (0.0-ro.y)/rd.y; if( tp1>0.0 ) tmax = min( tmax, tp1 );
|
||||
float tp2 = (1.6-ro.y)/rd.y; if( tp2>0.0 ) { if( ro.y>1.6 ) tmin = max( tmin, tp2 );
|
||||
else tmax = min( tmax, tp2 ); }
|
||||
#endif
|
||||
|
||||
|
||||
float t = tmin;
|
||||
float m = -1.0;
|
||||
for( int i=0; i<64; i++ )
|
||||
@ -287,9 +287,9 @@ float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
|
||||
vec3 calcNormal( in vec3 pos )
|
||||
{
|
||||
vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
|
||||
return normalize( e.xyy*map( pos + e.xyy ).x +
|
||||
e.yyx*map( pos + e.yyx ).x +
|
||||
e.yxy*map( pos + e.yxy ).x +
|
||||
return normalize( e.xyy*map( pos + e.xyy ).x +
|
||||
e.yyx*map( pos + e.yyx ).x +
|
||||
e.yxy*map( pos + e.yxy ).x +
|
||||
e.xxx*map( pos + e.xxx ).x );
|
||||
/*
|
||||
vec3 eps = vec3( 0.0005, 0.0, 0.0 );
|
||||
@ -313,7 +313,7 @@ float calcAO( in vec3 pos, in vec3 nor )
|
||||
occ += -(dd-hr)*sca;
|
||||
sca *= 0.95;
|
||||
}
|
||||
return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );
|
||||
return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
// http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
|
||||
@ -324,11 +324,11 @@ float checkersGradBox( in vec2 p )
|
||||
// analytical integral (box filter)
|
||||
vec2 i = 2.0*(abs(fract((p-0.5*w)*0.5)-0.5)-abs(fract((p+0.5*w)*0.5)-0.5))/w;
|
||||
// xor pattern
|
||||
return 0.5 - 0.5*i.x*i.y;
|
||||
return 0.5 - 0.5*i.x*i.y;
|
||||
}
|
||||
|
||||
vec3 render( in vec3 ro, in vec3 rd )
|
||||
{
|
||||
{
|
||||
vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
|
||||
vec2 res = castRay(ro,rd);
|
||||
float t = res.x;
|
||||
@ -338,17 +338,17 @@ vec3 render( in vec3 ro, in vec3 rd )
|
||||
vec3 pos = ro + t*rd;
|
||||
vec3 nor = calcNormal( pos );
|
||||
vec3 ref = reflect( rd, nor );
|
||||
|
||||
// material
|
||||
|
||||
// material
|
||||
col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) );
|
||||
if( m<1.5 )
|
||||
{
|
||||
|
||||
|
||||
float f = checkersGradBox( 5.0*pos.xz );
|
||||
col = 0.3 + f*vec3(0.1);
|
||||
}
|
||||
|
||||
// lighting
|
||||
// lighting
|
||||
float occ = calcAO( pos, nor );
|
||||
vec3 lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) );
|
||||
vec3 hal = normalize( lig-rd );
|
||||
@ -357,7 +357,7 @@ vec3 render( in vec3 ro, in vec3 rd )
|
||||
float bac = clamp( dot( nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
|
||||
float dom = smoothstep( -0.1, 0.1, ref.y );
|
||||
float fre = pow( clamp(1.0+dot(nor,rd),0.0,1.0), 2.0 );
|
||||
|
||||
|
||||
dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
|
||||
dom *= calcSoftshadow( pos, ref, 0.02, 2.5 );
|
||||
|
||||
@ -399,22 +399,22 @@ void main()
|
||||
// pixel coordinates
|
||||
vec2 o = vec2(float(m),float(n)) / float(AA) - 0.5;
|
||||
vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
|
||||
#else
|
||||
#else
|
||||
vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
|
||||
#endif
|
||||
|
||||
// RAY: Camera is provided from raylib
|
||||
//vec3 ro = vec3( -0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x) );
|
||||
|
||||
|
||||
vec3 ro = viewEye;
|
||||
vec3 ta = viewCenter;
|
||||
|
||||
|
||||
// camera-to-world transformation
|
||||
mat3 ca = setCamera( ro, ta, 0.0 );
|
||||
// ray direction
|
||||
vec3 rd = ca * normalize( vec3(p.xy,2.0) );
|
||||
|
||||
// render
|
||||
// render
|
||||
vec3 col = render( ro, rd );
|
||||
|
||||
// gamma
|
||||
|
||||
@ -34,7 +34,7 @@ void main()
|
||||
// Draw circle layer
|
||||
vec3 color = vec3(0.9, 0.16, 0.21);
|
||||
vec4 layer2 = DrawCircle(fragCoord, position, radius, color);
|
||||
|
||||
|
||||
// Blend the two layers
|
||||
finalColor = mix(layer1, layer2, layer2.a);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ void main()
|
||||
// Scanlines method 2
|
||||
float globalPos = (fragTexCoord.y + offset) * frequency;
|
||||
float wavePos = cos((fract(globalPos) - 0.5)*3.14);
|
||||
|
||||
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture(texture0, fragTexCoord);
|
||||
|
||||
|
||||
@ -14,11 +14,11 @@ out vec4 finalColor;
|
||||
// NOTE: Add here your custom variables
|
||||
uniform vec2 resolution = vec2(800, 450);
|
||||
|
||||
void main()
|
||||
void main()
|
||||
{
|
||||
float x = 1.0/resolution.x;
|
||||
float y = 1.0/resolution.y;
|
||||
|
||||
|
||||
vec4 horizEdge = vec4(0.0);
|
||||
horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
|
||||
horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0;
|
||||
@ -26,7 +26,7 @@ void main()
|
||||
horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
|
||||
horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0;
|
||||
horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
|
||||
|
||||
|
||||
vec4 vertEdge = vec4(0.0);
|
||||
vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
|
||||
vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0;
|
||||
@ -34,8 +34,8 @@ void main()
|
||||
vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
|
||||
vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0;
|
||||
vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
|
||||
|
||||
|
||||
vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb));
|
||||
|
||||
|
||||
finalColor = vec4(edge, texture2D(texture0, fragTexCoord).a);
|
||||
}
|
||||
@ -23,10 +23,10 @@ uniform float screenWidth; // Width of the screen
|
||||
void main()
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
|
||||
// Get the position of the current fragment (screen coordinates!)
|
||||
vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y);
|
||||
|
||||
|
||||
// Find out which spotlight is nearest
|
||||
float d = 65000; // some high value
|
||||
int fi = -1; // found index
|
||||
@ -36,15 +36,15 @@ void main()
|
||||
for (int j = 0; j < MAX_SPOTS; j++)
|
||||
{
|
||||
float dj = distance(pos, spots[j].pos) - spots[j].radius + spots[i].radius;
|
||||
|
||||
if (d > dj)
|
||||
|
||||
if (d > dj)
|
||||
{
|
||||
d = dj;
|
||||
fi = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// d now equals distance to nearest spot...
|
||||
// allowing for the different radii of all spotlights
|
||||
if (fi != -1)
|
||||
@ -56,8 +56,8 @@ void main()
|
||||
else alpha = (d - spots[fi].inner) / (spots[fi].radius - spots[fi].inner);
|
||||
}
|
||||
}
|
||||
|
||||
// Right hand side of screen is dimly lit,
|
||||
|
||||
// Right hand side of screen is dimly lit,
|
||||
// could make the threshold value user definable
|
||||
if ((pos.x > screenWidth/2.0) && (alpha > 0.9)) alpha = 0.9;
|
||||
|
||||
|
||||
@ -27,16 +27,16 @@ void main()
|
||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
||||
vec2 tc = fragTexCoord*texSize;
|
||||
tc -= center;
|
||||
|
||||
|
||||
float dist = length(tc);
|
||||
|
||||
if (dist < radius)
|
||||
if (dist < radius)
|
||||
{
|
||||
float percent = (radius - dist)/radius;
|
||||
float theta = percent*percent*angle*8.0;
|
||||
float s = sin(theta);
|
||||
float c = cos(theta);
|
||||
|
||||
|
||||
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user