Closed garrynewman closed 3 months ago
@garrynewman These are great questions!
maxDistance <= 0
: Yes, the correct thing to do in this case is to return 1 to indicate that the ray is occluded. However, I'm curious as to why this is happening in the first place. Do you have a callstack/minidump of an instance where maxDistance <= 0
?minDistance
: The first way of calculating end
is correct, i.e. end = origin + maxDistance * direction
. Both minDistance
and maxDistance
are measured from the origin
of the ray.IPLHit.distance
: Again, the first way is correct: distance = length(hitpoint - origin)
, since all distances are calculated from the ray origin.IPLHit
output parameter and return from the callback.maxNumRays
: The intent is definitely to allow you to change the actual number of rays used dynamically. So you can set the max value to something large, then change the actual value to a smaller value as needed. If these two numbers are very different, then it's possible that the ray distribution may be skewed. Was 32000 vs 128 a particular case where you observed all the rays being emitted to the left? I can double-check to make sure there isn't some sort of bug here too.So with maxNumRays
, I can definitely see how this would happen from the code. In ReflectionSimulator
's constructor it creates mListenerSamples
based on maxNumRays
, but then in ReflectionSimulator::simulate
it's only sampling the first numRays
of them, instead of some distributed sample.
With maxDistance, here's a stacktrace where it was 0
> Sandbox.Engine.dll!Sandbox.Audio.SteamAudio.AnyHit(IPLRay* ray, float minDistance, float maxDistance, byte* occluded, void* userData) Line 202 C#
[External Code]
phonon.dll!ipl::CustomScene::anyHit(const ipl::Ray & ray, float minDistance, float maxDistance) Line 48 C++
phonon.dll!ipl::IScene::isOccluded(const ipl::Vector3<float> & from, const ipl::Vector3<float> & to) Line 33 C++
[Inline Frame] phonon.dll!ipl::DirectSimulator::volumetricOcclusion(const ipl::IScene & sourcePosition, const ipl::Vector3<float> & numSamples, const ipl::Vector3<float> &) Line 168 C++
phonon.dll!ipl::DirectSimulator::simulate(const ipl::IScene * scene, ipl::DirectSimulationFlags flags, const ipl::CoordinateSpace3<float> & source, const ipl::CoordinateSpace3<float> & listener, const ipl::DistanceAttenuationModel & distanceAttenuationModel, const ipl::AirAbsorptionModel & airAbsorptionModel, const ipl::Directivity & directivity, ipl::OcclusionType occlusionType, float occlusionRadius, int numOcclusionSamples, int numTransmissionRays, ipl::DirectSoundPath & directSoundPath) Line 102 C++
[Inline Frame] phonon.dll!ipl::SimulationManager::simulateDirect(ipl::SimulationData & source) Line 171 C++
[Inline Frame] phonon.dll!ipl::SimulationManager::simulateDirect() Line 165 C++
phonon.dll!api::CSimulator::runDirect() Line 180 C++
engine2.dll!CSteamAudio::SimulateDirect(IPhysicsWorld * physics, const CTransform & listener) Line 188 C++
engine2.dll!Exports::CSteamAudio_SimulateDirect(void * self, IPhysicsWorld * world, CTransformUnaligned listener) Line 7376 C++
And here's one where it equals -1
> Sandbox.Engine.dll!Sandbox.Audio.SteamAudio.AnyHit(IPLRay* ray, float minDistance, float maxDistance, byte* occluded, void* userData) Line 205 C#
Sandbox.Engine.dll!Sandbox.Audio.SteamAudio.batchedAnyHitCallback.AnonymousMethod__0(int[] group) Line 257 C#
[External Code]
Sandbox.Engine.dll!Sandbox.Audio.SteamAudio.batchedAnyHitCallback(int numRays, IPLRay* rays, float* minDistances, float* maxDistances, byte* occluded, void* userData) Line 253 C#
[External Code]
phonon.dll!ipl::CustomScene::anyHits(int numRays, const ipl::Ray * rays, const float * minDistances, const float * maxDistances, bool * occluded) Line 87 C++
phonon.dll!ipl::BatchedReflectionSimulator::shade(const ipl::IScene & scene, int sourceIndex, int scalar, float start, int end, int threadId, int) Line 992 C++
phonon.dll!ipl::BatchedReflectionSimulator::simulateJob(const ipl::IScene & scene, int start, int end, int threadId, std::atomic<bool> & cancel) Line 815 C++
[External Code]
[Inline Frame] phonon.dll!std::_Func_class<void,int,std::atomic<bool> &>::operator()(int <_Args_0>, std::atomic<bool> &) Line 869 C++
[Inline Frame] phonon.dll!ipl::Job::process(int) Line 42 C++
[Inline Frame] phonon.dll!ipl::JobGraph::processNextJob(int) Line 68 C++
phonon.dll!ipl::ThreadPool::threadFunc(int threadId) Line 84 C++
[External Code]
[Inline Frame] phonon.dll!invoke_thread_procedure(unsigned int(*)(void *) context, void * const) Line 91 C++
phonon.dll!thread_start<unsigned int (__cdecl*)(void * __ptr64)>(void * const parameter) Line 115 C++
I do kind of worry that the plain simulators aren't ever gonna be as well trodden as the embree path, so I'm gonna look at the feasibility of using that instead, since I guess it would mean I could just put simulator tracing on a thread and forget about it.
Ah, the BatchedReflectionSimulator
sets maxDistance
to -1 to indicate that the ray should not be traced. I will update the docs to indicate that if maxDistance <= minDistance
, the ray shouldn't be traced. Thanks!
Hey guys, seeking some clarification on custom scene tracing and what we should be doing.
MaxDistance <= 0
Sometimes MaxDistance is zero, or less than zero in IPLAnyHitCallback. I noticed that if we don't return 1 for occluded in this instance the reflection bounces seem to echo forever. Should we be returning 1? Are we doing anything else wrong?
MinDistance
What should we be doing with minDistance and MaxDistance?
or
IPLHit.distance
When tracing with IPLClosestHitCallback, how should the hit distance be calculated?
Is it
or
No Hits
If there's no hits with IPLClosestHitCallback, should we be clearing the IPLHit, or just returning and ignoring it?
maxNumRays
When setting
simulationSettings.maxNumRays
to some huge number, like 32000, and thensharedInputs.numRays
to some configurable, manageable value, like 128.. the spread of the rays aren't distributed uniformly. They will only emit from the left for example.Is this right? Should these numbers always be the same?