pouët.net

Sample jjittering on a cubemap

category: code [glöplog]
 
Given a normal vector how can I randomize it within a certain cone angle?
added on the 2012-11-14 16:32:31 by xernobyl xernobyl
With an uniform distribution :)
added on the 2012-11-14 16:33:54 by xernobyl xernobyl
xernobyl: Generate two perpendicular vectors to the vector, and jitter in their plane.
added on the 2012-11-14 16:39:39 by kusma kusma
Pick random point inside unit sphere, scale, add original vector and renormalize (last step optional for cubemaps). If you want uniform distribution you should probably be able to work out distribution inside unit sphere so final distribution is uniform - distribution within unit sphere is biased towards cone center, distribution on sphere surface is biased towards cone surface, so there should be something in between that gives unit distribution for givan cone angle.
added on the 2012-11-14 18:54:23 by KK KK
Thank you I think I got it. It's not the fastest thing there is but does the job.
added on the 2012-11-15 00:59:16 by xernobyl xernobyl
Well, to do this you need one extra SAMPLE (to fetch random vector value), one extra MAD (to unbias and scale to final radius) and one extra ADD (to sum it up) - that's assuming cubemap will ignore final vector length. I don't think you can get much faster than that.
added on the 2012-11-15 04:52:42 by KK KK
I believe it can be done with 2 rotations; first pick one of the possible planes that contain the vector of the apex-base center vector, rotate in that plane with center at the apex between -angle and angle, with the angle given by your cone, and finally rotate between 0 and pi (or any multiple) around the axis defined by the original position of the vector apex-base center
added on the 2012-11-15 09:09:56 by texel texel
maybe even one rotation. my idea would be to sample a random rotation axis, preferrably a unit vector, otherwise: normalize. sample some random angle, do a rotation around that axis using quaternion rotation. the final vector will have the same length and the cone is defined by the max values for the angle.
added on the 2012-11-15 10:07:22 by skomp skomp

login