diff options
| author | Sam Nystrom <sam@samnystrom.dev> | 2024-02-14 14:05:17 +0000 |
|---|---|---|
| committer | Sam Nystrom <sam@samnystrom.dev> | 2024-02-14 16:49:19 -0500 |
| commit | 70b8aca498babc95b763df4a96f949b7b10214dc (patch) | |
| tree | 6a1daf6c936da08619fd8c57c9d8e6415e6f79e4 | |
| parent | 336b5505f09dcbc6115d125e7ffdb41da13cb32e (diff) | |
Uninvert lighting direction
| -rw-r--r-- | pineapple.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/pineapple.c b/pineapple.c index 5137534..eeb112b 100644 --- a/pineapple.c +++ b/pineapple.c @@ -165,17 +165,14 @@ main(int argc, char *argv[]) float brightness = 0.0; if (shortest != INFINITY) { float light_angle = acosf(dot(shortest_norm, light) / magnitude(shortest_norm) / magnitude(light)); - brightness = 1 - light_angle / PI; + brightness = light_angle / PI; } if (mode == ASCII) { printf("%c", ASCII_CHARS[strlen(ASCII_CHARS) - 1 - (int)(brightness * strlen(ASCII_CHARS))]); } else if (mode == FARBFELD) { uint16_t x = htobe16((uint16_t)(brightness * 0xffff)); - uint16_t a = htobe16(0xffff); - fwrite(&x, 1, 2, stdout); - fwrite(&x, 1, 2, stdout); - fwrite(&x, 1, 2, stdout); - fwrite(&a, 1, 2, stdout); + uint16_t pixel[4] = { x, x, x, htobe16(0xffff) }; + fwrite(&pixel, 2, 4, stdout); } } if (mode == ASCII) printf("\n"); |
