From e33562e6019c4eb5162974bafc9d491b61e966bf Mon Sep 17 00:00:00 2001 From: 101001000 Date: Mon, 4 Sep 2023 00:55:18 +0200 Subject: [PATCH] look, i don't care if I do thousand commits for fixing the double to float thing --- src/Sampling.h | 16 ++++++++-------- src/kernel.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Sampling.h b/src/Sampling.h index d55cf64..adf2f4f 100644 --- a/src/Sampling.h +++ b/src/Sampling.h @@ -8,9 +8,9 @@ inline Vector3 uniformSampleSphere(float u1, float u2) { - float z = 1.0 - 2.0 * u1; - float r = sycl::sqrt(maxf(0.f, 1.0 - z * z)); - float phi = 2.0 * PIF * u2; + float z = 1.0f - 2.0f * u1; + float r = sycl::sqrt(maxf(0.f, 1.0f - z * z)); + float phi = 2.0f * PIF * u2; float x = r * sycl::cos(phi); float y = r * sycl::sin(phi); @@ -31,21 +31,21 @@ inline Vector3 CosineSampleHemisphere(float u1, float u2){ Vector3 dir; float r = sycl::sqrt(u1); - float phi = 2.0 * PIF * u2; + float phi = 2.0f * PIF * u2; dir.x = r * sycl::cos(phi); dir.y = r * sycl::sin(phi); - dir.z = sycl::sqrt(maxf(0.0, 1.0 - dir.x * dir.x - dir.y * dir.y)); + dir.z = sycl::sqrt(maxf(0.0f, 1.0f - dir.x * dir.x - dir.y * dir.y)); return dir; } inline Vector3 ImportanceSampleGGX(float rgh, float r1, float r2) { - float a = maxf(0.001, rgh); + float a = maxf(0.001f, rgh); float phi = r1 * PIF * 2; - float cosTheta = sycl::sqrt((1.0 - r2) / (1.0 + (a * a - 1.0) * r2)); - float sinTheta = clamp(sycl::sqrt(1.0 - (cosTheta * cosTheta)), 0.0, 1.0); + float cosTheta = sycl::sqrt((1.0f - r2) / (1.0f + (a * a - 1.0f) * r2)); + float sinTheta = clamp(sycl::sqrt(1.0f - (cosTheta * cosTheta)), 0.0f, 1.0f); float sinPhi = sycl::sin(phi); float cosPhi = sycl::cos(phi); diff --git a/src/kernel.cpp b/src/kernel.cpp index bb52035..750aff6 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -381,8 +381,8 @@ void calculateCameraRay(int x, int y, dev_Scene& scene, Camera& camera, Ray& ray float ody = (-camera.sensorHeight / 2.0f) + dy; // Random part of the sampling offset so we get antialasing - float rx = (1.0 / static_cast(scene.x_res)) * (r1 - 0.5f) * camera.sensorWidth; - float ry = (1.0 / static_cast(scene.y_res)) * (r2 - 0.5f) * camera.sensorHeight; + float rx = (1.0f / static_cast(scene.x_res)) * (r1 - 0.5f) * camera.sensorWidth; + float ry = (1.0f / static_cast(scene.y_res)) * (r2 - 0.5f) * camera.sensorHeight; // Sensor point, the point where intersects the ray with the sensor float SPx = odx + rx;