Skip to content

Commit

Permalink
replace default shader with something textureless
Browse files Browse the repository at this point in the history
(thanks to glslsandbox for inspiration)
  • Loading branch information
Gargaj committed Feb 17, 2015
1 parent e1a2ca9 commit 86c7697
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
12 changes: 9 additions & 3 deletions platform_sdl/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,14 @@ namespace Renderer
"\n"
"layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything\n"
"\n"
"vec4 plas( vec2 v, float time )\n"
"{\n"
" float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );\n"
" return vec4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );\n"
"}\n"
"void main(void)\n"
"{\n"
" vec2 uv = gl_TexCoord[0].xy;\n";
" vec2 uv = gl_TexCoord[0].xy;\n"
" uv -= 0.5;\n"
" uv /= vec2(v2Resolution.y / v2Resolution.x, 1);\n"
"\n"
Expand All @@ -135,8 +140,9 @@ namespace Renderer
" m.x += sin( fGlobalTime ) * 0.1;\n"
" m.y += fGlobalTime * 0.25;\n"
"\n"
" vec4 t = texture( texTex2, m.xy ) * d; // or /d\n"
" out_color = f + t;// + uv.xyxy * 0.5 * (sin( fGlobalTime ) + 1.5);\n"
" vec4 t = plas( m * 3.14, fGlobalTime ) / d;\n"
" t = clamp( t, 0.0, 1.0 );\n"
" out_color = f + t;\n"
"}";

SDL_Surface * mScreen = NULL;
Expand Down
10 changes: 8 additions & 2 deletions platform_w32_dx11/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ namespace Renderer
"{%midi:end%}"
"}\n"
"\n"
"float4 plas( float2 v, float time )\n"
"{\n"
" float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );\n"
" return float4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );\n"
"}\n"
"float4 main( float4 position : SV_POSITION, float2 TexCoord : TEXCOORD ) : SV_TARGET\n"
"{\n"
" float2 uv = TexCoord;\n"
Expand All @@ -92,8 +97,9 @@ namespace Renderer
" m.x += sin( fGlobalTime ) * 0.1;\n"
" m.y += fGlobalTime * 0.25;\n"
"\n"
" float4 t = texTex2.Sample( smp, m.xy ) * d; // or /d\n"
" return f + t;// + uv.xyxy * 0.5 * (sin( fGlobalTime ) + 1.5);\n"
" float4 t = plas( m * 3.14, fGlobalTime ) / d;\n"
" t = saturate( t );\n"
" return f + t;\n"
"}";

char defaultVertexShader[65536] =
Expand Down
10 changes: 8 additions & 2 deletions platform_w32_dx9/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ namespace Renderer
"float fGlobalTime; // in seconds\n"
"float2 v2Resolution; // viewport resolution (in pixels)\n"
"\n"
"float4 plas( float2 v, float time )\n"
"{\n"
" float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );\n"
" return float4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );\n"
"}\n"
"float4 main( float2 TexCoord : TEXCOORD0 ) : COLOR0\n"
"{\n"
" float2 uv = TexCoord;\n"
Expand All @@ -87,8 +92,9 @@ namespace Renderer
" m.x += sin( fGlobalTime ) * 0.1;\n"
" m.y += fGlobalTime * 0.25;\n"
"\n"
" float4 t = tex2D( texTex2, m.xy ) * d; // or /d\n"
" return f + t;// + uv.xyxy * 0.5 * (sin( fGlobalTime ) + 1.5);\n"
" float4 t = plas( m * 3.14, fGlobalTime ) / d;\n"
" t = saturate( t );\n"
" return f + t;\n"
"}";
char defaultVertexShader[65536] =
"struct VS_INPUT_PP { float3 Pos : POSITION0; float2 TexCoord : TEXCOORD0; };\n"
Expand Down

0 comments on commit 86c7697

Please sign in to comment.