diff --git a/grk-project.vcxproj b/grk-project.vcxproj
index 5332a2d..8bda9b1 100644
--- a/grk-project.vcxproj
+++ b/grk-project.vcxproj
@@ -11,12 +11,14 @@
+
+
-
-
+
+
diff --git a/grk-project.vcxproj.filters b/grk-project.vcxproj.filters
index 7589c2e..70ea294 100644
--- a/grk-project.vcxproj.filters
+++ b/grk-project.vcxproj.filters
@@ -18,12 +18,6 @@
-
- Shader Files
-
-
- Shader Files
-
Shader Files
@@ -60,6 +54,18 @@
Shader Files
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
diff --git a/shaders/shader_asteroid.frag b/shaders/shader_asteroid.frag
new file mode 100644
index 0000000..8098f4a
--- /dev/null
+++ b/shaders/shader_asteroid.frag
@@ -0,0 +1,62 @@
+#version 430 core
+
+layout (location = 0) out vec4 FragColor;
+layout (location = 1) out vec4 BrightColor;
+
+struct PointLight {
+ vec3 position;
+ vec3 color;
+ float intensity;
+};
+
+#define MAX_POINT_LIGHTS 16
+
+uniform vec3 cameraPos;
+uniform sampler2D diffuseTexture;
+uniform sampler2D normalTexture;
+uniform PointLight pointLights[MAX_POINT_LIGHTS];
+uniform int LightsCount;
+
+in vec3 fragPos;
+in vec2 vTexCoord;
+in vec3 LightPosTS[MAX_POINT_LIGHTS];
+in vec3 CameraPosTS;
+in vec3 FragPosTS;
+
+
+
+void main()
+{
+ vec3 fragColor = vec3(0,0,0);
+ vec3 texture = texture2D(diffuseTexture, vTexCoord).rgb;
+ //vec3 texture = vec3(textureColor.x, textureColor.y, textureColor.z);
+ vec3 ambient = vec3(0.1, 0.1, 0.1) * texture;
+
+ vec3 normal = texture2D(normalTexture, vTexCoord).rgb;
+ normal = normalize(normal * 2.0 - 1.0);
+
+ vec3 V = normalize(CameraPosTS-FragPosTS);
+
+ for(int i = 0; i < LightsCount; i++)
+ {
+ vec3 lightDir = normalize(LightPosTS[i] - FragPosTS);
+
+
+ vec3 R = reflect(-lightDir,normal);
+
+ float dist = distance(fragPos, pointLights[i].position);
+ float distance = (1/dist) * (1/dist);
+
+ float spec = pow(max(0,dot(R,V)),2);
+ float diff = max(0,dot(normal,normalize(lightDir)));
+
+ vec3 diffuse = pointLights[i].color * diff * distance * pointLights[i].intensity;
+ vec3 specular = spec * pointLights[i].color * (pointLights[i].intensity/dist);
+
+
+ fragColor += texture*diffuse+specular;
+ }
+
+ BrightColor = vec4(0.0, 0.0, 0.0, 1.0);
+ FragColor = vec4(fragColor+ambient,1.0);
+}
diff --git a/shaders/shader_asteroid.vert b/shaders/shader_asteroid.vert
new file mode 100644
index 0000000..efe5a64
--- /dev/null
+++ b/shaders/shader_asteroid.vert
@@ -0,0 +1,55 @@
+#version 430 core
+
+layout(location = 0) in vec3 vertexPosition;
+layout(location = 1) in vec2 vertexTexCoord;
+layout(location = 2) in vec3 vertexNormal;
+layout (location = 3) in vec3 aTangent;
+layout (location = 4) in vec3 aBitangent;
+layout (location = 5) in mat4 aInstanceMatrix;
+
+struct PointLight {
+ vec3 position;
+ vec3 color;
+ float intensity;
+};
+
+#define MAX_POINT_LIGHTS 16
+
+uniform mat4 projection;
+uniform mat4 view;
+uniform vec3 cameraPos;
+uniform PointLight pointLights[MAX_POINT_LIGHTS];
+uniform int LightsCount;
+
+
+out vec3 fragPos;
+out vec2 vTexCoord;
+out vec3 LightPosTS[MAX_POINT_LIGHTS];
+out vec3 CameraPosTS;
+out vec3 FragPosTS;
+
+void main()
+{
+ gl_Position = projection * view * aInstanceMatrix * vec4(vertexPosition, 1.0);
+
+ mat3 normalMatrix = transpose(inverse(mat3(aInstanceMatrix)));
+
+ vec3 T = normalize(normalMatrix * aTangent);
+ vec3 N = normalize(normalMatrix * vertexNormal);
+ // re-orthogonalize T with respect to N
+ T = normalize(T - dot(T, N) * N);
+ // then retrieve perpendicular vector B with the cross product of T and N
+ vec3 B = cross(N, T);
+
+ mat3 TBN = mat3(T, B, N);
+
+ for(int i=0; i cube;
std::shared_ptr sphere;
@@ -68,16 +69,17 @@ std::shared_ptr asteroid;
//std::vector corvetteMeshes;
std::shared_ptr crewmate;
+
+//cameraPos
float cameraAngle = 0;
glm::vec3 cameraPos = glm::vec3(-6, 0, 0);
glm::vec3 cameraDir;
glm::vec3 cameraSide;
-
-
glm::mat4 cameraMatrix, perspectiveMatrix;
glm::vec3 sunPos = glm::vec3(10.0f, 0.0f, -5.0f);
glm::vec3 sunPos2 = glm::vec3(25.0f, -1.0f, 10.0f);
+
//particlepart
struct Particle {
glm::vec3 pos, speed;
@@ -90,6 +92,16 @@ struct Particle {
return this->cameradistance > that.cameradistance;
}
};
+
+struct Object
+{
+ glm::mat4 modelM;
+ glm::mat4 invModelM;
+ std::shared_ptr modelParent;
+ GLuint textureID;
+ GLuint shaderID;
+ glm::vec3 color;
+};
const int MaxParticles = 1000;
Particle ParticlesContainer[MaxParticles];
@@ -138,8 +150,9 @@ std::vector faces
"skybox/back.jpg"
};
-
+std::vector