NVIDIAGameWorks / RTXGI-DDGI

RTX Global Illumination (RTXGI)
https://developer.nvidia.com/rtxgi
Other
683 stars 55 forks source link

DDGIResetScrolledPlane #62

Closed jirzynek closed 2 years ago

jirzynek commented 2 years ago

Hi,

I have been experimenting with the scrolling volumes and I have noticed strange behaviour, I'm not sure if this is intended.

I have included some animations showing the problem.

Scrolling the probes to the right: bl0 Scrolling the probes to the left: bad_left

This animation was created with the following:

Also, if the probes are scrolled too quickly, scrolling code on cpu side can go wrong and miss a few probes quick_scroll

Normally I would expect something like this (with my local fix): Scrolling the probes to the right: ok_right

Scrolling the probes to the left: ok_left

Python code showing the problem and the fix:

probe_count = 6

def f(offset):
    # DDGI calculations (DDGIResetScrolledPlane)
    if offset > 0:
        v = math.fmod(offset, probe_count) - 1
    else:
        v = math.fmod(offset, probe_count) + probe_count

    # modulo
    w = (offset - 1) % probe_count

    # fix
    y = offset - 1
    z2 = math.fmod(math.fmod(y, probe_count) + probe_count, probe_count)

    return (offset, w, v, z2)

for i in range(-10, 10):
    res = f(i)
    print(f'"offset={res[0]:4}, mod={res[1]} ddgi={res[2]:4} fix={res[3]}')

And the output

"offset= -10, mod=1 ddgi= 2.0 fix=1.0
"offset=  -9, mod=2 ddgi= 3.0 fix=2.0
"offset=  -8, mod=3 ddgi= 4.0 fix=3.0
"offset=  -7, mod=4 ddgi= 5.0 fix=4.0
"offset=  -6, mod=5 ddgi= 6.0 fix=5.0
"offset=  -5, mod=0 ddgi= 1.0 fix=0.0
"offset=  -4, mod=1 ddgi= 2.0 fix=1.0
"offset=  -3, mod=2 ddgi= 3.0 fix=2.0
"offset=  -2, mod=3 ddgi= 4.0 fix=3.0
"offset=  -1, mod=4 ddgi= 5.0 fix=4.0
"offset=   0, mod=5 ddgi= 6.0 fix=5.0
"offset=   1, mod=0 ddgi= 0.0 fix=0.0
"offset=   2, mod=1 ddgi= 1.0 fix=1.0
"offset=   3, mod=2 ddgi= 2.0 fix=2.0
"offset=   4, mod=3 ddgi= 3.0 fix=3.0
"offset=   5, mod=4 ddgi= 4.0 fix=4.0
"offset=   6, mod=5 ddgi=-1.0 fix=5.0
"offset=   7, mod=0 ddgi= 0.0 fix=0.0
"offset=   8, mod=1 ddgi= 1.0 fix=1.0
"offset=   9, mod=2 ddgi= 2.0 fix=2.0

As you can see, the code that is currently in the SDK doesn't wrap correctly in some situations. e.g.

"offset=  -6, mod=5 ddgi= 6.0 fix=5.0
"offset=   0, mod=5 ddgi= 6.0 fix=5.0
"offset=   6, mod=5 ddgi=-1.0 fix=5.0

L

acmarrs-nvidia commented 2 years ago

Hi @jirzynek - thanks very much for letting us know about this problem and taking the time to clearly explain the issue (with animations!). The latest release includes changes to fix the problem. This should be resolved, but if you have any issues still, feel free to reopen this issue and let us know what's going on.