From: Eleni Maria Stea Date: Mon, 1 Oct 2018 19:11:01 +0000 (+0300) Subject: clouds and better light beam X-Git-Url: http://git.mutantstargoat.com?p=lighthouse;a=commitdiff_plain;h=b9f859fddd8d2e482a6fbcfe37828b64865a8727 clouds and better light beam --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a5c0a51 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.o +*.d +*.swp +faros diff --git a/sdr/beam.v.glsl b/sdr/beam.v.glsl index a823e8b..6ea5003 100644 --- a/sdr/beam.v.glsl +++ b/sdr/beam.v.glsl @@ -1,9 +1,15 @@ +uniform float beam_len; + void main() { - float s = gl_Vertex.z + 1.0; + float dist = gl_Vertex.z; + float s = (dist + 1.0) * 1.6; vec4 pos = gl_Vertex * vec4(s, s, 1.0, 1.0); gl_Position = gl_ModelViewProjectionMatrix * pos; - gl_FrontColor = gl_Color; + + float d = dist / beam_len; + float falloff = min(1.0 - d, 1.0); + gl_FrontColor = vec4(gl_Color.xyz, gl_Color.a * falloff); } diff --git a/sdr/sky.f.glsl b/sdr/sky.f.glsl index 1767b42..4b830fe 100644 --- a/sdr/sky.f.glsl +++ b/sdr/sky.f.glsl @@ -1,92 +1,157 @@ -float pnoise(vec2 P, vec2 rep); -float pnoise_octaves(); +varying vec3 local_pos; + +#define PI 3.141592653589793 +#define TWO_PI (2.0 * PI) + +float fbm(vec3 p, int octaves); +float snoise(vec3 p); +float clouds(vec3 p); void main() { - float alt = min((gl_TexCoord[0].y + 0.29)* 2.0, 1.0); - float cloud_dens = 0.5; + vec3 lpos = normalize(local_pos); + + float cval = clouds(lpos * vec3(4.5, 4.5, 4.5)); + float alt = min(lpos.y * 2.0 + 0.5, 1.0); //const vec3 col_hor = vec3(0.96, 0.55, 0.98); const vec3 col_hor = vec3(0.95, 0.38, 0.54); - const vec3 col_zen = vec3(0.05, 0.15, 0.32); + const vec3 col_zen = vec3(0.08, 0.18, 0.4); - gl_FragColor.rgb = mix(col_hor, col_zen, alt); + vec3 skycol = mix(col_hor, col_zen, alt); + + gl_FragColor.rgb = mix(skycol, vec3(0.0, 0.0, 0.0), cval); gl_FragColor.a = 1.0; } +const float cloud_dens = 0.25; +const float cloud_smooth = 1.0; +const float cloud_alpha = 0.4; -// -// GLSL textureless classic 2D noise "cnoise", -// with an RSL-style periodic variant "pnoise". -// Author: Stefan Gustavson (stefan.gustavson@liu.se) -// Version: 2011-08-22 -// -// Many thanks to Ian McEwan of Ashima Arts for the -// ideas for permutation and gradient selection. -// -// Copyright (c) 2011 Stefan Gustavson. All rights reserved. -// Distributed under the MIT license. See LICENSE file. -// https://github.com/ashima/webgl-noise -// - -vec4 mod289(vec4 x) +float clouds(vec3 p) { - return x - floor(x * (1.0 / 289.0)) * 289.0; + float hor = clamp(p.y * 2.0, 0.0, 1.0); + float nval = fbm(p * vec3(0.2, 1.0, 0.2), 5); + float res = smoothstep(cloud_dens - cloud_smooth * 0.5, + cloud_dens + cloud_smooth * 0.5, nval); + return res * hor * cloud_alpha; } -vec4 permute(vec4 x) +float fbm(vec3 p, int octaves) { - return mod289(((x*34.0)+1.0)*x); + float res = 0.0; + float freq = 1.0; + float s = 1.0; + + for(int i=0; i