Skip to content

Potential index bug in shadow rendering #12

Description

@TimSchneider42

Hi,
I believe there is an indexing error in the shadow generation. The for loop in simOptical.py line 206 iterates variable s from 1 to num_step and retrieves values from the shadow_table at position s:

for s in range(1,num_step):
    cur_x = int(cx_origin + pr.shadow_step * s * ct)
    cur_y = int(cy_origin + pr.shadow_step * s * st)
    # check boundary of the image and height's difference
    if cur_x >= 0 and cur_x < psp.w and cur_y >= 0 and cur_y < psp.h and heightMap[cy_origin,cx_origin] > heightMap[cur_y,cur_x]:
        frame[cur_y,cur_x] = np.minimum(frame[cur_y,cur_x],v[s])

However, this means that v[0] is never used. Looking at generateShadowMasks.py, it seems to me as if for s = 1, v[0] should be retrieved instead of v[1]. Hence, I think this code should be:

for s in range(num_step):
    cur_x = int(cx_origin + pr.shadow_step * (s + 1) * ct)
    cur_y = int(cy_origin + pr.shadow_step * (s + 1) * st)
    # check boundary of the image and height's difference
    if cur_x >= 0 and cur_x < psp.w and cur_y >= 0 and cur_y < psp.h and heightMap[cy_origin,cx_origin] > heightMap[cur_y,cur_x]:
        frame[cur_y,cur_x] = np.minimum(frame[cur_y,cur_x],v[s])

Best,
Tim

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions