Download

Simulating Diffraction Using Blueprints?

Hello everyone! I want to create a way of simulating sound wave diffraction in UE4. I have this idea of how to achieve this in theoretical and conceptual terms, but I am struggling to figure out how I would actually go about doing this in the engine. For those of you who dont know what this is, its basically how sound waves bend around obstacles and how they spread beyond small openings.

The concept is visualized in this illustration:

This idea mainly revolves around a concept of a “portal” (marked P) that is used to represent a door or opening in the game. I imagine this being a simple box collider, either 2D or 3D.

We try to calculate a diffraction value, which is a float number, that can be used to affect the sound (through volume change, filtering etc). The idea here is that as long as the player is in front of the portal/door (between the blue dotted line and blue drawn line), the diffraction value should be a specific float number, lets say 0.4, which we can call the portal float pF. However, when the player goes to either side of the portal and towards the wall, this value gradually increases as we approach the Max Angle where the value is something else, lets say 0.8, and call it the wall float number wF. The diffraction value transitions from the portal float to the wall float and the other way around depending on the angle of the player in relation to the portal.

The idea was to first draw two vectors from both edges of the portal in a straight line forward (Portal Normal), and two Max angle vectors (In the illustration, only one side is used). Then, in runtime, we could find the point on the portal closest to the player and draw a vector to the player (Vector to listener). We could then say that as long as the Portal Normal vector is parallell with the Vector to the listener, the diffraction value is equal to the portal float (pF), and when its not, we find the angle between Portal Normal and Vector to the listener. This angle could be used to represent a float value somewhere between the pF and wF values. That way, the diffraction value could represent float values between pF and wF depending on the players angle in relation to the portal.

I am sorry if I am using the wrong mathematical terms, being a sound designer. If anyone have any suggestions on how I could achieve this in blueprints, that would be great!