diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-12-12 20:01:25 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-12-12 20:01:25 -0800 |
commit | f79699d4c8b40e43847ec5f75993b5a39b598e53 (patch) | |
tree | fd1632ce31ad361965aece121eca1a10cf8b2336 | |
parent | e3085a3505bb30cf975804c519a3352bdc74d0dd (diff) |
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
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/plasma-node.c | 10 | ||||
-rw-r--r-- | src/plasma-node.h | 2 |
3 files changed, 9 insertions, 5 deletions
@@ -1140,7 +1140,7 @@ static void * game_init(play_t *play, int argc, char *argv[], unsigned flags) game->sars = sars; game->stage = sars->stage; - game->plasma_node = plasma_node_new(&(stage_conf_t){ .parent = sars->stage, .name = "plasma", .alpha = 1 }, &sars->projection_x); + game->plasma_node = plasma_node_new(&(stage_conf_t){ .parent = sars->stage, .name = "plasma", .alpha = 1 }, &sars->projection_x, &game->infections_rate_smoothed); game->ix2 = ix2_new(NULL, 4, 4, 2 /* support two simultaneous searches: tv_search->baby_search */); 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", } ); } diff --git a/src/plasma-node.h b/src/plasma-node.h index 2c52431..9f2dc47 100644 --- a/src/plasma-node.h +++ b/src/plasma-node.h @@ -21,6 +21,6 @@ typedef struct m4f_t m4f_t; typedef struct stage_t stage_t; typedef struct stage_conf_t stage_conf_t; -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); #endif |