X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=fishladder_resources.h;h=2bd1442d125e379b53eb589b77fc3f0b81ba8390;hb=4528469af4267280885db212dd5c68ee938ebd92;hp=0585b0ce2cb295499c5db40df375074e1e98e9d9;hpb=e750e1ea996212bec83072cab19cc21c358b4d89;p=fishladder.git diff --git a/fishladder_resources.h b/fishladder_resources.h index 0585b0c..2bd1442 100644 --- a/fishladder_resources.h +++ b/fishladder_resources.h @@ -1,11 +1,11 @@ // TEXTURES // =========================================================================================================== -vg_tex2d tex_tile_data = { .path = "textures/tileset.png" }; -vg_tex2d tex_tile_detail = { .path = "textures/tile_overlays.png" }; -vg_tex2d tex_wood = { .path = "textures/wood.png" }; -vg_tex2d tex_ball = { .path = "textures/ball.png", .flags = VG_TEXTURE_CLAMP }; -vg_tex2d tex_background = { .path = "textures/background.png" }; +vg_tex2d tex_tile_data = { .path = "textures/tileset.qoi" }; +vg_tex2d tex_tile_detail = { .path = "textures/tile_overlays.qoi" }; +vg_tex2d tex_wood = { .path = "textures/wood.qoi" }; +vg_tex2d tex_ball = { .path = "textures/ball.qoi", .flags = VG_TEXTURE_CLAMP }; +vg_tex2d tex_background = { .path = "textures/background.qoi" }; vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_ball, &tex_background }; @@ -292,12 +292,65 @@ SHADER_DEFINE( shader_background, UNIFORMS({ "uPv", "uOffset", "uTexMain", "uVariance", "uSamplerNoise" }) ) +SHADER_DEFINE( shader_wire, + // VERTEX + "layout (location=0) in vec2 a_co;" + "uniform vec3 uStart;" + "uniform vec3 uEnd;" + "uniform mat3 uPv;" + "uniform float uCurve;" + "" + "out vec2 aTexCoords;" + "" + "vec3 sample_curve_time( float t )" + "{" + "vec3 line_coord = mix( uStart, uEnd, t );" + + "float curve_amt = 1.0-(pow((t*2.0-1.0),2.0));" + "return vec3( line_coord.x, line_coord.y - curve_amt*uCurve, line_coord.z );" + "}" + "" + "void main()" + "{" + // Vertex transform + "vec3 p0 = sample_curve_time( a_co.x );" + "vec3 p1 = sample_curve_time( a_co.x + 0.025 );" + + "vec2 line_tangent = normalize(p1.xy-p0.xy);" + "vec2 line_normal = vec2( -line_tangent.y, line_tangent.x );" + + "vec2 worldfinal = p0.xy + line_normal*a_co.y*p0.z;" + + "gl_Position = vec4( uPv * vec3(worldfinal, 1.0), 1.0 );" + + // Create texture coords (todo: include stretch adjusted coords?) + "aTexCoords = vec2( a_co.x, a_co.y + 0.5 );" + "}", + + // FRAGMENT + "out vec4 FragColor;" + "" + "uniform sampler2D uTexMain;" + "uniform vec4 uColour;" + "" + "in vec2 aTexCoords;" + "" + "void main()" + "{" + "FragColor = uColour;" + "}" + , + UNIFORMS({ "uPv", "uColour", "uTexMain", "uStart", "uEnd", "uCurve" }) +) + + void vg_register(void) { SHADER_INIT( shader_tile_colour ); SHADER_INIT( shader_tile_main ); SHADER_INIT( shader_ball ); SHADER_INIT( shader_background ); + SHADER_INIT( shader_wire ); } /*