Skip to content

Instantly share code, notes, and snippets.

/am_i_dreaming_gl2.xml Secret

Created Apr 13, 2015
Embed
What would you like to do?
uploaded by Drest for Geeks3D
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<glsl_hacker>
<window name="win3d01" title="Shadertoy - Am I Dreaming?"
width="800" height="400"
gl_version_major="2" gl_version_minor="1" />
<gpu_program name="shadertoy_prog" >
<raw_data_vs><![CDATA[
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
]]></raw_data_vs>
<raw_data_ps><![CDATA[
// https://www.shadertoy.com/view/ldXGDl
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iGlobalTime; // shader playback time (in seconds)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform sampler2D iChannel0;
void main(void)
{
vec2 uv = gl_FragCoord.xy / iResolution.xy - .5;
uv.x*=iResolution.x/iResolution.y;
if (iMouse.z>0.) uv+=(iMouse.xy/iResolution.xy-.5)*2.;
float t=iGlobalTime*.2;
float fov=1.5+sin(t);
vec3 dir=normalize(vec3(uv*fov*mat2(cos(t),sin(t),-sin(t),cos(t)),1.));
vec3 from=vec3(sin(t*1.28352),0.,t*5.)*.005;
float dist=-0.015;
vec3 vol=vec3(0.);
for (int v=0; v<500; v++) {
dist+=.00015;
vec3 p=from+dist*dir*vec3(vec2(sign(dist)),1.);
vec3 disp=texture2D(iChannel0,vec2(length(p.xy),p.z*.3)*2.2568).xyz-.5;
vol+=pow(length(abs(.5-mod(p+disp*.013,vec3(.01))/.01)),14.)
*(.7+normalize(disp)*.3)*exp(-500.*dist*dist);
}
vol=(vol+.2)*min(1.,t-.05)*vec3(1.,.8,.7);
gl_FragColor = vec4(pow(vol,vec3(1.3)),1.0);
} ]]></raw_data_ps>
</gpu_program>
<script name="init_scene" run_mode="INIT" >
<raw_data><![CDATA[
app_dir = gh_utils.get_scripting_libs_dir()
dofile(app_dir .. "lua/Moon3D_v2.lua")
moon3d.init(2, 1)
moon3d.graphics.vsync(0)
bmfont = moon3d.font.create("trebuchet_20px.fnt", "data/")
bmfont_texture = moon3d.font.getTexture(bmfont)
moon3d.madshaders.setBmFontData(bmfont, bmfont_texture)
winW, winH = moon3d.window.getSize()
quad = moon3d.graphics.newQuad(winW, winH)
shadertoy_prog = moon3d.graphics.getGpuProgram("shadertoy_prog")
tex0 = moon3d.image.load2d("./data/noise_texture_0002b_256x256.png")
moon3d.madshaders.resetBenchmarkData()
]]></raw_data>
</script>
<script name="update_scene" run_mode="FRAME" >
<raw_data><![CDATA[
moon3d.startFrame(0, 0, 0, 1)
local global_time = moon3d.getTime()
moon3d.madshaders.updateBenchmarkData(global_time)
moon3d.camera.bindOrtho()
moon3d.graphics.bindGpuProgram(shadertoy_prog)
moon3d.madshaders.updateShadertoyCommonParams(shadertoy_prog, global_time)
moon3d.madshaders.setShadertoyTexture(shadertoy_prog, tex0, 0)
moon3d.graphics.draw(quad)
moon3d.madshaders.displayBenchmarkInfoV2("Shadertoy/Am I Dreaming?", global_time, 1, 1, 1, 1)
moon3d.endFrame()
]]></raw_data>
</script>
<script name="resize_scene" run_mode="SIZE" >
<raw_data><![CDATA[
moon3d.window.resize()
winW, winH = moon3d.window.getSize()
moon3d.graphics.resizeQuad(quad, winW, winH)
]]></raw_data>
</script>
</glsl_hacker>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment