Skip to content

Commit 4ad90f5

Browse files
committed
Added our first ShaderToy.com conversion
1 parent 312a373 commit 4ad90f5

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

per-fragment-phong.fs.glsl

+27
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ uniform vec3 light_position = vec3(0.0, 0.0, 1000.0);
3131

3232
uniform sampler2D base_texture;
3333

34+
// A global time value as needed by many of the shader toy shaders.
35+
uniform float global_time;
36+
3437
subroutine(color_t)
3538
vec4 Constant()
3639
{
@@ -76,6 +79,30 @@ vec4 PPLWithTexture()
7679
vec3 specular = pow(max(dot(r, v), 0.0), specular_power) * specular_albedo;
7780

7881
return vec4(ambient + diffuse + specular, 1.0);
82+
//vec4(fs_in.T.t, fs_in.T.t, fs_in.T.t, 0); //
83+
}
84+
85+
subroutine(color_t)
86+
vec4 ShaderToy1()
87+
{
88+
// http://www.pouet.net/prod.php?which=57245
89+
90+
vec3 c;
91+
float l;
92+
float z= global_time;
93+
94+
for(int i=0;i<3;i++)
95+
{
96+
vec2 uv;
97+
vec2 p = fs_in.T;
98+
uv = p;
99+
p -= 0.5;
100+
z +=.07;
101+
l = length(p);
102+
uv += p / l * (sin(z)+1.0) * abs(sin(l * 9.0 - z * 2.0));
103+
c[i] = 0.01/length(abs(mod(uv, 1.0) - 0.5));
104+
}
105+
return vec4(c / l, 1.0);
79106
}
80107

81108
void main(void)

per-fragment-phong.vs.glsl

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#version 410 core
22

3-
// Lifted largely from OpenGL Superbible 7th Edition
4-
53
// Per-vertex attributes. The location here corresponds
64
// to the attribute number in the calling CPU-based program.
75
layout (location = 0) in vec3 position;

0 commit comments

Comments
 (0)