User:Leesonw/BlenderFoundationWork/2021

July 5th - 9th
Worked on fixing the depth issues with PMJ sampling T79190. It appears the the samples used for each dimension are correlated. To help investigate these I added a number of different sampling methods Then to check the pixel hash was not causing issues I added 2 pixel hashes. Next I added Owen shuffling to add more variation to the sample set. So as to be able to experiment with these I add some extra items to the UI so as to be able to combine the various options. These changes can be found in D11869 Looked over upcoming patch for And discussion and ideas regarding
 * QMC Sobol with Xor scrambling
 * QMC Sobol with Owen scrambling
 * Animation De-noising D11442
 * Apple Metal support
 * Path Guiding

Aug 9th - 13th
Back from vacation and worked to catch up with how things have developed over the previous weeks. Worked on cleaning up the PMJ sampling patch and also removing any experimental code. The change increases the number of samples that can be drawn from the PMJ sample sets, so that it takes longer to fall back to random sampling which should improve the convergence. Also, selected to use the Tong hash on the pixels so as to avoid any clashes with the same hash being used for other purposes. The PMJ sampling now uses an Owen shuffle along the x and y axes to vary the 2D samples which should provide a good deal of variation between the sample sets used with each pixel and dimension. 1D samples are drawn from the both the x and y dimensions of the sample sets to make better use of the sets. Started integrating these changes into the cycles x branch and working on extending the PMJ sampler to produce a much larger number of samples.

Aug 16th - 20th

 * Worked on adding infinite sample count to existing PMJ method for master and cycles-x branches
 * Looked at the changes AMD have made in their Blender repo for HIP
 * Went over HIP documentation to get a better understanding of it
 * Attempted to setup up the HIP dev environment on my machine
 * Analysed some pending commits (in preparation for accepting more changes) to get a feel for what is expected
 * Analysed the changes in the cycles-x branch w.r.t. master branch

Aug 23rd - 27th

 * Analysed various methods of extending PMJ to an effectively infinite sample count using
 * 1) Owen shuffling
 * 2) XOR shuffling
 * 3) Cranley Pattersion Rotation (CPR)
 * Created patches for master and cycles-x branches for the above PMJ changes
 * Reduced the number sample patterns to use less memory than previous PMJ
 * Examined the AMD hip repo and commits
 * Reviewed some basic changes

Aug 30th - Sept 3rd

 * Further iterations on fixing the PMJ method working towards removing some of the noise by limiting the CPR displacement amounts to only be within the PMJ cells/intervals
 * Investigated using micro jittering with PMJ to speed up GPU and possibly CPU rendering. This seemed to work to speed up rendering with relatively minor changes to the new PMJ algorithm. However, the pixels are highly correlated which does not produce a good image with a low number of samples.
 * Looking into the Animation Denoising D11442 but need to wait on other changes before this can be finished.
 * Looked into a bug in the volumetric rendering that has been pointed out, but I don't have a solution yet.
 * Reviewed and committed some changes for viewport navigation resolution selection.

Sept 6th - Sept 10th

 * Started working on removing ray offsetting to remove artefacts when rendering instanced objects D6250.
 * Further examination of volumetric rendering bug seems related to the ray intersection code.
 * Reviewed some patches relating to cycles.
 * Looked into updating the PMJ sampler to use scrambling distance.

Sept 13th - Sept 17th

 * Continued working on removing ray offsetting to remove artefacts when rendering instanced objects D6250
 * 1) The black likes are largely fixed on the test scenes
 * 2) Still getting some issues with shadow rays due to lack of offsetting
 * Noticed crash bug when switching rendering devices and created a fix D12498 but it was not used in the end
 * Writing documentation for the sampling in Cycles in particular the new PMJ sampler mentioned above.
 * Analysed some bugs: T89353 T80267
 * Reviewed cycles related patches such as D12316 D12514 D12511

Sept 20th - Sept 24th

 * Further work on removing ray offsetting the Dynamic BVH is now working but the static BVH ids don't appear to be working
 * Fixed correlation issue with PMJ sampler D12610
 * Updated PMJ docs
 * Reviewed cycles diffs such as D12578 D12318
 * Further investigated Distance scrambling on PMJ w.r.t. the issues found in D12610 which necessitates a differnt approach.

