buildaworldnet / IrrlichtBAW

Build A World fork of Irrlicht
http://www.buildaworld.net
Apache License 2.0
122 stars 28 forks source link

InverseFunctionFilter #494

Closed AnastaZIuk closed 3 years ago

AnastaZIuk commented 4 years ago

Well, we will provide new filters. The goal is to handle Inclusive image scan and CDF. https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-20-gpu-based-importance-sampling How should the class interface look like for both of them? Will we create another ADTs? What about defaults? Do we have any assumptions if it comes to the implementation?

devshgraphicsprogramming commented 4 years ago

Yes new ADT.

you can start the CSummedAreaTableImageFilter by copying the interface of CCopyImageFilter, but it would be a good thing to have a template bool parameter Exclusive=false whether the sum is exclusive or inclusive (the value of the pixel is the sum of all pixels with x,y,z values < or <= than itself).

You'd need to add a few constraints to the validation:

For an efficient implementation, the state_type needs to have two more variables which is the scratch memory size and the scratch memory pointer (much like the blit image filter).

You need this scratch memory to use as a temporary double or uint64_t arrays (instead of allocating during execute), where you will first decode the entire image extent to be processed, and then after the decode you fill sweep through row, column and depth axes doing the partial sums ensuring the algorithm runs in O(n) and not something stupid like O(n^3).

CInverseFunctionFilter should follow more or less the same logic (it needs an extra state parameter whether to "normalize" the function, i.e. divide it by the maximum value for each channel) up until the decode, then we'll talk more about how to invert 3D functions.

AnastaZIuk commented 4 years ago

there are CMatchedSizeInOutImage and CBasicImageFilterCommon, but it seems to me I can't use it since for example CBasicImageFilterCommon iterates through blocks (it doesn't enter the single block, the lambda does it later), cuz I need another way of iterating and saving new pixel data twice - left and down pixels for each individual) to compute the sum and it isn't about just iterating through an array like it does, though there are some functions I could take such as region functor validation from there. It also concerns CMatchedSizeInOutImage since I need probably to put the allocation in something like it's CommonExecuteData, and also parameters in state_type, but it's fine in that case. CMatchedSizeInOutImageFilterCommon also doesn't cover all the validation you have written about.

devshgraphicsprogramming commented 4 years ago

See the Blit Filter on how to use temporary scratch memory.

Inherit from CMatchedSizeInOutImage add extra stuff just like every other filter does

AnastaZIuk commented 3 years ago

CSummedAreaTableImageFilter is done

devshgraphicsprogramming commented 3 years ago

moved to https://github.com/Devsh-Graphics-Programming/Nabla/issues/59