diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-09 20:20:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-09 21:06:27 +0300 |
commit | bfa1c077cb46af6450e014cd515ac6c51ee6c12a (patch) | |
tree | d30c8eafb3e5a07f605ce984e71c71a38b07dcf9 /source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl | |
parent | f4827d08bc9be71e7eb5b44a2de73044e5a45174 (diff) |
Fix T97983 EEVEE: Tangent Normal of Curves info behaves differently in Eevee
Curve tangent was correctly mistaken with curve normal.
This patch fixes the name of the output in the glsl function and make curve
attributes more explicit (with `curve_` prefix).
This also improve the normal computation by making it per pixel to match
cycles.
Also ports the changes to eevee-next.
Diffstat (limited to 'source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl index 0d8644c9901..30b48edaa78 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl @@ -42,6 +42,12 @@ void init_globals_curves() float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta)); g_data.N = normalize(interp.N * sin_theta + interp.curves_binormal * cos_theta); + /* Costly, but follows cycles per pixel tangent space (not following curve shape). */ + vec3 V = cameraVec(g_data.P); + g_data.curve_T = -interp.curves_tangent; + g_data.curve_B = cross(V, g_data.curve_T); + g_data.curve_N = safe_normalize(cross(g_data.curve_T, g_data.curve_B)); + g_data.is_strand = true; g_data.hair_time = interp.curves_time; g_data.hair_thickness = interp.curves_thickness; @@ -94,6 +100,7 @@ void init_interface() interp.P = vec3(0.0); interp.N = vec3(0.0); interp.barycentric_coords = vec2(0.0); + interp.curves_tangent = vec3(0.0); interp.curves_binormal = vec3(0.0); interp.curves_time = 0.0; interp.curves_time_width = 0.0; |