|
1 | 1 | package baaahs.glsl
|
2 | 2 |
|
3 | 3 | import baaahs.glshaders.GlslAnalyzer
|
| 4 | +import baaahs.show.Shader |
| 5 | +import baaahs.show.ShaderType |
4 | 6 |
|
5 | 7 | object Shaders {
|
| 8 | + val smpteColorBars = Shader("SMTPE Color Bars", ShaderType.Paint, """ |
| 9 | + // Robby Kraft |
| 10 | + // from https://www.shadertoy.com/view/XlGXRz |
| 11 | +
|
| 12 | + void mainImage( out vec4 fragColor, in vec2 fragCoord ) |
| 13 | + { |
| 14 | + float br = 0.75; // a less popular SMPTE version uses 1.0 |
| 15 | +
|
| 16 | + vec2 st = fragCoord.xy/iResolution.xy; |
| 17 | +
|
| 18 | + bool sev1 = bool( step(st.x, 1.0/7.0) ); |
| 19 | + bool sev2 = bool( step(st.x, 2.0/7.0) ); |
| 20 | + bool sev3 = bool( step(st.x, 3.0/7.0) ); |
| 21 | + bool sev4 = bool( step(st.x, 4.0/7.0) ); |
| 22 | + bool sev5 = bool( step(st.x, 5.0/7.0) ); |
| 23 | + bool sev6 = bool( step(st.x, 6.0/7.0) ); |
| 24 | +
|
| 25 | + bool row1 = !bool( step(st.y, 0.3333) ); |
| 26 | + bool row2 = !bool( step(st.y, 0.25) ); |
| 27 | +
|
| 28 | + ///////////////////////////////////////// |
| 29 | + // R : 0.75 1.0 1.0 1.0 |
| 30 | + // G : 0.75 1.0 1.0 1.0 |
| 31 | + // B : 0.75 1.0 1.0 1.0 |
| 32 | + ///////////////////////////////////////// |
| 33 | + float top_red = br * float((sev6 && !sev4) || sev2 ); |
| 34 | + float top_green = br * float(sev4); |
| 35 | + float top_blue = br * float(!sev6 || (sev5 && !sev4) || (sev3 && !sev2) || sev1 ); |
| 36 | +
|
| 37 | + ///////////////////////////////////////// |
| 38 | + // R : 1.0 0.75 |
| 39 | + // G : 1.0 0.75 |
| 40 | + // B : 1.0 1.0 1.0 0.75 |
| 41 | + ///////////////////////////////////////// |
| 42 | + float mid_red = 0.075*float( (sev6 && !sev5)||(sev4 && !sev3)||(sev2 && !sev1) ) + br * float(!sev6 || (sev3 && !sev2) ); |
| 43 | + float mid_green = 0.075*float( (sev6 && !sev5)||(sev4 && !sev3)||(sev2 && !sev1) ) + br * float(!sev6 || (sev5 && !sev4) ); |
| 44 | + float mid_blue = 0.075*float( (sev6 && !sev5)||(sev4 && !sev3)||(sev2 && !sev1) ) + br * float(!sev6 || (sev5 && !sev4) || (sev3 && !sev2) || sev1); |
| 45 | +
|
| 46 | + /////////////////////// |
| 47 | + // R: 0.00 1.0 0.22 |
| 48 | + // G: 0.24 1.0 0.00 |
| 49 | + // B: 0.35 1.0 0.5 |
| 50 | + /////////////////////// |
| 51 | + bool fourth1 = bool( step(st.x, 1.0*(5.0/7.0)/4.0 )); |
| 52 | + bool fourth2 = bool( step(st.x, 2.0*(5.0/7.0)/4.0 )); |
| 53 | + bool fourth3 = bool( step(st.x, 3.0*(5.0/7.0)/4.0 )); |
| 54 | + bool fourth4 = bool( step(st.x, (5.0/7.0) )); |
| 55 | +
|
| 56 | + bool littleThird1 = bool( step(st.x, 5.0/7.0 + 1.0/7.0/3.0) ); |
| 57 | + bool littleThird2 = bool( step(st.x, 5.0/7.0 + 1.0/7.0/3.0*2.0) ); |
| 58 | + bool littleThird3 = bool( step(st.x, 5.0/7.0 + 1.0/7.0/3.0*3.0) ); |
| 59 | +
|
| 60 | + float bottom_red = float(fourth2 && !fourth1) + 0.22*float(fourth3 && !fourth2) + 0.075*float(fourth4 && !fourth3) + 0.075*float(littleThird2 && !littleThird1) + 0.15*float(littleThird3 && !littleThird2) + 0.075*float(!sev6); |
| 61 | + float bottom_green = 0.24*float(fourth1) + float(fourth2 && !fourth1) + 0.075*float(fourth4 && !fourth3) + 0.075*float(littleThird2 && !littleThird1) + 0.15*float(littleThird3 && !littleThird2) + 0.075*float(!sev6); |
| 62 | + float bottom_blue = 0.35*float(fourth1) + float(fourth2 && !fourth1) + 0.5*float(fourth3 && !fourth2) + 0.075*float(fourth4 && !fourth3) + 0.075*float(littleThird2 && !littleThird1) + 0.15*float(littleThird3 && !littleThird2) + 0.075*float(!sev6); |
| 63 | +
|
| 64 | + fragColor = vec4(top_red*float(row1) + mid_red*float(row2 && !row1) + bottom_red*float(!row2), |
| 65 | + top_green*float(row1) + mid_green*float(row2 && !row1) + bottom_green*float(!row2), |
| 66 | + top_blue*float(row1) + mid_blue*float(row2 && !row1) + bottom_blue*float(!row2),1.); |
| 67 | + } |
| 68 | + """.trimIndent()) |
6 | 69 |
|
7 | 70 | val cylindricalUvMapper = GlslAnalyzer().openShader(
|
8 | 71 | /**language=glsl*/
|
|
0 commit comments