Sept 27th - Oct 1st

 * Reviewed cycles diffs
 * 1) D12593 PMJ02 Sample generation was generating PMJ samples instead of PMJ02 samples. Also noticed that the cmj random number generator has issues with filling out the pmj02 table. Sometimes it never completes, switching to use drand48 help improve this but it still occurs. The float precision may make it hard to generate samples in small gaps. We may need to alter the PMJ02 sample generation to produce a more balanced tree. Below are some convergence results of pmj02 versus the other methods.
 * 1) D12403 Black areas around the edges of object due to invalid normals
 * 2) D127724 Code clean up
 * Continuing work on D6250
 * 1) Static BVH currently has different prim or object ids than the dynamic which makes solution only work in the dynamic case.
 * 2) For the static BVH the object id is always 0, the object id can be retrieved via __prim_object. However, the rest of cycles expects this to be OBJECT_NONE or weird shading happens. So added code to handle this within the scene intersection tests.
 * 3) Performance has dropped due to these changes, the code need to be refactored a bit to reduce the amount of tests and memory access.
 * 4) Working on fixing all static BVH scenes
 * 5) There is now a CUDA Error when rendering static scenes with both Optix and CUDA the glitch scene seems to have this
 * 6) Adjacent triangles seem to cause and issue which is probably caused by the triangle intersection routine including all edges in the intersection
 * 7) There are precision issues in enlarged scenes I believe caused by issues handling the distance along the ray that needs investigation

Oct 4th - Oct 8th

 * Trip to Blender HQ in Amsterdam to meet everyone and discuss working at Blender
 * Patches reviewed and submitted
 * 1) Submitted D12403
 * 2) Reviewed D12385
 * 3) Reviewed D12318
 * Continued working on D6250
 * 1) Optix has an issue with back facing surfaces
 * 2) Working on mesh related issues due to close proximity caused by triangle mesh edges. This appears to be because the distance values are compared in camera world space and not the object world space. This is most obvious at really small scales see below for 1e-5 scale.
 * 1) Setup AMD GPU on machine (trying a dual GPU setup with Nvidia and AMD GPUs)
 * 2) Investigated T92036 It seems the magic texture default input is producing NaNs on GPU but not on CPU causing blackness

Bug Fixes

 * Fix for Black volume when using Magic Texture T92036
 * Fix for assert when baking with debug build D12767
 * Found and helped fix (mostly Sergeys' work) D12853

Reviews

 * Reviewed E-Cycles speed-up D12318
 * Reviewed HIP Clean up D12834

Investigations

 * Analysed T92212
 * Analysed T91797
 * Analysed T91990
 * Analysed T92106
 * Analysed T92128
 * Analysed T92158

Work in progress
Added PMJ scrambling distance patch which applies the distance scrambling to the PMJ sampler which is based on Micro-Jittered sampling. This basically works by using the same sample set for each pixel so there is a lot a coherency between the pixels. This coherency results in a speed increase especially on GPUs. To counteract this there is a user controlled random displacement that can be applied to decorrelate the samples. The results proved to be quite good. The correlation is more obvious with lower samples and is also somewhat scene dependent. For instance the cobwebs in the barbershop really showed up the correlation even with high number of samples. Some scenes worked really well such as the junk shop below is a table of increasing sample counts for PMJ and PMJ with distance scrambling Continue working on removing ray offsetting
 * Reviewed some papers and books w.r.t. to ray tracing robustness
 * 1) Ray Tracing Gems I
 * 2) Ray Tracing Gems II
 * 3) Improving Ray Tracing Precision by Object Space Intersection Computation
 * Trying using double instead of float to preserve the distance along the ray
 * The Optix issue is now fixed :-) but I found another issue that seems to happen.

Reviews

 * Reviewed D12880 Cycles:bake transparent shadows for hair
 * Reviewed D12888 Cycles:replace integrator state argument macros
 * Reviewed D12889 Cycles: decouple shadow paths from main path on GPU

