Are Ray tracing resource hungry

I was wondering if ray tracing used a lot of resource?

What kind of ray tracing? One used in pixel shaders for looking around (screen space reflections, some parallax implementation, SSAO) or full blown povray-like raytracing?
What do you mean by lot of resources? Memory? CPU?

Assuming you mean real ray tracing, problem is not resource utilization, but fact that you cannot utilize GPU in meanigful way. Plus, it is completely out of scope for jme3.

Ok i mean this one,

import com.jme3.math.Ray;
Ray ray = new Ray(location, direction);

But i am trying to make a AI using it.

And yes i am wondering if it use lots of memorys or CPU to calculate a single ray or multiple ray. I was planing on making multiple ray at a time to find the path with no rock or tree in the way.

It depends. :slight_smile: You can easily use it for example to check the visibility between 100s of objects/players if all of the objects have say 5 or 6 points (e.g., shoulders, head, feet) you check, plus it being used for all of the objects to track a surface for example. If you try to do actual raytracing in the sense of tracing 1000s of rays per object/player then its probably using too much resources.

1 Like
@n3cr0 said: I was planing on making multiple ray at a time to find the path with no rock or tree in the way.

use pathfinding, not raytracing. if you want your ai to go somewhere, you must first know where to go. think of it as car gps navigation. there is no path without destination.

if you dont want pathfinding, still dont use multiple raytracing, but lets say this:

1 Like
@Ascaria said: use pathfinding, not raytracing. if you want your ai to go somewhere, you must first know where to go. think of it as car gps navigation. there is no path without destination.

if you dont want pathfinding, still dont use multiple raytracing, but lets say this:
Understanding Steering Behaviors: Collision Avoidance | Envato Tuts+

The second thing you ve said is exactly what i am trying to Achieve in a certain way. Using ray tracing i can see if there is actually something to be dodged. Then i will make the npc move in concequence! The thing is it will certainly use about 5-10 raytracing to see if there is a possible way to ignore the obstacle then once passed by it will try to make a new way to the player. The only problem would be corner obstacle… I cant really make raytracing all arround the player and try to find a way back arround. Maybe the pathfind would be better then! Anyway thank you everyone!

@n3cr0 said: The second thing you ve said is exactly what i am trying to Achieve in a certain way. Using ray tracing i can see if there is actually something to be dodged. Then i will make the npc move in concequence! The thing is it will certainly use about 5-10 raytracing to see if there is a possible way to ignore the obstacle then once passed by it will try to make a new way to the player. The only problem would be corner obstacle... I cant really make raytracing all arround the player and try to find a way back arround. Maybe the pathfind would be better then! Anyway thank you everyone!

Its easy to forget in games that you don’t simulate a real environment. In a real environment you don’t know about the obstacles in advance. In a game world you placed the obstacles yourself :wink: Its much more efficient to simply loop over all known obstacles instead of (re)discovering them each time you move an object though the environment :slight_smile:

There is this video of The Last of Us where they explain their buddy AI, they used ray tracing to find good positions for the buddy to walk next to the player without looking awkward. http://www.gamasutra.com/view/news/217215/Video_Ellies_buddy_AI_in_The_Last_Of_Us.php