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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-09-20 18:41:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-09-20 18:53:47 +0300
commit667add5fc5b743a324b508e3c5cedfde1df218c0 (patch)
treee3f3d9f7b4f46d0ce6e351959ba669f13382e650 /source/blender/gpu/shaders
parent5c20161f81c75a4139cb3c865955f53a9880f627 (diff)
Eevee: Implement Wireframe Node
This implementation is a bit hacky but match cycles pretty close. If pixel size is not enabled, it will use the geom shader to compute distances between vertices. This will have a cost. Implementation is a bit hacky in gpu_codegen to make the geom shader works in an optional manner.
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl25
1 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 84e4165ac00..8fa1828bd9c 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -1,10 +1,10 @@
-uniform mat4 ModelMatrix;
uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewMatrixInverse;
uniform mat3 NormalMatrix;
#ifndef ATTRIB
+uniform mat4 ModelMatrix;
uniform mat4 ModelMatrixInverse;
#endif
@@ -1423,6 +1423,29 @@ void node_emission(vec4 color, float strength, vec3 vN, out Closure result)
#endif
}
+void node_wireframe(float size, vec2 barycentric, vec3 barycentric_dist, out float fac)
+{
+ vec3 barys = barycentric.xyy;
+ barys.z = 1.0 - barycentric.x - barycentric.y;
+
+ size *= 0.5;
+ vec3 s = step(-size, -barys * barycentric_dist);
+
+ fac = max(s.x, max(s.y, s.z));
+}
+
+void node_wireframe_screenspace(float size, vec2 barycentric, out float fac)
+{
+ vec3 barys = barycentric.xyy;
+ barys.z = 1.0 - barycentric.x - barycentric.y;
+
+ size *= (1.0 / 3.0);
+ vec3 deltas = fwidth(barys);
+ vec3 s = step(-deltas * size, -barys);
+
+ fac = max(s.x, max(s.y, s.z));
+}
+
/* background */
void background_transform_to_world(vec3 viewvec, out vec3 worldvec)