URL: http://glslsandbox.com/e#21943.9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
// Merry Christmas Everyone! // By: Brandon Fogerty // bfogerty at gmail dot com // "“Glory to God in the highest, and on earth peace among those with whom He is pleased!” - Luke 2:14 // "But he was pierced for our transgressions, // he was crushed for our iniquities; // the punishment that brought us peace was on him, // and by his wounds we are healed." - Isaiah 53:5-6 // Special Thanks to my Beautiful Wife, Naomi, for the design! #ifdef GL_ES precision mediump float; #endif uniform float time; uniform vec2 resolution; #define Resolution resolution #define Time time #define GloryGlowColor vec3(0.26, 0.16, 0.06) #define VerticalBarWidth 0.09 #define VerticalBarHeight 0.9 #define HorizontalBarWidth 0.7 #define HorizontalBarHeight 0.07 #define HorizontalBarVerticalOffset 0.4 #define ChristsCrossColor vec3( 1.0, 1.0, 1.0 ) #define UnrepentantThiefsCrossColor vec3( 0.45, 0.45, 0.45 ) #define RepentantThiefsCrossColor vec3( 0.90, 0.90, 0.90 ) #define CrossGlowScale 0.02 #define CrossGloryGlowMin 0.35 #define CrossGloryGlowMax 1.00 float hash( float x ) { return fract( sin( x ) * 43758.5453 ); } float noise( vec2 uv ) // Thanks Inigo Quilez { vec3 x = vec3( uv.xy, 0.0 ); vec3 p = floor( x ); vec3 f = fract( x ); f = f*f*(3.0 - 2.0*f); float offset = 57.0; float n = dot( p, vec3(1.0, offset, offset*2.0) ); return mix( mix( mix( hash( n + 0.0 ), hash( n + 1.0 ), f.x ), mix( hash( n + offset), hash( n + offset+1.0), f.x ), f.y ), mix( mix( hash( n + offset*2.0), hash( n + offset*2.0+1.0), f.x), mix( hash( n + offset*3.0), hash( n + offset*3.0+1.0), f.x), f.y), f.z); } float snoise( vec2 uv ) { return noise( uv ) * 2.0 - 1.0; } float perlinNoise( vec2 uv ) { float n = noise( uv * 1.0 ) * 128.0 + noise( uv * 2.0 ) * 64.0 + noise( uv * 4.0 ) * 32.0 + noise( uv * 8.0 ) * 16.0 + noise( uv * 16.0 ) * 8.0 + noise( uv * 32.0 ) * 4.0 + noise( uv * 64.0 ) * 2.0 + noise( uv * 128.0 ) * 1.0; float noiseVal = n / ( 1.0 + 2.0 + 4.0 + 8.0 + 16.0 + 32.0 + 64.0 + 128.0 ); noiseVal = abs(noiseVal * 2.0 - 1.0); return noiseVal; } float fBm( vec2 uv, float lacunarity, float gain ) { float sum = 0.0; float amp = 1.0; for( int i = 0; i < 10; ++i ) { sum += ( perlinNoise( uv ) ) * amp; amp *= gain; uv *= lacunarity; } return sum; } float pulse( float value, float minValue, float maxValue ) { float t = step( minValue, value ) - step( maxValue, value ); return t; } vec3 cross( vec2 uv, float verticalBarWidth, float verticalBarHeight, float horizontalBarWidth, float horizontalBarHeight, float horizontalBarVerticalOffset, vec2 position, float scale, vec3 color ) { verticalBarWidth *= scale; verticalBarHeight *= scale; horizontalBarWidth *= scale; horizontalBarHeight *= scale; horizontalBarVerticalOffset *= scale; float verticleBar = pulse( uv.x, -verticalBarWidth + position.x, verticalBarWidth + position.x ); verticleBar *= pulse( uv.y, -verticalBarHeight + position.y, verticalBarHeight + position.y ); float horizontalBar = pulse( uv.x, -horizontalBarWidth + position.x, horizontalBarWidth + position.x ); horizontalBar *= pulse( uv.y, -horizontalBarHeight + horizontalBarVerticalOffset + position.y, horizontalBarHeight + horizontalBarVerticalOffset + position.y ); float intensity = clamp(verticleBar + horizontalBar, 0.0, 1.0); vec3 finalColor = (color * intensity); return finalColor; } vec3 gloryGlow( vec2 uv, vec3 glowColor, float minGlow, float maxGlow, float noiseFactor, float speed ) { float t = sin( Time ) * 0.50 + 0.50; float glowAmount = mix( minGlow, maxGlow, t ); vec2 glowUV = uv + vec2( 0.0, 0.0 ); float glowPulse = sin( glowUV.x * glowAmount ); vec3 color = glowColor * abs( 1.0 / glowPulse ) * noiseFactor; return color; } vec3 beam( vec2 uv, vec3 glowColor, float noiseFactor, float offset, float speed ) { float t = sin( Time * speed ) * 0.50 + 0.50; float glowAmount = mix( 0.20, 1.0, t ); vec2 glowUV = uv + vec2( 0.0, 0.0 ); float glowPulse = sin( glowUV.x * glowAmount ); float t2 = sin( Time * 0.50 ) * 0.50 + 0.50; float lengthOfBeam = mix( -1.0, 0.70, 1.0 - t2 ); glowUV = uv + vec2( -1.24 - sin(offset + Time + uv.y * speed) * 0.10, 0.0 ); glowPulse = sin( glowUV.x * 0.7 ); float glowFactor = (( abs( 0.2 / glowPulse ) * noiseFactor)) * (sin(uv.y + lengthOfBeam) * 1.0); vec3 color = clamp( glowColor * glowFactor, 0.0, 1.50); return color; } void main( void ) { vec2 uv = ( gl_FragCoord.xy / Resolution.xy ) * 2.0 - 1.0; uv.x *= ( Resolution.x / Resolution.y ); vec3 finalColor = vec3( 0.0, 0.0, 0.0 ); float noiseFactor = fBm( uv * 1.0, 2.0, 0.9 ); finalColor += gloryGlow( uv, GloryGlowColor, CrossGloryGlowMin, CrossGloryGlowMax, noiseFactor, 1.0 ); vec3 beamColor = vec3( 0.0, 0.0, 0.0 ); beamColor += beam( uv, vec3( 0.03, 0.03, 0.13), noiseFactor, 0.0, 2.4 ); beamColor += beam( uv, vec3( 0.03, 0.13, 0.03), noiseFactor, 0.2, 3.5 ); beamColor += beam( uv, vec3( 0.13, 0.13, 0.03), noiseFactor, 1.4, 4.6 ); beamColor += beam( uv, vec3( 0.13, 0.03, 0.03), noiseFactor, 4.0, 6.7 ); beamColor += beam( uv, vec3( 0.13, 0.03, 0.13), noiseFactor, 6.7, 8.7 ); float t = sin( Time + (uv.y / 2.0) ) * 0.5 + 0.5; finalColor += (beamColor * t); finalColor += cross( uv, VerticalBarWidth, VerticalBarHeight, HorizontalBarWidth + 0.05, HorizontalBarHeight, HorizontalBarVerticalOffset, vec2( 0.0, 0.0 ), 1.0, ChristsCrossColor ); finalColor += cross( uv, VerticalBarWidth, VerticalBarHeight, HorizontalBarWidth, HorizontalBarHeight, HorizontalBarVerticalOffset, vec2( -1.2, -0.5 ), 0.2, UnrepentantThiefsCrossColor ); finalColor += cross( uv, VerticalBarWidth, VerticalBarHeight, HorizontalBarWidth, HorizontalBarHeight, HorizontalBarVerticalOffset, vec2( 1.2, -0.5 ), 0.2, RepentantThiefsCrossColor ); finalColor *= mix( 0.7, 1.0, uv.y ); finalColor *= mix( 0.7, 1.0, -abs(uv.x)); gl_FragColor = vec4( finalColor, 1.0 ); } |