mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
'properly' disable noise effect scaling
This commit is contained in:
parent
36bdb54d5e
commit
aa5dfaa7c2
2 changed files with 9 additions and 16 deletions
|
@ -1307,9 +1307,9 @@ static void gfx_d3d11_start_frame(void) {
|
||||||
// No high values, as noise starts to look ugly
|
// No high values, as noise starts to look ugly
|
||||||
d3d.per_frame_cb_data.noise_frame = 0;
|
d3d.per_frame_cb_data.noise_frame = 0;
|
||||||
}
|
}
|
||||||
float aspect_ratio = (float) d3d.current_width / (float) d3d.current_height;
|
|
||||||
d3d.per_frame_cb_data.noise_scale_x = 120 * aspect_ratio; // 120 = N64 height resolution (240) / 2
|
d3d.per_frame_cb_data.noise_scale_x = (float) d3d.current_width;
|
||||||
d3d.per_frame_cb_data.noise_scale_y = 120;
|
d3d.per_frame_cb_data.noise_scale_y = (float) d3d.current_height;
|
||||||
|
|
||||||
D3D11_MAPPED_SUBRESOURCE ms;
|
D3D11_MAPPED_SUBRESOURCE ms;
|
||||||
ZeroMemory(&ms, sizeof(D3D11_MAPPED_SUBRESOURCE));
|
ZeroMemory(&ms, sizeof(D3D11_MAPPED_SUBRESOURCE));
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct ShaderProgram {
|
||||||
bool used_textures[2];
|
bool used_textures[2];
|
||||||
uint8_t num_floats;
|
uint8_t num_floats;
|
||||||
GLint attrib_locations[7];
|
GLint attrib_locations[7];
|
||||||
GLint uniform_locations[6];
|
GLint uniform_locations[5];
|
||||||
uint8_t attrib_sizes[7];
|
uint8_t attrib_sizes[7];
|
||||||
uint8_t num_attribs;
|
uint8_t num_attribs;
|
||||||
bool used_noise;
|
bool used_noise;
|
||||||
|
@ -67,7 +67,6 @@ static struct GLTexture *opengl_tex[2];
|
||||||
static int opengl_curtex = 0;
|
static int opengl_curtex = 0;
|
||||||
|
|
||||||
static uint32_t frame_count;
|
static uint32_t frame_count;
|
||||||
static uint32_t current_height;
|
|
||||||
|
|
||||||
static bool gfx_opengl_z_is_from_0_to_1(void) {
|
static bool gfx_opengl_z_is_from_0_to_1(void) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -85,10 +84,8 @@ static void gfx_opengl_vertex_array_set_attribs(struct ShaderProgram *prg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfx_opengl_set_shader_uniforms(struct ShaderProgram *prg) {
|
static inline void gfx_opengl_set_shader_uniforms(struct ShaderProgram *prg) {
|
||||||
if (prg->used_noise) {
|
if (prg->used_noise)
|
||||||
glUniform1i(prg->uniform_locations[4], frame_count);
|
glUniform1f(prg->uniform_locations[4], (float)frame_count);
|
||||||
glUniform1i(prg->uniform_locations[5], current_height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfx_opengl_set_texture_uniforms(struct ShaderProgram *prg, const int tile) {
|
static inline void gfx_opengl_set_texture_uniforms(struct ShaderProgram *prg, const int tile) {
|
||||||
|
@ -332,8 +329,7 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(uint32_t shad
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_alpha && opt_noise) {
|
if (opt_alpha && opt_noise) {
|
||||||
append_line(fs_buf, &fs_len, "uniform int frame_count;");
|
append_line(fs_buf, &fs_len, "uniform float frame_count;");
|
||||||
append_line(fs_buf, &fs_len, "uniform int window_height;");
|
|
||||||
|
|
||||||
append_line(fs_buf, &fs_len, "float random(in vec3 value) {");
|
append_line(fs_buf, &fs_len, "float random(in vec3 value) {");
|
||||||
append_line(fs_buf, &fs_len, " float random = dot(sin(value), vec3(12.9898, 78.233, 37.719));");
|
append_line(fs_buf, &fs_len, " float random = dot(sin(value), vec3(12.9898, 78.233, 37.719));");
|
||||||
|
@ -374,9 +370,8 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(uint32_t shad
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_alpha && opt_noise) {
|
if (opt_alpha && opt_noise)
|
||||||
append_line(fs_buf, &fs_len, "texel.a *= floor(random(vec3(floor(gl_FragCoord.xy * float(window_height)), float(frame_count))) + 0.5);");
|
append_line(fs_buf, &fs_len, "texel.a *= floor(random(floor(vec3(gl_FragCoord.xy, frame_count))) + 0.5);");
|
||||||
}
|
|
||||||
|
|
||||||
if (opt_alpha) {
|
if (opt_alpha) {
|
||||||
append_line(fs_buf, &fs_len, "gl_FragColor = texel;");
|
append_line(fs_buf, &fs_len, "gl_FragColor = texel;");
|
||||||
|
@ -483,7 +478,6 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(uint32_t shad
|
||||||
|
|
||||||
if (opt_alpha && opt_noise) {
|
if (opt_alpha && opt_noise) {
|
||||||
prg->uniform_locations[4] = glGetUniformLocation(shader_program, "frame_count");
|
prg->uniform_locations[4] = glGetUniformLocation(shader_program, "frame_count");
|
||||||
prg->uniform_locations[5] = glGetUniformLocation(shader_program, "window_height");
|
|
||||||
prg->used_noise = true;
|
prg->used_noise = true;
|
||||||
} else {
|
} else {
|
||||||
prg->used_noise = false;
|
prg->used_noise = false;
|
||||||
|
@ -579,7 +573,6 @@ static void gfx_opengl_set_zmode_decal(bool zmode_decal) {
|
||||||
|
|
||||||
static void gfx_opengl_set_viewport(int x, int y, int width, int height) {
|
static void gfx_opengl_set_viewport(int x, int y, int width, int height) {
|
||||||
glViewport(x, y, width, height);
|
glViewport(x, y, width, height);
|
||||||
current_height = height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_opengl_set_scissor(int x, int y, int width, int height) {
|
static void gfx_opengl_set_scissor(int x, int y, int width, int height) {
|
||||||
|
|
Loading…
Reference in a new issue