{
.name = "[vg] loader",
.link = NULL,
+
+ /* This is the old background shader */
+#if 0
.vs =
{
.orig_file = NULL,
"FragColor = vec4(vec3(0.5,0.5,0.5)*grad*fmt1,1.0);"
"}"
}
+#else
+
+ /* This is the new foreground shader */
+
+ .vs =
+ {
+ .orig_file = NULL,
+ .static_src = ""
+ "layout (location=0) in vec2 a_co;"
+ "out vec2 aUv;"
+ "void main()"
+ "{"
+ "gl_Position = vec4(a_co*2.0-1.0,0.0,1.0);"
+ "aUv = a_co;"
+ "}"
+ },
+ .fs =
+ {
+ .orig_file = NULL,
+ .static_src =
+
+ "out vec4 FragColor;"
+ "uniform float uTime;"
+ "uniform float uRatio;"
+ "in vec2 aUv;"
+
+ "float eval_zero( vec2 uv )"
+ "{"
+ "vec4 vsines = sin( (uTime+uv.y*80.0) * vec4(1.1,2.0234,3.73,2.444) );"
+ "float gradient = min( uv.y, 0.0 );"
+ "float offset = vsines.x*vsines.y*vsines.z*vsines.w*gradient;"
+
+ "vec2 vpos = uv + vec2( offset, 0.0 );"
+ "float dist = dot( vpos, vpos );"
+
+ "float fring = step(0.1*0.1,dist) * step(dist,0.15*0.15);"
+ "return max( 0.0, fring * 1.0+gradient*6.0 );"
+ "}"
+
+ "void main()"
+ "{"
+
+ "vec3 col = 0.5+0.5*sin( uTime + aUv.xyx + vec3(0.0,2.0,4.0) );"
+
+ "vec2 uvx = aUv - vec2( 0.5 );"
+ "uvx.x *= uRatio;"
+ "uvx.y *= 0.75;"
+
+ "float zero = eval_zero( uvx );"
+
+ "float dither=fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0)-0.5;"
+ "float fmt1 = step( 0.5, zero*zero + dither )*0.8+0.2;"
+
+ "FragColor = vec4(vec3(fmt1),0.8);"
+ "}"
+ }
+
+#endif
};
static struct vg_loader
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
+#if 0
glUseProgram( _shader_loader.id );
glUniform1f( glGetUniformLocation( _shader_loader.id, "uTime" ), vg.time );
-
glBindVertexArray( vg_loader.vao );
glDrawArrays( GL_TRIANGLES, 0, 6 );
+#endif
_vg_render_log();
+
+#if 1
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendEquation(GL_FUNC_ADD);
+
+ glUseProgram( _shader_loader.id );
+ glUniform1f( glGetUniformLocation( _shader_loader.id, "uTime" ), vg.time );
+ float ratio = (float)vg.window_x / (float)vg.window_y;
+ glUniform1f( glGetUniformLocation( _shader_loader.id, "uRatio"), ratio );
+ glBindVertexArray( vg_loader.vao );
+ glDrawArrays( GL_TRIANGLES, 0, 6 );
+#endif
}