Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenricoturri1966 <enricoturri@seznam.cz>2020-05-28 16:27:29 +0300
committerenricoturri1966 <enricoturri@seznam.cz>2020-05-28 16:27:29 +0300
commitc63e03c3674279c86b92bb648fac26f34a0e146e (patch)
tree91cdd88a1c52a012d7f5c34035064e4112b41b07 /resources
parent4b6bcd702871feec2f938092cb5f2bdd96fcdcdc (diff)
1st installment of tech ENABLE_ENVIRONMENT_MAP
Diffstat (limited to 'resources')
-rw-r--r--resources/icons/Pmetal_001.pngbin0 -> 80450 bytes
-rw-r--r--resources/shaders/gouraud.fs9
-rw-r--r--resources/shaders/gouraud.vs9
3 files changed, 13 insertions, 5 deletions
diff --git a/resources/icons/Pmetal_001.png b/resources/icons/Pmetal_001.png
new file mode 100644
index 000000000..c848f839c
--- /dev/null
+++ b/resources/icons/Pmetal_001.png
Binary files differ
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)