X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fmodel_gate_unlinked.h;h=93ab1e32de8240bf985f5c857af8f22770479187;hb=5f6a4f9df6c8accc89f1920bfe9ace3cbac4c4b6;hp=449322aa95a2368792442e9ed59582dd8a6861d5;hpb=a109f126d8adab622e38fbcc2d4281e75255246a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/model_gate_unlinked.h b/shaders/model_gate_unlinked.h index 449322a..93ab1e3 100644 --- a/shaders/model_gate_unlinked.h +++ b/shaders/model_gate_unlinked.h @@ -1,168 +1,38 @@ -#ifndef SHADER_model_gate_unlinked_H -#define SHADER_model_gate_unlinked_H -static void shader_model_gate_unlinked_link(void); -static void shader_model_gate_unlinked_register(void); -static struct vg_shader _shader_model_gate_unlinked = { - .name = "model_gate_unlinked", - .link = shader_model_gate_unlinked_link, - .vs = +#pragma once +#include "vg/vg_engine.h" +extern struct vg_shader _shader_model_gate_unlinked; +extern GLuint _uniform_model_gate_unlinked_uMdl; +extern GLuint _uniform_model_gate_unlinked_uPv; +extern GLuint _uniform_model_gate_unlinked_uPvmPrev; +extern GLuint _uniform_model_gate_unlinked_uTime; +extern GLuint _uniform_model_gate_unlinked_uCam; +extern GLuint _uniform_model_gate_unlinked_uColour; +static inline void shader_model_gate_unlinked_uMdl(m4x3f m) { -.orig_file = "shaders/model.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = normalize( mat3(uMdl) * a_norm );\n" -" aCo = a_co;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/model_gate_unlinked.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"uniform float uTime;\n" -"uniform vec3 uCam;\n" -"uniform vec4 uColour;\n" -"\n" -"in vec3 aNorm;\n" -"in vec2 aUv;\n" -"in vec3 aCo;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 12 0 \n" -"\n" -"const int NOISE_LOOP = 3;\n" -"vec3 digital_noise( uvec3 iuv ){\n" -" iuv *=uvec3(8,2524,7552);\n" -" for( int i=0; i