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
4 changes: 2 additions & 2 deletions source/chapter7/graphics/render_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,7 @@ void RenderScene::upload_gpu_data( UploadGpuDataContext& context ) {
for ( u32 i = 0; i < k_num_lights; ++i ) {
const SortedLight& light = sorted_lights[ i ];

if ( ( light.projected_z >= bin_min && light.projected_z <= bin_max ) ||
if ( ( light.projected_z_min <= bin_min && light.projected_z_max >= bin_max ) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is correct, as this would include lights that have their min/max depth bounds outside the bin bounds. It could well be that this line is not needed though and that we just need to check the min/max z against the bin bounds. I haven't run the code yet, I'll verify more thoroughly later.

( light.projected_z_min >= bin_min && light.projected_z_min <= bin_max ) ||
( light.projected_z_max >= bin_min && light.projected_z_max <= bin_max ) ) {
if ( i < min_light_id ) {
Expand Down Expand Up @@ -2352,7 +2352,7 @@ void RenderScene::upload_gpu_data( UploadGpuDataContext& context ) {

for ( u32 y = first_tile_y; y <= last_tile_y; ++y ) {
for ( u32 x = first_tile_x; x <= last_tile_x; ++x ) {
u32 array_index = y * tile_stride + x;
u32 array_index = y * tile_stride + x * k_num_words;

u32 word_index = i / 32;
u32 bit_index = i % 32;
Expand Down
2 changes: 1 addition & 1 deletion source/chapter7/shaders/lighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ vec4 calculate_lighting(vec4 base_colour, vec3 orm, vec3 normal, vec3 emissive,
uvec2 tile = position / uint( TILE_SIZE );

uint stride = uint( NUM_WORDS ) * ( uint( resolution.x ) / uint( TILE_SIZE ) );
uint address = tile.y * stride + tile.x;
uint address = tile.y * stride + tile.x * uint( NUM_WORDS );

#if ENABLE_OPTIMIZATION
// NOTE(marco): this version has been implemented following:
Expand Down