From 3364a1ab0c57ac1e3031a8942d8b330145bbfd24 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 13 Mar 2013 16:49:41 +0000 Subject: [PATCH] tutorial: randomise colours. --- tutorial/12_texture_to_screen.lolfx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tutorial/12_texture_to_screen.lolfx b/tutorial/12_texture_to_screen.lolfx index a4d29779..78ca4d6d 100644 --- a/tutorial/12_texture_to_screen.lolfx +++ b/tutorial/12_texture_to_screen.lolfx @@ -23,6 +23,13 @@ precision highp float; uniform sampler2D in_texture; varying vec2 pass_position; +vec3 rand_color(float t) +{ + return vec3(0.5 + 0.5 * sin(t * 19.0 + 17.0), + 0.5 + 0.5 * sin(t * 24.0 + 23.0), + 0.5 + 0.5 * sin(t * 37.0 + 12.0)); +} + void main(void) { vec2 texcoords = pass_position * 0.5 + vec2(0.5, 0.5); @@ -31,7 +38,7 @@ void main(void) float newb = 0.0; if (newg > 0.0) newb = 1.0; - gl_FragColor = vec4(0.0, newg, 0.0, 1.0); + gl_FragColor = vec4(rand_color(newg), 1.0); } [vert.hlsl] @@ -46,6 +53,13 @@ void main(float2 in_Position : POSITION, [frag.hlsl] +float3 rand_color(float t) +{ + return float3(0.5 + 0.5 * sin(t * 9.0 + 3.0), + 0.5 + 0.5 * sin(t * 4.0 + 1.0), + 0.5 + 0.5 * sin(t * 7.0 + 2.0)); +} + void main(in float2 pass_Position : TEXCOORD0, uniform sampler2D in_Texture, uniform float in_Flag,