diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-09-20 18:41:07 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-09-20 18:53:47 +0300 |
commit | 667add5fc5b743a324b508e3c5cedfde1df218c0 (patch) | |
tree | e3f3d9f7b4f46d0ce6e351959ba669f13382e650 /source/blender/gpu/shaders | |
parent | 5c20161f81c75a4139cb3c865955f53a9880f627 (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.glsl | 25 |
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) |