Commit 7b2dead6 authored by Dario Seyb's avatar Dario Seyb

made music loop

parent b2062388
......@@ -28,7 +28,8 @@ vec3 unpackWorldPosition(float depth) {
clipSpaceLocation.z = depth * 2.0 - 1.0;
clipSpaceLocation.w = 1.0;
vec4 homogenousLocation = uViewProjectionInverseMatrix * clipSpaceLocation;
return homogenousLocation.xyz / homogenousLocation.w;
homogenousLocation /= homogenousLocation.w;
return homogenousLocation.xyz;
}
float linearizeDepth(float depth) {
......@@ -61,9 +62,11 @@ void main() {
float sampleDepth = texture(uSamplerDepth, offset.xy).r;
vec3 samplePos = unpackWorldPosition(sampleDepth);
// range check & accumulate:
float rangeCheck= length(samplePos-origin) > uRadius ? 1.0 : 0.0;
occlusion += ( originDepth >= sampleDepth ? 1.0 : 0.0) * rangeCheck;
float rangeCheck= length(samplePos-origin) < uRadius ? 1.0 : 0.0;
//oColor.r = samplePos.x; return;
occlusion += ( length(origin) >= length(samplePos) ? 1.0 : 0.0) * rangeCheck;
}
occlusion = 1.0 - (occlusion / uSampleKernelSize);
......
......@@ -18,11 +18,11 @@ struct SoundSource : Component<SoundSource> {
friend class AudioSystem;
public:
SoundSource() : m_sound(nullptr), m_channel(nullptr) {}
SoundSource(std::shared_ptr<Sound> sound) : m_sound(sound), m_channel(nullptr), m_state(PlaybackState::STOPPED) {}
SoundSource(std::shared_ptr<Sound> sound) : m_sound(sound), m_channel(nullptr), m_state(PlaybackState::STOPPED) { }
void stop();
void pause();
void play();
void play(int loops = 0);
void setVolume(float vol);
PlaybackState getState() { return m_state; }
......
......@@ -16,7 +16,7 @@ void SoundSource::pause() {
}
}
void SoundSource::play() {
void SoundSource::play(int loops) {
bool isPaused;
m_channel->getPaused(&isPaused);
if (isPaused && m_channel) {
......@@ -25,6 +25,7 @@ void SoundSource::play() {
m_channel = m_sound->play();
}
m_channel->setVolume(m_volume);
m_channel->setLoopCount(loops);
m_state = PlaybackState::PLAYING;
}
......
......@@ -42,7 +42,7 @@ void AtmosphereTestScene::switchConsole() {
m_renderer->setRenderPassActive("Skybox"_sh, true);
m_renderer->setRenderPassActive("Minimap"_sh, true);
cockpitSoundSource->setVolume(0);
cockpitSoundSource->play();
cockpitSoundSource->play(-1);
m_renderer->setRenderPassActive("Console"_sh, false);
} else {
......@@ -315,7 +315,7 @@ void AtmosphereTestScene::switchToMainScene() {
consoleSoundSource = console.assign<SoundSource>(soundTrackMain);
consoleSoundSource->setVolume(0.5);
consoleSoundSource->play();
consoleSoundSource->play(-1);
auto consoleFrontLeft = m_sceneGraph->create();
consoleFrontLeft.assign<Drawable>(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment