167 const glm::mat4& proj,
168 const glm::vec3& axis,
170 std::int32_t& in_out_min_x,
171 std::int32_t& in_out_max_x)
173 auto view_x = float(in_out_min_x);
174 auto view_size_x = float(in_out_max_x - in_out_min_x);
178 if(discriminant >= 0)
180 float sqrt_discriminant = glm::sqrt(discriminant);
181 float inv_light_square = 1.0f / (
square(light_x) +
square(light_z));
183 float Nxa = (radius * light_x - sqrt_discriminant) * inv_light_square;
184 float Nxb = (radius * light_x + sqrt_discriminant) * inv_light_square;
185 float Nza = (radius - Nxa * light_x) / light_z;
186 float Nzb = (radius - Nxb * light_x) / light_z;
187 float Pza = light_z - radius * Nza;
188 float Pzb = light_z - radius * Nzb;
193 float Pxa = -Pza * Nza / Nxa;
194 glm::vec4 P = proj * glm::vec4(axis.x * Pxa, axis.y * Pxa, Pza, 1);
195 float X = (glm::dot(glm::vec3(P), axis) / P.w + 1.0f * axis_sign) / 2.0f * axis_sign;
198 in_out_max_x = std::min<std::int32_t>(std::int32_t(glm::ceil(view_size_x * X + view_x)), in_out_max_x);
202 in_out_min_x = std::max<std::int32_t>(std::int32_t(glm::floor(view_size_x * X + view_x)), in_out_min_x);
209 float Pxb = -Pzb * Nzb / Nxb;
210 glm::vec4 P = proj * glm::vec4(axis.x * Pxb, axis.y * Pxb, Pzb, 1);
211 float X = (glm::dot(glm::vec3(P), axis) / P.w + 1.0f * axis_sign) / 2.0f * axis_sign;
214 in_out_max_x = std::min<std::int32_t>(std::int32_t(glm::ceil(view_size_x * X + view_x)), in_out_max_x);
218 in_out_min_x = std::max<std::int32_t>(std::int32_t(glm::floor(view_size_x * X + view_x)), in_out_min_x);
223 return in_out_min_x <= in_out_max_x;
230 std::int32_t& bottom,
231 const glm::vec3& sphere_center,
233 const glm::vec3& view_origin,
234 const glm::mat4&
view,
235 const glm::mat4& proj)
238 if(glm::length2(sphere_center - view_origin) >
square(radius))
240 glm::vec3 lv = glm::vec3(
view * glm::vec4(sphere_center, 1.0f));
288 float temporal_phase_scale = 1.0f)
291 temporal_phase_scale < 0.03f ? 0.03f : (temporal_phase_scale > 4.0f ? 4.0f : temporal_phase_scale);
292 constexpr float inv_phi = 0.61803398874989484820459f;
293 const float f =
static_cast<float>(
frame) * s;
294 float u = std::fmod(0.5f + f * inv_phi, 1.0f);
295 float v = std::fmod(0.5f + f * (inv_phi * inv_phi), 1.0f);
327 float temporal_phase_scale = 1.0f)
330 temporal_phase_scale < 0.03f ? 0.03f : (temporal_phase_scale > 4.0f ? 4.0f : temporal_phase_scale);
331 constexpr float a1 = 0.75487766624669276f;
332 constexpr float a2 = 0.56984029099805327f;
333 const float f =
static_cast<float>(
frame) * s;
334 float u = std::fmod(0.5f + f * a1, 1.0f);
335 float v = std::fmod(0.5f + f * a2, 1.0f);
std::uint32_t compute_projected_sphere_rect(std::int32_t &left, std::int32_t &right, std::int32_t &top, std::int32_t &bottom, const glm::vec3 &sphere_center, float radius, const glm::vec3 &view_origin, const glm::mat4 &view, const glm::mat4 &proj)
void taa_subpixel_offset_progressive(std::uint32_t frame, float &offset_x, float &offset_y, float temporal_phase_scale=1.0f)
2D subpixel jitter in [-0.5, 0.5] for temporal AA (Kronecker / golden-ratio sequence).
bool compute_projected_sphere_shaft(float light_x, float light_z, float radius, const glm::mat4 &proj, const glm::vec3 &axis, float axis_sign, std::int32_t &in_out_min_x, std::int32_t &in_out_max_x)
std::vector< math::vec3 > start