From 593be43b58d0bff63340eb33cd23b36fa6767512 Mon Sep 17 00:00:00 2001 From: Anton Baskanov Date: Wed, 10 Nov 2021 01:42:34 +0700 Subject: [PATCH] Pass world positions to computeAnisotropicEllipseAxes(). Fixes #197. --- ref_vk/shaders/ray.rchit | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ref_vk/shaders/ray.rchit b/ref_vk/shaders/ray.rchit index 5ca89469..8628d990 100644 --- a/ref_vk/shaders/ray.rchit +++ b/ref_vk/shaders/ray.rchit @@ -87,19 +87,19 @@ void main() { }; const vec3 pos[3] = { - vertices[vi1].pos, - vertices[vi2].pos, - vertices[vi3].pos, + gl_ObjectToWorldEXT * vec4(vertices[vi1].pos, 1.), + gl_ObjectToWorldEXT * vec4(vertices[vi2].pos, 1.), + gl_ObjectToWorldEXT * vec4(vertices[vi3].pos, 1.), }; const vec2 texture_uv = vertices[vi1].gl_tc * (1. - bary.x - bary.y) + vertices[vi2].gl_tc * bary.x + vertices[vi3].gl_tc * bary.y + push_constants.time * kusochki[kusok_index].uv_speed; const uint tex_index = kusochki[kusok_index].texture; - const vec3 real_geom_normal = normalize(normalTransformMat * cross(pos[2]-pos[0], pos[1]-pos[0])); + const vec3 real_geom_normal = normalize(cross(pos[2]-pos[0], pos[1]-pos[0])); const float geom_normal_sign = sign(dot(real_geom_normal, -gl_WorldRayDirectionEXT)); const vec3 geom_normal = geom_normal_sign * real_geom_normal; // This one is supposed to be numerically better, but I can't see why - const vec3 hit_pos = (gl_ObjectToWorldEXT * vec4(pos[0] * (1. - bary.x - bary.y) + pos[1] * bary.x + pos[2] * bary.y, 1.)).xyz + geom_normal * normal_offset_fudge; + const vec3 hit_pos = pos[0] * (1. - bary.x - bary.y) + pos[1] * bary.x + pos[2] * bary.y + geom_normal * normal_offset_fudge; //const vec3 hit_pos = gl_WorldRayOriginEXT + gl_WorldRayDirectionEXT * gl_HitTEXT + geom_normal * normal_offset_fudge; const float ray_cone_width = payload.pixel_cone_spread_angle * payload.t_offset;