Work in Progress

 * Worked on fixing Optix issue managed to isolate it to a single triangle it seems the rays are getting shot from the wrong side of the surface but only on Optix. This was down to 2 reasons
 * 1) Optix __anyhit__ function was disabled in certain scenarios
 * 2) prim variable was not always filled out due to being inside a #ifdef that for some reason I did not notice :-(
 * 3) Almost there now got volume rendering working again :-)
 * 1) Working on improving the precision of intersections
 * 2) Performance results for the barbershop scene
 * 3) There are still some differences probably due to the curves in the scene as that does not correctly support no offsetting yet  :-)

Reviews

 * Reviewed Update UI for Scrambling Distance Settings D12963
 * Reviewed Separate Calculations for Adaptive Scrambling Distance for Viewport and Final Render D13017
 * Reviewed potential fix for Instancing in Cycles T91986

Work in progress

 * Worked on centring objects around the origin during BVH generation to improve floating point resolution helping small scenes appear less cracked
 * Updated https://developer.blender.org/D12318 so that is chooses a valid tile size
 * Submitted PMJ Scrambling Distance D12854

Nov 1st - Nov 5th

 * Vacation

Work in Progress

 * Analyse results from D13042 regarding performance decrease with CUDA when using Distance Scrambling.
 * Investigate T92601 performance issues with CPU rendering. I created 3 different patches (D13187, D13185, D13190) which gave some nice results.
 * Investigated issues with HIP devices when rendering to viewport and with a full render causing green images T92972.
 * Found bugs with latest master w.r.t. creating white/black pixel in the monster scene T92991.
 * Working on creating test for the Sobol and PMJ samplers with and without distance scrambling.

Reviews

 * Closed Volume rendering bug T90062 as it was already fixed
 * Add sample offset D13086
 * Huge memory spike when saving tile to disk D13186

Work in Progress

 * Looking into an issue with rendering a scene using Optix where it run out of memory T93089
 * Generated performance data for the automatic scrambling distance on HIP devices D13042
 * Looking into the while/black pixels T92991
 * Analysed patch to replace flattened vertex buffers with indexed one. This was supplied Feng Xie (Facebook) and could improve rendering performance x3.
 * Looks like another subsurface issue for T12954 causing the triangle mesh to appear and with simple cube some triangles are darker.

Work Done

 * Created patch to detect accelerated ray tracing support for D13042
 * Created fix for principled hair shader (and wave texture) D13262
 * Subsurface scattering had an issue with the ray offsetting removal D12954. This was due to missing the object and prim data for the subsurface ray.
 * Looking into volume rendering issue T91797 (Fixed by Brechts commit)
 * Monster scene has an artefact on the hand when using ray offsetting removal D12954

Reviews

 * Accepted "Adapt volumetric lambda functions to work on MSL" D13234

Work in Progress

 * Optimizing the performance of ray offsetting removal D12954

Work Done

 * Fixed: Cracks with SSS and offsetting removal T12954.
 * Found weird instancing issue when rendering the hair_instancing_uv scene from the tests when using offsetting removal. This turned out to be cause by the particle emitter generating particles at the same location which resulted in two object occupying the same position in space. Maybe particle emitters are not great for generating hair :-( NB: To fix this issue switch off random ordering :-)
 * Fixed: The first primitive in the first object seems to have issues with ray offset removal T12954.

Reviews

 * Analysed and committed D13042. The fix worked well for all currently supported platforms CPU, CUDA, HIP & Optix.

Work in Progress

 * Analysing the performance and optimising D12954


 * Trying to reduce the memory used by Rays in D12954 has caused Bevel and bake rendering to break. The idea was to store light and hit objects now in the isect structures instead of in the ray. This broke many things but most are working again. However, bevel and baking still have an issue.

Work Done

 * Still noticed some lighting issues in D12954. You would expect the lighting to be slightly different as the ray is not being offset. However, some details seem more different than that. In the Monster images below notice the lighting on the right side of the bed and on the right most eye of the monster. This was because light types were not behaving correctly and block each other.

Work in Progress

 * Working on improving the speed of ray offsetting D12954

Work Done

 * Bevel and bake rendering are broken in D12954.
 * Speed improvements for Optix in D12954.
 * Fixed precision issues with magic texture https://developer.blender.org/D12821

Reviews

 * Reviewed and committed D13042

Reviews

 * Reviewed D13325 and left some suggestions

Work Done

 * Enable generating the PMJ02 sample set instead of just the PMJ one https://developer.blender.org/D13557. This produces a better sample set resulting in better convergence.