Commit 32128812 authored by Adam Štěpánek's avatar Adam Štěpánek
Browse files

Play music

parent 976282c2
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,7 @@ target_include_directories(framework
add_executable(final
add_executable(final
	src/main.cpp 
	src/main.cpp 
	src/application.cpp
	src/application.cpp
	src/playback.cpp
)
)


add_dependencies(final 
add_dependencies(final 
@@ -136,3 +137,4 @@ endfunction()
copy_resources("shaders" "*")
copy_resources("shaders" "*")
copy_resources("images" "*")
copy_resources("images" "*")
copy_resources("objects" "*")
copy_resources("objects" "*")
copy_resources("music" "*")
+8902 −0

File added.

Preview size limit exceeded, changes collapsed.

+33209 −0

File added.

Preview size limit exceeded, changes collapsed.

+50 −30
Original line number Original line Diff line number Diff line
#version 450
#version 450


layout(binding = 0, std140) uniform Camera {
// ---------------------------------------------------------------------------------
	mat4 projection;
// Obtained from: https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl
	mat4 view;
// ---------------------------------------------------------------------------------
	vec3 position;

} camera;
// Description : Array and textureless GLSL 2D simplex noise function.

//      Author : Ian McEwan, Ashima Arts.
struct Light {
//  Maintainer : stegu
	vec4 position;
//     Lastmod : 20110822 (ijm)
	vec4 ambientColor;
//     License : Copyright (C) 2011 Ashima Arts. All rights reserved.
	vec4 diffuseColor;
//               Distributed under the MIT License. See LICENSE file.
	vec4 specularColor;
//               https://github.com/ashima/webgl-noise
};
//               https://github.com/stegu/webgl-noise

// 
layout(binding = 1, std430) buffer Lights {
	Light lights[];
};

layout(binding = 2, std140) uniform Object {
	mat4 modelMatrix;
	vec4 ambientColor;
	vec4 diffuseColor;
	vec4 specularColor;
} object;

layout(location = 0) in vec3 position;
layout(location = 1) in vec3 normal;

layout(location = 0) out vec3 fs_Position;
layout(location = 1) out vec3 fs_Normal;


vec3 mod289(vec3 x) {
vec3 mod289(vec3 x) {
  return x - floor(x * (1.0 / 289.0)) * 289.0;
  return x - floor(x * (1.0 / 289.0)) * 289.0;
@@ -91,6 +75,42 @@ float snoise(vec2 v)
  return 130.0 * dot(m, g);
  return 130.0 * dot(m, g);
}
}


// ---------------------
// End of 3rd party code
// ---------------------

layout(binding = 0, std140) uniform Camera {
	mat4 projection;
	mat4 view;
	vec3 position;
} camera;

struct Light {
	vec4 position;
	vec4 ambientColor;
	vec4 diffuseColor;
	vec4 specularColor;
};

layout(binding = 1, std430) buffer Lights {
	Light lights[];
};

layout(binding = 2, std140) uniform Object {
	mat4 modelMatrix;
	vec4 ambientColor;
	vec4 diffuseColor;
	vec4 specularColor;
} object;

layout(location = 0) uniform int magic;

layout(location = 0) in vec3 position;
layout(location = 1) in vec3 normal;

layout(location = 0) out vec3 fs_Position;
layout(location = 1) out vec3 fs_Normal;

void main()
void main()
{
{
	float rotationSeed = snoise(vec2(gl_InstanceID, 0.0)) * 360;
	float rotationSeed = snoise(vec2(gl_InstanceID, 0.0)) * 360;
@@ -107,6 +127,6 @@ void main()
	direction *= 2.3 + snoise(vec2(gl_InstanceID, 0.0)) / 2.0;
	direction *= 2.3 + snoise(vec2(gl_InstanceID, 0.0)) / 2.0;
	vec4 finalPosition = vec4(position * 0.01, 1.0);
	vec4 finalPosition = vec4(position * 0.01, 1.0);
	finalPosition.xz += direction;
	finalPosition.xz += direction;
	finalPosition.y += snoise(direction * 128.0) / 16.0;
	finalPosition.y += snoise(vec2(magic, 0.0));
	gl_Position = camera.projection * camera.view * rotation * object.modelMatrix * finalPosition;
	gl_Position = camera.projection * camera.view * rotation * object.modelMatrix * finalPosition;
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -89,6 +89,7 @@ void Application::render() {
	//polarTeapot.draw();
	//polarTeapot.draw();


	glUseProgram(beltProgram.id());
	glUseProgram(beltProgram.id());
	glProgramUniform1i(beltProgram.id(), 0, static_cast<int>(playback.magic));
	glBindBufferBase(GL_UNIFORM_BUFFER, 2, dustObjectBuffer);
	glBindBufferBase(GL_UNIFORM_BUFFER, 2, dustObjectBuffer);
	glBindVertexArray(teapot.vao());
	glBindVertexArray(teapot.vao());
	glDrawElementsInstanced(teapot.mode(), teapot.indicesCount(), GL_UNSIGNED_INT, nullptr, 2048);
	glDrawElementsInstanced(teapot.mode(), teapot.indicesCount(), GL_UNSIGNED_INT, nullptr, 2048);
Loading