Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential index bug in shadow rendering #12

Open
TimSchneider42 opened this issue Apr 5, 2023 · 0 comments
Open

Potential index bug in shadow rendering #12

TimSchneider42 opened this issue Apr 5, 2023 · 0 comments

Comments

@TimSchneider42
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant