Skip to content

Commit

Permalink
Different approach, not truly ambient light (kind of "see-through sph…
Browse files Browse the repository at this point in the history
…ere"), avoids aliasing near the horizon.
  • Loading branch information
fidergo-stephane-gourichon committed Jan 10, 2021
1 parent 7722e05 commit 9a8e4c2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ function(trace ray_origin ray_dir depth color)

trace(new_origin new_dir ${depth} traced_col)

set(col ${light_color_ambient})
set(col 0 0 0)
light_contrib(hit_point_1 hit_normal_1 light1_pos light1_col out_col1)
light_contrib(hit_point_1 hit_normal_1 light2_pos light2_col out_col2)
vec3_add(col out_col1 col)
Expand All @@ -459,7 +459,7 @@ function(trace ray_origin ray_dir depth color)
vec3_mul(base_col col col)

elseif(${hit_t_2} GREATER ${ray_epsilon})
set(light_col ${light_color_ambient})
set(light_col 0 0 0)

list(GET hit_point_2 0 hit_p_x)
list(GET hit_point_2 2 hit_p_z)
Expand All @@ -470,11 +470,12 @@ function(trace ray_origin ray_dir depth color)
mul(${shadow_offset_z} ${shadow_offset_z} shadow_offset_z_2)
add(${shadow_offset_x_2} ${shadow_offset_z_2} hit_dist_2)

if(${hit_dist_2} GREATER_EQUAL ${shadow_radius2})
light_contrib(hit_point_2 hit_normal_2 light1_pos light1_col out_col1)
light_contrib(hit_point_2 hit_normal_2 light2_pos light2_col out_col2)
vec3_add(light_col out_col1 light_col)
vec3_add(light_col out_col2 light_col)
light_contrib(hit_point_2 hit_normal_2 light1_pos light1_col out_col1)
light_contrib(hit_point_2 hit_normal_2 light2_pos light2_col out_col2)
vec3_add(light_col out_col1 light_col)
vec3_add(light_col out_col2 light_col)
if(${hit_dist_2} LESS ${shadow_radius2})
vec3_mulf(light_col ${tenth} light_col)
endif()

# Calculate checkerboard pattern
Expand Down Expand Up @@ -509,14 +510,14 @@ endfunction()

to_fp(255.99 rgb_scaling)
to_fp(0.5 half)
to_fp(0.1 tenth)
to_fp(${image_width} image_width_fp)
to_fp(${image_height} image_height_fp)
to_fp(0.01 ray_epsilon)

to_fp(2 sphere_radius)
vec3_to_fp(0.0 0.0 3.0 sphere_center)
vec3_to_fp(0.3 0.3 0.3 sphere_color)
vec3_to_fp(0.05 0.05 0.05 light_color_ambient)

to_fp(3.0 shadow_center)
to_fp(4 shadow_radius2)
Expand Down

0 comments on commit 9a8e4c2

Please sign in to comment.