Created
October 24, 2023 00:01
-
-
Save Vipitis/45e3181d1d6c81641c2b0411e56080fa to your computer and use it in GitHub Desktop.
naga panic during translation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 450 core | |
vec3 i_resolution; | |
vec4 i_mouse; | |
float i_time; | |
float i_time_delta; | |
int i_frame; | |
// Shadertoy compatibility, see we can use the same code copied from shadertoy website | |
#define iTime i_time | |
#define iResolution i_resolution | |
#define iTimeDelta i_time_delta | |
#define iMouse i_mouse | |
#define iFrame i_frame | |
#define mainImage shader_main | |
// step 1: a funciton with an inout input and some other return value | |
float fn(inout float a) { | |
a += 0.1; | |
return 0.2; | |
} | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
{ | |
// step 2: first variable that is vec2/vec3 (float works) | |
vec2 cd = vec2(0.3, 0.4); | |
// step 3: second variable is assigned to the return value, using first variable as args. | |
float e = fn(cd.x); | |
// Output to screen | |
fragColor = vec4(e); | |
} | |
layout(location = 0) in vec2 uv; | |
struct ShadertoyInput { | |
vec4 mouse; | |
vec3 resolution; | |
float time; | |
float time_delta; | |
int frame; | |
}; | |
layout(binding = 0) uniform ShadertoyInput input; | |
out vec4 FragColor; | |
void main(){ | |
i_time = input.time; | |
i_resolution = input.resolution; | |
i_time_delta = input.time_delta; | |
i_mouse = input.mouse; | |
i_frame = input.frame; | |
vec2 uv = vec2(uv.x, 1.0 - uv.y); | |
vec2 frag_coord = uv * i_resolution.xy; | |
shader_main(FragColor, frag_coord); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment