- Home /
thousands of raycasts in nested for loop
hi, i wanted to know what’d be the best approach to get faster results than we expect now from calculating ambient occlusion for a tree.
for now we calculate in rough something like this:
for (int i =0; i<verteciescount;i++){
//some basic setups
for (int x = 0; x< sample64; x++){
pos = vertecies[i];
dir= randompositioninsphere+pos;
//Physics.Raycast
}
}
tried it with batches raycastcommands,(jobs) does not increase performance very much it’s like 1.1x times faster than physics.raycast
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612195019im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Change the direction of ScreenPointToRay() Ray 1 Answer
RayCast Nearest Character 0 Answers
Raycast doesn't work properly? 0 Answers