diff options
Diffstat (limited to 'advanced_opengl/10.antialiasing')
-rwxr-xr-x | advanced_opengl/10.antialiasing/anti_aliasing_msaa | bin | 1277808 -> 1277808 bytes | |||
-rw-r--r-- | advanced_opengl/10.antialiasing/anti_aliasing_msaa.c | 6 | ||||
-rwxr-xr-x | advanced_opengl/10.antialiasing/anti_aliasing_offscreen | bin | 1278840 -> 1278840 bytes | |||
-rw-r--r-- | advanced_opengl/10.antialiasing/anti_aliasing_offscreen.c | 6 | ||||
-rw-r--r-- | advanced_opengl/10.antialiasing/shaders/color.fs | 2 | ||||
-rw-r--r-- | advanced_opengl/10.antialiasing/shaders/screen.fs | 73 | ||||
-rw-r--r-- | advanced_opengl/10.antialiasing/shaders/screen.vs | 2 |
7 files changed, 43 insertions, 46 deletions
diff --git a/advanced_opengl/10.antialiasing/anti_aliasing_msaa b/advanced_opengl/10.antialiasing/anti_aliasing_msaa Binary files differindex d0afd7e..36811f7 100755 --- a/advanced_opengl/10.antialiasing/anti_aliasing_msaa +++ b/advanced_opengl/10.antialiasing/anti_aliasing_msaa diff --git a/advanced_opengl/10.antialiasing/anti_aliasing_msaa.c b/advanced_opengl/10.antialiasing/anti_aliasing_msaa.c index 9fcb645..65a5b01 100644 --- a/advanced_opengl/10.antialiasing/anti_aliasing_msaa.c +++ b/advanced_opengl/10.antialiasing/anti_aliasing_msaa.c @@ -169,9 +169,9 @@ main(void) if (key_is_pressed(global_input.exit)) glfwSetWindowShouldClose(window, GLFW_TRUE); - camera_pos = update_camera_orbital(global_input, - camera_pos, v3f_zero(), - dt, camera_speed); + V3F camera_dv = get_dv_camera_orbital(&global_input, camera_pos, + v3f_zero(), dt, camera_speed); + camera_pos = v3f_add(camera_pos, camera_dv); projection = perspective(fovx, (F32)global_width/(F32)global_height, near, far); view = look_at(camera_pos, v3f_zero(), v3f(0.0f, 1.0f, 0.0f)); diff --git a/advanced_opengl/10.antialiasing/anti_aliasing_offscreen b/advanced_opengl/10.antialiasing/anti_aliasing_offscreen Binary files differindex 72be7e2..c8a241c 100755 --- a/advanced_opengl/10.antialiasing/anti_aliasing_offscreen +++ b/advanced_opengl/10.antialiasing/anti_aliasing_offscreen diff --git a/advanced_opengl/10.antialiasing/anti_aliasing_offscreen.c b/advanced_opengl/10.antialiasing/anti_aliasing_offscreen.c index 91a26f9..5c6debb 100644 --- a/advanced_opengl/10.antialiasing/anti_aliasing_offscreen.c +++ b/advanced_opengl/10.antialiasing/anti_aliasing_offscreen.c @@ -218,9 +218,9 @@ main(void) if (key_is_pressed(global_input.exit)) glfwSetWindowShouldClose(window, GLFW_TRUE); - camera_pos = update_camera_orbital(global_input, - camera_pos, v3f_zero(), - dt, camera_speed); + V3F camera_dv = get_dv_camera_orbital(&global_input, camera_pos, + v3f_zero(), dt, camera_speed); + camera_pos = v3f_add(camera_pos, camera_dv); projection = perspective(fovx, (F32)WIDTH/(F32)HEIGHT, near, far); view = look_at(camera_pos, v3f_zero(), v3f(0.0f, 1.0f, 0.0f)); diff --git a/advanced_opengl/10.antialiasing/shaders/color.fs b/advanced_opengl/10.antialiasing/shaders/color.fs index b935555..542143e 100644 --- a/advanced_opengl/10.antialiasing/shaders/color.fs +++ b/advanced_opengl/10.antialiasing/shaders/color.fs @@ -5,5 +5,5 @@ out vec4 frag_color; void main(void) { - frag_color = vec4(0.76f, 0.47f, 0.84f, 1.0f); + frag_color = vec4(0.76, 0.47, 0.84, 1.0); } diff --git a/advanced_opengl/10.antialiasing/shaders/screen.fs b/advanced_opengl/10.antialiasing/shaders/screen.fs index 8fefa24..183d490 100644 --- a/advanced_opengl/10.antialiasing/shaders/screen.fs +++ b/advanced_opengl/10.antialiasing/shaders/screen.fs @@ -9,7 +9,7 @@ uniform sampler2D texture1; vec4 inversion() { - vec4 result = vec4(1.0f-vec3(texture(texture1, tex_coords)), 1.0f); + vec4 result = vec4(1.0-vec3(texture(texture1, tex_coords)), 1.0); return(result); } @@ -17,8 +17,8 @@ vec4 grayscale_average() { vec4 tex_color = texture(texture1, tex_coords); - float average = (tex_color.r+tex_color.g+tex_color.b)/3.0f; - vec4 result = vec4(average, average, average, 1.0f); + float average = (tex_color.r+tex_color.g+tex_color.b)/3.0; + vec4 result = vec4(average, average, average, 1.0); return(result); } @@ -26,25 +26,25 @@ vec4 grayscale_weights() { vec4 tex_color = texture(texture1, tex_coords); - float average = 0.2126*tex_color.r+0.7152*tex_color.g+0.0722f*tex_color.b; - vec4 result = vec4(average, average, average, 1.0f); + float average = 0.2126*tex_color.r+0.7152*tex_color.g+0.0722*tex_color.b; + vec4 result = vec4(average, average, average, 1.0); return(result); } -const float offset = 1.0f/300.0f; +const float offset = 1.0/300.0; vec4 kernel_effect(float[9] kernel) { vec2 offsets[9] = vec2[]( vec2(-offset, offset), /* top-left */ - vec2(0.0f, offset), /* top-center */ + vec2(0.0, offset), /* top-center */ vec2(offset, offset), /* top-right */ - vec2(-offset, 0.0f), /* center-left */ - vec2(0.0f, 0.0f), /* center-center */ - vec2(offset, 0.0f), /* center-right */ + vec2(-offset, 0.0), /* center-left */ + vec2(0.0, 0.0), /* center-center */ + vec2(offset, 0.0), /* center-right */ vec2(-offset, -offset), /* bottom-left */ - vec2(0.0f, -offset), /* bottom-center */ + vec2(0.0, -offset), /* bottom-center */ vec2(offset, -offset) /* bottom-right */ ); @@ -57,11 +57,11 @@ kernel_effect(float[9] kernel) vec3(texture(texture1, tex_coords+offsets[offset_index])); } - vec3 color = vec3(0.0f); + vec3 color = vec3(0.0); for (int i = 0; i < 9; ++i) color += sample_texture[i]*kernel[i]; - return(vec4(color, 1.0f)); + return(vec4(color, 1.0)); } void @@ -74,49 +74,46 @@ main(void) ); float gaussian_blur_kernel[9] = float[]( - 1.0f/16.0f, 2.0f/16.0f, 1.0f/16.0f, - 2.0f/16.0f, 4.0f/16.0f, 2.0f/16.0f, - 1.0f/16.0f, 2.0f/16.0f, 1.0f/16.0f + 1.0/16.0, 2.0/16.0, 1.0/16.0, + 2.0/16.0, 4.0/16.0, 2.0/16.0, + 1.0/16.0, 2.0/16.0, 1.0/16.0 ); float box_blur_kernel[9] = float[]( - 1.0f/9.0f, 1.0f/9.0f, 1.0f/9.0f, - 1.0f/9.0f, 1.0f/9.0f, 1.0f/9.0f, - 1.0f/9.0f, 1.0f/9.0f, 1.0f/9.0f + 1.0/9.0, 1.0/9.0, 1.0/9.0, + 1.0/9.0, 1.0/9.0, 1.0/9.0, + 1.0/9.0, 1.0/9.0, 1.0/9.0 ); float edge_detection_kernel[9] = float[]( - 1.0f, 1.0f, 1.0f, - 1.0f, -8.0f, 1.0f, - 1.0f, 1.0f, 1.0f + 1.0, 1.0, 1.0, + 1.0, -8.0, 1.0, + 1.0, 1.0, 1.0 ); float sharpening_kernel[9] = float[]( - 0.0f, -1.0f, 0.0f, - -1.0f, 5.0f, -1.0f, - 0.0f, -1.0f, 0.0f + 0.0, -1.0, 0.0, + -1.0, 5.0, -1.0, + 0.0, -1.0, 0.0 ); float sobel_kernel_vertical[9] = float[]( - -1.0f, 0.0f, 1.0f, - -2.0f, 0.0f, 2.0f, - -1.0f, 0.0f, 0.0f + -1.0, 0.0, 1.0, + -2.0, 0.0, 2.0, + -1.0, 0.0, 0.0 ); float sobel_kernel_horizontal[9] = float[]( - -1.0f, -2.0f, -1.0f, - 0.0f, 0.0f, 0.0f, - 1.0f, 2.0f, 1.0f + -1.0, -2.0, -1.0, + 0.0, 0.0, 0.0, + 1.0, 2.0, 1.0 ); float funny_kernel[9] = float[]( - 1.0f, 1.0f, 1.0f, - 1.0f, -4.0f, 1.0f, - 1.0f, 1.0f, 1.0f + 1.0, 1.0, 1.0, + 1.0, -4.0, 1.0, + 1.0, 1.0, 1.0 ); - /* frag_color = kernel_effect(funny_kernel); - frag_color *= vec4(0.76f, 0.47f, 0.84f, 1.0f); - */ - frag_color = grayscale_weights(); + frag_color *= vec4(0.76, 0.47, 0.84, 1.0); } diff --git a/advanced_opengl/10.antialiasing/shaders/screen.vs b/advanced_opengl/10.antialiasing/shaders/screen.vs index 0a5213b..1f233ee 100644 --- a/advanced_opengl/10.antialiasing/shaders/screen.vs +++ b/advanced_opengl/10.antialiasing/shaders/screen.vs @@ -7,6 +7,6 @@ out vec2 tex_coords; void main(void) { - gl_Position = vec4(apos, 1.0f); + gl_Position = vec4(apos, 1.0); tex_coords = atex_coords; } |