Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/opencl/kernel/include/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool BlockPalette_intersectNormalizedBlock(BlockPalette self, image2d_array_t at
hit = AABB_full_intersect(box, tempRay, &tempRecord);
tempRecord.material = modelPointer;
} else if (ray.flags & RAY_INDIRECT) {
AABB box = AABB_new(0.125, 0.875, 0.125, 0.875, 0.125, 0.875);
AABB box = AABB_new(0.125f, 0.875f, 0.125f, 0.875f, 0.125f, 0.875f);
hit = AABB_full_intersect(box, tempRay, &tempRecord);
tempRecord.material = modelPointer;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/opencl/kernel/include/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Ray Camera_pinHole(float x, float y, Random random, __global const float* projec
float fovTan = projectorSettings[2];

ray.origin = (float3) (0, 0, 0);
ray.direction = (float3) (fovTan * x, fovTan * y, 1.0);
ray.direction = (float3) (fovTan * x, fovTan * y, 1.0f);

if (aperature > 0) {
ray.direction *= subjectDistance / ray.direction.z;

float r = sqrt(Random_nextFloat(random)) * aperature;
float theta = Random_nextFloat(random) * M_PI_F * 2.0;
float theta = Random_nextFloat(random) * M_PI_F * 2.0f;
float rx = cos(theta) * r;
float ry = sin(theta) * r;

Expand Down
14 changes: 7 additions & 7 deletions src/main/opencl/kernel/include/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ bool Material_sample(Material self, image2d_array_t atlas, float2 uv, MaterialSa

if (self.tint == 0xFE000000) {
// Light block
sample->color.xyz = 0.5;
sample->color.w = 1.0;
sample->color.xyz = 0.5f;
sample->color.w = 1.0f;
} else if (color.w > EPS) {
sample->color = color;
} else {
Expand Down Expand Up @@ -89,7 +89,7 @@ bool Material_sample(Material self, image2d_array_t atlas, float2 uv, MaterialSa
if (self.flags & 0b010)
sample->emittance = Atlas_read_uv(uv.x, uv.y, self.normal_emittance, self.textureSize, atlas).w;
else
sample->emittance = (self.normal_emittance & 0xFF) / 255.0;
sample->emittance = (self.normal_emittance & 0xFF) / 255.0f;

// specular, metalness, roughness
if (self.flags & 0b001) {
Expand All @@ -98,9 +98,9 @@ bool Material_sample(Material self, image2d_array_t atlas, float2 uv, MaterialSa
sample->metalness = smr.y;
sample->roughness = smr.z;
} else {
sample->specular = (self.specular_metalness_roughness & 0xFF) / 255.0;
sample->metalness = ((self.specular_metalness_roughness >> 8) & 0xFF) / 255.0;
sample->roughness = ((self.specular_metalness_roughness >> 16) & 0xFF) / 255.0;
sample->specular = (self.specular_metalness_roughness & 0xFF) / 255.0f;
sample->metalness = ((self.specular_metalness_roughness >> 8) & 0xFF) / 255.0f;
sample->roughness = ((self.specular_metalness_roughness >> 16) & 0xFF) / 255.0f;
}

return true;
Expand All @@ -121,7 +121,7 @@ float3 _Material_diffuseReflection(IntersectionRecord record, Random random) {
float ux, uy, uz;
float vx, vy, vz;

if (fabs(record.normal.x) > 0.1) {
if (fabs(record.normal.x) > 0.1f) {
xx = 0;
xy = 1;
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/main/opencl/kernel/include/rayTracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Ray ray_to_camera(
int cropX = canvasConfig[4];
int cropY = canvasConfig[5];

float halfWidth = fullWidth / (2.0 * fullHeight);
float invHeight = 1.0 / fullHeight;
float halfWidth = fullWidth / (2.0f * fullHeight);
float invHeight = 1.0f / fullHeight;
float x = -halfWidth + ((gid % width) + Random_nextFloat(random) + cropX) * invHeight;
float y = -0.5 + ((gid / width) + Random_nextFloat(random) + cropY) * invHeight;
float y = -0.5f + ((gid / width) + Random_nextFloat(random) + cropY) * invHeight;

switch (*projectorType) {
case 0:
Expand Down Expand Up @@ -107,8 +107,8 @@ __kernel void render(
ray.material = 0;
ray.flags = 0;

float3 color = (float3) (0.0);
float3 throughput = (float3) (1.0);
float3 color = (float3) (0.0f);
float3 throughput = (float3) (1.0f);

for (int depth = 0; depth < *rayDepth; depth++) {
IntersectionRecord record = IntersectionRecord_new();
Expand Down Expand Up @@ -203,7 +203,7 @@ __kernel void preview(

float3 color;
if (closestIntersect(scene, textureAtlas, ray, &record, &sample, &material)) {
float shading = dot(record.normal, (float3) (0.25, 0.866, 0.433));
float shading = dot(record.normal, (float3) (0.25f, 0.866f, 0.433f));
shading = fmax(0.3f, shading);
color = sample.color.xyz * shading;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/opencl/kernel/include/sky.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool Sun_intersect(Sun self, image2d_array_t atlas, Ray ray, MaterialSample* sam
return false;
}

float radius = 0.03;
float radius = 0.03f;

float width = radius * 4;
float width2 = width * 2;
Expand Down Expand Up @@ -112,7 +112,7 @@ void Sky_intersect(image2d_t skyTexture, float skyIntensity, Ray ray, MaterialSa
float phi = (asin(clamp(direction.y, -1.0f, 1.0f)) + M_PI_2_F) * M_1_PI_F;

sample->color = read_imagef(skyTexture, skySampler, (float2) (theta, phi)) * skyIntensity;
sample->emittance = 1.0;
sample->emittance = 1.0f;
}

#endif
8 changes: 4 additions & 4 deletions src/main/opencl/tonemap/include/post_processing_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ __kernel void filter(
switch (type) {
case 0:
// GAMMA
color = pow(color, 1.0 / 2.2);
color = pow(color, 1.0f / 2.2f);
break;
case 1:
// TONEMAP1
Expand All @@ -34,7 +34,7 @@ __kernel void filter(
// ACES
color = (color * (2.51f * color + 0.03f)) / (color * (2.43f * color + 0.59f) + 0.14f);
color = clamp(color, (float3)(0), (float3)(1));
color = pow(color, 1.0 / 2.2);
color = pow(color, 1.0f / 2.2f);
break;
case 3:
// HABLE
Expand All @@ -55,7 +55,7 @@ float ue4_filter_process_component(float c, float saturation, float slope, float
float logc = log10(c);

if (logc >= ta && logc <= sa) {
return saturation * (slope * (logc + 0.733) + 0.18);
return saturation * (slope * (logc + 0.733f) + 0.18f);
}
if (logc > sa) {
return saturation * (1 + whiteClip - (2 * (1 + whiteClip - shoulder)) / (1 + exp(((2 * slope) / (1 + whiteClip - shoulder)) * (logc - sa))));
Expand Down Expand Up @@ -95,7 +95,7 @@ __kernel void ue4_filter(
ue4_filter_process_component(color.z, saturation, slope, toe, shoulder, blackClip, whiteClip, ta, sa)
);
color = clamp(color, 0.0f, 1.0f);
color = pow(color, 1.0 / 2.0);
color = pow(color, 1.0f / 2.0f);

float4 pixel;
pixel.xyz = color;
Expand Down