Created
September 12, 2020 14:15
-
-
Save monkstone/cfcca33e47605bf764f307f37d7a4644 to your computer and use it in GitHub Desktop.
Shadertoy wrapper
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
require 'erb' | |
shadertoy = File.read(ARGV[0]) | |
def shader_template | |
%( | |
#ifdef GL_ES | |
precision mediump float; | |
precision mediump int; | |
#endif | |
\/\/ ---------------------- | |
\/\/ SHADERTOY UNIFORMS - | |
\/\/ ---------------------- | |
uniform vec3 iResolution; \/\/ viewport resolution (in pixels) | |
uniform float iTime; \/\/ shader playback time (in seconds) | |
uniform float iTimeDelta; \/\/ render time (in seconds) | |
uniform int iFrame; \/\/ shader playback frame | |
uniform vec4 iMouse; \/\/ mouse pixel coords. xy: current (if MLB down), zw: click | |
uniform vec4 iDate; \/\/ (year, month, day, time in seconds) | |
\/\/uniform float iChannelTime[2]; | |
\/\/uniform vec3 iChannelResolution[2]; | |
\/\/ Channels can be either 2D maps or Cubemaps. | |
\/\/ Pick the ones you need and uncomment them. | |
\/\/ uniform float iChannelTime[1..4]; \/\/ channel playback time (in seconds) | |
\/\/ uniform vec3 iChannelResolution[1..4]; \/\/ channel resolution (in pixels) | |
/* | |
uniform sampler2D iChannel0; | |
uniform sampler2D iChannel1; | |
uniform sampler2D iChannel2; | |
uniform sampler2D iChannel3; | |
uniform samplerCube iChannel0; | |
uniform samplerCube iChannel1; | |
uniform samplerCube iChannel2; | |
uniform samplerCube iChannel3; | |
uniform vec3 iChannelResolution[4]; \/\/ channel resolution (in pixels) | |
uniform float iChannelTime[4]; \/\/ Channel playback time (in seconds) | |
*/ | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ); | |
void main() { | |
mainImage(gl_FragColor,gl_FragCoord.xy); | |
} | |
\/\/ Shadertoy code | |
<%= shadertoy %> | |
\/\/ End of Shadertoy code | |
) | |
end | |
renderer = ERB.new(shader_template) | |
output = renderer.result | |
File.write('wrapper.glsl', output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment