Hi guys, i just have a simple question and how i can implement a ray cast that shoots in all directions
Is it possible to “shoot raycast in all directions”. if so, than how can i do it.
what i want is a ray casts shot in every direction, then the ray cast will identify the color, than instantiate a point light with the color data, and boom. i googled on how to but i just don’t seem to have much luck on how to.
Any help would be appreciated!
P.S: i’d rather not share my script sense it’s practically empty. but with a few lines of code.
P.S.S the code is required to be in javascript sense its the only scripting language i know.
sorry to point it out, but that’s not how GI is going work. At least not with the poin light sources. While you could implement some sort of Final Gathering by shooting rays from each point in all directions, that would be really slow (like in let’s-check-back-in-a-few-days slow) and you would need the ability to evaluate a shader for a given surface point and incidence ray. For this you would need a CPU implementation of each of the material shaders used in the scene. Then, after acquiring this data, you’d need to properly sample it into lightmap textures and use these on your geometry to render the final image. What is described here is not a good idea.
Actually, shooting raycasts in all directions won’t ever finish because there are infinite directions. Instantiating infinite colored point lights will also require infinite memory. So no, you can’t shoot raycasts in all directions because both time and memory constraints. I don’t know what the ‘boom’ is for, however. I’d say that it’s an in-game explosion event, but then there would be no need for ‘all directions’.
What I am trying to say is that we can’t help you when we don’t know in which context you are working, and what you really want to do - you need to be clearer so others can try to help you. My guess is that you want to implement a real time photon mapping, light propagation volume or some kind of radiosity algorithm. In all of these cases, you will need to learn a lot more than javascript (and I mean it). Also, I think that unity only gives you physics raycasting. It can be rather bad for rendering if you do not pre-compute data. My hint is to stick to the built-in lightning system in the unity, and abuse of good use o lightmaps.
If you just want to know colors that can be seen from a point in space, there is a trick known as Hemicubes that is reasonably fast to implement, but I would not advice to use more than a dozen in real time games. Also, you’ll need RenderTextures.