You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been reading the source code of this repo recently and have some questions about the function used to generate probePixelAreaLookup data. What is the internal basis of the generatePixelAreaLookup function?
exportfunctiongeneratePixelAreaLookup(probeTargetSize: number){constprobePixelCount=probeTargetSize*probeTargetSize;constlookup=newArray(probePixelCount)asnumber[];constprobePixelBias=0.5/probeTargetSize;for(letpy=0;py<probeTargetSize;py+=1){// compute offset from center (with a bias for target pixel size)constdy=py/probeTargetSize-0.5+probePixelBias;for(letpx=0;px<probeTargetSize;px+=1){// compute offset from center (with a bias for target pixel size)constdx=px/probeTargetSize-0.5+probePixelBias;// compute multiplier as affected by inclination of corresponding rayconstspan=Math.hypot(dx*2,dy*2);consthypo=Math.hypot(span,1);constarea=1/hypo;lookup[py*probeTargetSize+px]=area;}}returnlookup;}
Is there any calculation basis?
The text was updated successfully, but these errors were encountered:
Hi Oliver, this function computes the multiplier for each pixel of the light probe half-cube (well, of each side of the half-cube). The pixels near corners/edges of the cube are weighted less than center pixels in the resulting average. In other words, this is mapping cube pixels onto a sphere before combining them into a final sum. Actual mathematics here are very much approximated, I actually did not test this for physical precision or anything - the aim of the whole project is to be a quick convincing hack instead of a full mathematically correct solution. Hope this helps!
@unframework
Thank you for your answer
I drew the following figure based on the source code and your answer, which is very useful for me to understand how it works:
This also makes me understand the following program:
I have been reading the source code of this repo recently and have some questions about the function used to generate
probePixelAreaLookup
data. What is the internal basis of thegeneratePixelAreaLookup
function?Is there any calculation basis?
The text was updated successfully, but these errors were encountered: