POV-Ray : Newsgroups : povray.unofficial.patches : BSP tree bounding patch : Re: BSP tree bounding patch Server Time
3 Jul 2024 05:47:50 EDT (-0400)
  Re: BSP tree bounding patch  
From: Andrew Clinton
Date: 27 Nov 2003 22:15:02
Message: <web.3fc6bd866b3b1e2c611ee4e60@news.povray.org>
ABX wrote:
>On Thu, 27 Nov 2003 09:03:46 EST, "Andrew Clinton" <ajc### [at] uwaterlooca>
>wrote:
>> One exception is that there is a bug fix in TEST_RAY_FLAGS_SHADOW()
>
>Can you elaborate on this ? Your version is different that current
>development. Any reasons to follow you ? Minimal scene and settings to verify
>why you modified it that way ?
>
>TIA, ABX
>

OK.  The problem I was trying to solve can be observed when you render
"advanced/glasschess/glasschess.pov" with and then without the light buffer
turned on (-UL).  The number of shadow ray tests when this scene is
rendered without the light buffer is about 3x the number when it is
rendered with the light buffer.  This is not a side-effect of just not
using the light buffer, because the light buffer should not reduce the
total number of shadow ray tests at all as far as I know.

What I figured to be the problem was that objects in this scene marked with
"no_shadow" were still being tested against by shadow rays when the light
buffer is not used.  When the light buffer is used, this problem is not
noticed because the objects with "no_shadow" are not even put into the
light buffer when it is constructed.

My solution was to change the routine TEST_RAY_FLAGS_SHADOW from

--------

#define TEST_RAY_FLAGS_SHADOW(obj) \
(  (!backtraceFlag && \
(!Test_Flag((obj), NO_IMAGE_FLAG) || In_Reflection_Ray == true) && \
(!Test_Flag((obj), NO_REFLECTION_FLAG) || In_Reflection_Ray == false)) \
||(shadow_flag && !Test_Flag((obj), NO_SHADOW_FLAG)) \
|| (backtraceFlag && !Test_Flag((obj), NO_SHADOW_FLAG)) )

-------- to

#define TEST_RAY_FLAGS_SHADOW(obj) \
(  (!backtraceFlag && \
(!Test_Flag((obj), NO_IMAGE_FLAG) || In_Reflection_Ray == true) && \
(!Test_Flag((obj), NO_REFLECTION_FLAG) || In_Reflection_Ray == false) && \
(!shadow_flag || !Test_Flag((obj), NO_SHADOW_FLAG))) \
|| (backtraceFlag && (!Test_Flag((obj), NO_SHADOW_FLAG) ) ))

---------

This change makes sure that when we are in a shadow ray, and the object
being tested has "no_shadow", we will not test the object.  I also assume
that shadow_flag will never be set during backtrace (reasonable?)

I've just been testing this some more, and realise that this solution is
still not complete.  By fixing this, another bug seems to be exposed where
uninitialized memory is accessed by csg.cpp and isosurface.cpp.  Try
searching for "Optimisiation_Flags" and you will find that this member of
RAY is never initialized for non-shadow rays so its value could be
unpredictable.  This is causing rendering problems for glasschess.pov when
my fix to TEST_RAY_FLAGS_SHADOW is used.

I hope this helps!

Andrew


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.