diff options
author | enricoturri1966 <enricoturri@seznam.cz> | 2020-05-29 13:29:04 +0300 |
---|---|---|
committer | enricoturri1966 <enricoturri@seznam.cz> | 2020-05-29 13:29:04 +0300 |
commit | dcec684cc7fe8979d25b726f6bdf560353139691 (patch) | |
tree | 0366134d5cc65d6136eea3b9bb92ff48bd91ee4e /resources | |
parent | e9d57c932acfac13e7be9eed3971426032ab5f44 (diff) |
ENABLE_GCODE_VIEWER -> Refactoring of shaders for options
Diffstat (limited to 'resources')
-rw-r--r-- | resources/shaders/options_110.fs | 2 | ||||
-rw-r--r-- | resources/shaders/options_110.vs | 8 | ||||
-rw-r--r-- | resources/shaders/options_120_flat.fs | 20 | ||||
-rw-r--r-- | resources/shaders/options_120_flat.vs | 8 | ||||
-rw-r--r-- | resources/shaders/options_120_solid.fs | 2 | ||||
-rw-r--r-- | resources/shaders/options_120_solid.vs | 8 |
6 files changed, 24 insertions, 24 deletions
diff --git a/resources/shaders/options_110.fs b/resources/shaders/options_110.fs index 3722058c8..474e355e0 100644 --- a/resources/shaders/options_110.fs +++ b/resources/shaders/options_110.fs @@ -1,4 +1,4 @@ -#version 120 +#version 110 uniform vec3 uniform_color; diff --git a/resources/shaders/options_110.vs b/resources/shaders/options_110.vs index 5361c88ce..7592f86a4 100644 --- a/resources/shaders/options_110.vs +++ b/resources/shaders/options_110.vs @@ -1,11 +1,11 @@ #version 110 uniform float zoom; -// x = min, y = max -uniform vec2 point_sizes; +uniform float point_size; +uniform float near_plane_height; void main() { - gl_PointSize = clamp(zoom, point_sizes.x, point_sizes.y); - gl_Position = ftransform(); + gl_Position = ftransform(); + gl_PointSize = (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w; } diff --git a/resources/shaders/options_120_flat.fs b/resources/shaders/options_120_flat.fs index 656eccd1d..e98e5693f 100644 --- a/resources/shaders/options_120_flat.fs +++ b/resources/shaders/options_120_flat.fs @@ -5,31 +5,31 @@ uniform vec3 uniform_color; uniform float percent_outline_radius; uniform float percent_center_radius; -vec4 hardcoded_color(float sq_radius) +vec4 hardcoded_color(float sq_radius, vec3 color) { if ((sq_radius < 0.005625) || (sq_radius > 0.180625)) - return vec4(0.5 * uniform_color, 1.0); + return vec4(0.5 * color, 1.0); else - return vec4(uniform_color, 1.0); + return vec4(color, 1.0); } -vec4 customizable_color(float sq_radius) +vec4 customizable_color(float sq_radius, vec3 color) { float in_radius = 0.5 * percent_center_radius; float out_radius = 0.5 * (1.0 - percent_outline_radius); if ((sq_radius < in_radius * in_radius) || (sq_radius > out_radius * out_radius)) - return vec4(0.5 * uniform_color, 1.0); + return vec4(0.5 * color, 1.0); else - return vec4(uniform_color, 1.0); + return vec4(color, 1.0); } void main() { - vec2 pos = gl_PointCoord - vec2(0.5, 0.5); + vec2 pos = gl_PointCoord - vec2(0.5); float sq_radius = dot(pos, pos); if (sq_radius > 0.25) discard; - - gl_FragColor = customizable_color(sq_radius); -// gl_FragColor = hardcoded_color(sq_radius); + + gl_FragColor = customizable_color(sq_radius, uniform_color); +// gl_FragColor = hardcoded_color(sq_radius, uniform_color); } diff --git a/resources/shaders/options_120_flat.vs b/resources/shaders/options_120_flat.vs index ebf7428c9..baf3cd3a7 100644 --- a/resources/shaders/options_120_flat.vs +++ b/resources/shaders/options_120_flat.vs @@ -1,11 +1,11 @@ #version 120 uniform float zoom; -// x = min, y = max -uniform vec2 point_sizes; +uniform float point_size; +uniform float near_plane_height; void main() { - gl_PointSize = clamp(zoom, point_sizes.x, point_sizes.y); - gl_Position = ftransform(); + gl_Position = ftransform(); + gl_PointSize = (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w; } diff --git a/resources/shaders/options_120_solid.fs b/resources/shaders/options_120_solid.fs index c7a57d547..18410b406 100644 --- a/resources/shaders/options_120_solid.fs +++ b/resources/shaders/options_120_solid.fs @@ -79,7 +79,7 @@ float fragment_depth(vec3 eye_pos) void main() { - vec2 pos = gl_PointCoord - vec2(0.5, 0.5); + vec2 pos = gl_PointCoord - vec2(0.5); float sq_radius = dot(pos, pos); if (sq_radius > 0.25) discard; diff --git a/resources/shaders/options_120_solid.vs b/resources/shaders/options_120_solid.vs index 0ad75003c..745ec8ddd 100644 --- a/resources/shaders/options_120_solid.vs +++ b/resources/shaders/options_120_solid.vs @@ -1,14 +1,14 @@ #version 120 uniform float zoom; -// x = min, y = max -uniform vec2 point_sizes; +uniform float point_size; +uniform float near_plane_height; varying vec3 eye_center; void main() { - gl_PointSize = clamp(zoom, point_sizes.x, point_sizes.y); eye_center = (gl_ModelViewMatrix * gl_Vertex).xyz; - gl_Position = ftransform(); + gl_Position = ftransform(); + gl_PointSize = (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w; } |