feat: started athmospheare post processing
This commit is contained in:
30
src/athmosphere.h
Normal file
30
src/athmosphere.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef ATHMOSPHERE_H
|
||||||
|
#define ATHMOSPHERE_H
|
||||||
|
|
||||||
|
#include "linmath.h"
|
||||||
|
#include "rendertarget.h"
|
||||||
|
void renderAthmosphere(render_target *target, const mat4x4 invProj) {
|
||||||
|
|
||||||
|
float widthF = 2. / target->width;
|
||||||
|
float heightF = 2. / target->height;
|
||||||
|
|
||||||
|
for (int y = 0; y < target->height; y++) {
|
||||||
|
for (int x = 0; x < target->width; x++) {
|
||||||
|
vec4 tmp = {((float)x) * widthF - 1.f, ((float)y) * heightF - 1.0f,
|
||||||
|
((float)target_get_depth(target, x, y)) / 65536.0f, 1.0f};
|
||||||
|
// vec4_scale(tmp, tmp, 1.0f / tmp[2]);
|
||||||
|
|
||||||
|
vec4 pos;
|
||||||
|
mat4x4_mul_vec4(pos, invProj, tmp);
|
||||||
|
vec4_scale(pos, pos, 1.0f / pos[3]);
|
||||||
|
// pos[2] = -pos[2];
|
||||||
|
vec4_scale(pos, pos, -.1f);
|
||||||
|
// vec4_scale(tmp, tmp, -1.f);
|
||||||
|
// tmp[3] = -tmp[2];
|
||||||
|
vec3_set(pos, pos[2]);
|
||||||
|
target_set_color(target, x, y, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
11
src/main.c
11
src/main.c
@@ -164,6 +164,17 @@ int main(void) {
|
|||||||
render(&target, &rocket.model, &drawMat, buffer);
|
render(&target, &rocket.model, &drawMat, buffer);
|
||||||
renderC = clock() - renderC;
|
renderC = clock() - renderC;
|
||||||
|
|
||||||
|
mat4x4 invProj;
|
||||||
|
mat4x4_invert(invProj, rData.projMat);
|
||||||
|
|
||||||
|
athmosC = clock();
|
||||||
|
// renderAthmosphere(&target, invProj);
|
||||||
|
athmosC = clock() - athmosC;
|
||||||
|
|
||||||
|
if (didHit(rocket)) {
|
||||||
|
stop = 1;
|
||||||
|
}
|
||||||
|
|
||||||
base64encode(&target, encodeBuff);
|
base64encode(&target, encodeBuff);
|
||||||
printf("\033[H");
|
printf("\033[H");
|
||||||
printImage(encodeBuff);
|
printImage(encodeBuff);
|
||||||
|
|||||||
Reference in New Issue
Block a user