Skip to content

Commit 86c7697

Browse files
committed
replace default shader with something textureless
(thanks to glslsandbox for inspiration)
1 parent e1a2ca9 commit 86c7697

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

platform_sdl/Renderer.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,14 @@ namespace Renderer
120120
"\n"
121121
"layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything\n"
122122
"\n"
123+
"vec4 plas( vec2 v, float time )\n"
124+
"{\n"
125+
" float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );\n"
126+
" return vec4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );\n"
127+
"}\n"
123128
"void main(void)\n"
124129
"{\n"
125-
" vec2 uv = gl_TexCoord[0].xy;\n";
130+
" vec2 uv = gl_TexCoord[0].xy;\n"
126131
" uv -= 0.5;\n"
127132
" uv /= vec2(v2Resolution.y / v2Resolution.x, 1);\n"
128133
"\n"
@@ -135,8 +140,9 @@ namespace Renderer
135140
" m.x += sin( fGlobalTime ) * 0.1;\n"
136141
" m.y += fGlobalTime * 0.25;\n"
137142
"\n"
138-
" vec4 t = texture( texTex2, m.xy ) * d; // or /d\n"
139-
" out_color = f + t;// + uv.xyxy * 0.5 * (sin( fGlobalTime ) + 1.5);\n"
143+
" vec4 t = plas( m * 3.14, fGlobalTime ) / d;\n"
144+
" t = clamp( t, 0.0, 1.0 );\n"
145+
" out_color = f + t;\n"
140146
"}";
141147

142148
SDL_Surface * mScreen = NULL;

platform_w32_dx11/Renderer.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ namespace Renderer
7777
"{%midi:end%}"
7878
"}\n"
7979
"\n"
80+
"float4 plas( float2 v, float time )\n"
81+
"{\n"
82+
" float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );\n"
83+
" return float4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );\n"
84+
"}\n"
8085
"float4 main( float4 position : SV_POSITION, float2 TexCoord : TEXCOORD ) : SV_TARGET\n"
8186
"{\n"
8287
" float2 uv = TexCoord;\n"
@@ -92,8 +97,9 @@ namespace Renderer
9297
" m.x += sin( fGlobalTime ) * 0.1;\n"
9398
" m.y += fGlobalTime * 0.25;\n"
9499
"\n"
95-
" float4 t = texTex2.Sample( smp, m.xy ) * d; // or /d\n"
96-
" return f + t;// + uv.xyxy * 0.5 * (sin( fGlobalTime ) + 1.5);\n"
100+
" float4 t = plas( m * 3.14, fGlobalTime ) / d;\n"
101+
" t = saturate( t );\n"
102+
" return f + t;\n"
97103
"}";
98104

99105
char defaultVertexShader[65536] =

platform_w32_dx9/Renderer.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ namespace Renderer
7272
"float fGlobalTime; // in seconds\n"
7373
"float2 v2Resolution; // viewport resolution (in pixels)\n"
7474
"\n"
75+
"float4 plas( float2 v, float time )\n"
76+
"{\n"
77+
" float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );\n"
78+
" return float4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );\n"
79+
"}\n"
7580
"float4 main( float2 TexCoord : TEXCOORD0 ) : COLOR0\n"
7681
"{\n"
7782
" float2 uv = TexCoord;\n"
@@ -87,8 +92,9 @@ namespace Renderer
8792
" m.x += sin( fGlobalTime ) * 0.1;\n"
8893
" m.y += fGlobalTime * 0.25;\n"
8994
"\n"
90-
" float4 t = tex2D( texTex2, m.xy ) * d; // or /d\n"
91-
" return f + t;// + uv.xyxy * 0.5 * (sin( fGlobalTime ) + 1.5);\n"
95+
" float4 t = plas( m * 3.14, fGlobalTime ) / d;\n"
96+
" t = saturate( t );\n"
97+
" return f + t;\n"
9298
"}";
9399
char defaultVertexShader[65536] =
94100
"struct VS_INPUT_PP { float3 Pos : POSITION0; float2 TexCoord : TEXCOORD0; };\n"

0 commit comments

Comments
 (0)