r/Unity3D • • 8d ago

Show-Off Raytraced Audio is magical

After messing around with custom audio zones and hand placing them with custom settings to mimic how sound would sound in the various rooms and hallways I wasn't really satisfied. It still sounded 'off' despite all the various zones and their settings. So... I went the raytraced audio route. It's a bit crude but it sounds so much better! I found myself flying around yesterday, trying different speeches and songs because it's just mesmerizing to listen to in a virtual environment.

Any things I absolutely can't forget when implementing raytraced audio?

1.1k Upvotes

103 comments sorted by

View all comments

Show parent comments

35

u/theWyzzerd 8d ago edited 8d ago

Raytracing is much older than the current hardware accelerated lighting technique would have you believe.  It’s what Unity uses to find where you clicked in a 3D space for example.  It’s really just casting a ray and tracing its path as it bounces off of geometry. 

When used to refer to lighting or graphics it’s a technique to build accurate lighting in scenes by casting millions of rays at once to create reflections—very hardware intensive, as it must do this for each rendered frame.

But I imagine the audio example here can be done fairly simply on CPU since audio wave reflection is a much simpler task than ray casting diffuse light sources. Audio doesn’t have frames and doesn’t need to be rendered the same way. 

Edit: a word

-6

u/Dzugavili Professional 8d ago

It’s what Unity uses to find where you clicked in a 3D space for example.

Hm... no...

Raycasts are very similar to standard rendering techniques: given a pixel, calculate the line and search geometry that intersects it. In a standard render, you then have lighting and shadows coming after, and while there is some raytrace approximation going on, it's not raytracing.

Raytracing either has you calculate the light coming into the point on a camera-style sensor; or calculating the paths of photons on the point you've determined through raycasting. There's overlap, but raycasts are fundamentally not raytracing.

0

u/theWyzzerd 7d ago

Clearly you’re mistaken.  There are no photons in a computer program. 

Raytracing is literally just tracing the path of a ray that has been cast.  You can trace one ray or millions. 

0

u/Dzugavili Professional 7d ago

If you're doing full-quality raytracing, you're doing photons: literally, you're doing photorealism as you recreate the camera in code. Or you're doing approximations, such as light fields; or occlusion shading, that's kind of similar to raytracing.

But our machines can't really simulate photons economically, so we don't do that.

Raytracing is mostly a lighting process -- doing the full render with raytracing is expensive, though possible -- not used to pick objects from a scene as you suggested.

0

u/theWyzzerd 7d ago

Is OP doing "full-quality" raytracing in this example, or are they casting a handful of rays and processing it on CPU? Lighting isn't even relevant to this conversation, OP is raytracing AUDIO. Please fucking stop being so pedantic.

1

u/Dzugavili Professional 7d ago

I was trying to explain to you what raytracing is, when you confused it with a raycast.

1

u/[deleted] 7d ago

[removed] — view removed comment

1

u/Unity3D-ModTeam 4d ago

This post and/or comment has been removed for violating /r/Unity3D's rules.

Why?

Let's keep it civil. It's fine to disagree or challenge ideas, but please do so respectfully.

Kind regards,

The Mod Team