From f79699d4c8b40e43847ec5f75993b5a39b598e53 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 12 Dec 2022 20:01:25 -0800 Subject: plasma-node: link infects_rate_smoothed to plasma For now just scale the intensity of the plasma by the infections rate. When the infections rate sustain the maximum rate, the plasma eventually turns black. Will probably have to iterate a bit on this --- src/plasma-node.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/plasma-node.c') diff --git a/src/plasma-node.c b/src/plasma-node.c index 656aa56..0d276ba 100644 --- a/src/plasma-node.c +++ b/src/plasma-node.c @@ -68,6 +68,7 @@ static const char *plasma_fs = "" "uniform float alpha;" "uniform float time;" + "uniform float gloom;" "void main() {" " float v;" @@ -92,29 +93,32 @@ static const char *plasma_fs = "" " v += sin(sqrt(c.x * c.x + c.y * c.y + 1.0) + stime);" " vec3 col = vec3(cos(PI * v + sin(time)), sin(PI * v + cos(time * .33)), cos(PI * v + sin(time * .66)));" - " gl_FragColor = vec4(col * .5 + .5, alpha);" + " gl_FragColor = vec4((col * .5 + .5) * (1.f - gloom), alpha);" "}" ""; static void plasma_uniforms(void *uniforms_ctxt, void *render_ctxt, unsigned n_uniforms, const int *uniforms, const m4f_t *model_x, float alpha) { + float *gloom = uniforms_ctxt; play_t *play = render_ctxt; glUniform1f(uniforms[0], alpha); glUniform1f(uniforms[1], play_ticks(play, PLAY_TICKS_TIMER0) * .001f); // FIXME KLUDGE ALERT glUniformMatrix4fv(uniforms[2], 1, GL_FALSE, &model_x->m[0][0]); + glUniform1f(uniforms[3], *gloom); } /* create plasma rendering stage */ -stage_t * plasma_node_new(const stage_conf_t *conf, m4f_t *projection_x) +stage_t * plasma_node_new(const stage_conf_t *conf, m4f_t *projection_x, float *gloom) { - return shader_node_new_src(conf, plasma_vs, plasma_fs, projection_x, plasma_uniforms, NULL, 3, + return shader_node_new_src(conf, plasma_vs, plasma_fs, projection_x, plasma_uniforms, gloom, 4, (const char *[]){ "alpha", "time", "projection_x", + "gloom", } ); } -- cgit v1.2.3