diff options
author | enricoturri1966 <enricoturri@seznam.cz> | 2020-05-28 16:50:21 +0300 |
---|---|---|
committer | enricoturri1966 <enricoturri@seznam.cz> | 2020-05-28 16:50:21 +0300 |
commit | e9d57c932acfac13e7be9eed3971426032ab5f44 (patch) | |
tree | 8c8060bcc01b6feee6142a7839b0642f52f213ed /resources | |
parent | 96db6aaadb936c324f2f07369937a6fac8f8fc11 (diff) | |
parent | 0599dc4df7c8ea2973c8092ef75eb0ad72625258 (diff) |
Fixed conflicts after merge with master
Diffstat (limited to 'resources')
-rw-r--r-- | resources/icons/Pmetal_001.png | bin | 0 -> 80450 bytes | |||
-rw-r--r-- | resources/shaders/gouraud.fs | 9 | ||||
-rw-r--r-- | resources/shaders/gouraud.vs | 9 |
3 files changed, 13 insertions, 5 deletions
diff --git a/resources/icons/Pmetal_001.png b/resources/icons/Pmetal_001.png Binary files differnew file mode 100644 index 000000000..c848f839c --- /dev/null +++ b/resources/icons/Pmetal_001.png diff --git a/resources/shaders/gouraud.fs b/resources/shaders/gouraud.fs index 853a5512c..45175acc2 100644 --- a/resources/shaders/gouraud.fs +++ b/resources/shaders/gouraud.fs @@ -17,6 +17,9 @@ struct SlopeDetection uniform vec4 uniform_color; uniform SlopeDetection slope; +uniform sampler2D environment_tex; +uniform bool use_environment_tex; + varying vec3 clipping_planes_dots; // x = tainted, y = specular; @@ -26,6 +29,7 @@ varying vec3 delta_box_min; varying vec3 delta_box_max; varying float world_normal_z; +varying vec3 eye_normal; vec3 slope_color() { @@ -40,5 +44,8 @@ void main() vec3 color = slope.actived ? slope_color() : uniform_color.rgb; // if the fragment is outside the print volume -> use darker color color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(color, ZERO, 0.3333) : color; - gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a); + if (use_environment_tex) + gl_FragColor = vec4(0.45 * texture2D(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, uniform_color.a); + else + gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, uniform_color.a); } diff --git a/resources/shaders/gouraud.vs b/resources/shaders/gouraud.vs index 2644d48e4..d60f6eae8 100644 --- a/resources/shaders/gouraud.vs +++ b/resources/shaders/gouraud.vs @@ -51,22 +51,23 @@ varying vec3 delta_box_max; varying vec3 clipping_planes_dots; varying float world_normal_z; +varying vec3 eye_normal; void main() { // First transform the normal into camera space and normalize the result. - vec3 normal = normalize(gl_NormalMatrix * gl_Normal); + eye_normal = normalize(gl_NormalMatrix * gl_Normal); // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. - float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); + float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0); intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; - intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); + intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS); // Perform the same lighting calculation for the 2nd light source (no specular applied). - NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); + NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0); intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; // compute deltas for out of print volume detection (world coordinates) |