Merge pull request 'prbTexture+ammo_count' (#10) from prbTexture+ammo_count into master
Reviewed-on: #10
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
|
||||
/grk/.vs/grk-cw
|
||||
/grk/project/Debug
|
||||
/.vs
|
||||
/grk/dependencies/glm/out/build/x64-Debug
|
||||
|
@ -14,15 +14,19 @@ private:
|
||||
float scale;
|
||||
glm::vec3 position;
|
||||
glm::mat4 positionMatrix;
|
||||
GLuint textureID;
|
||||
GLuint normalMapID;
|
||||
|
||||
public:
|
||||
Planet(GameObject* center, float distanceFromCenter, float rotationSpeed, float scale, Core::RenderContext sphereContext) {
|
||||
Planet(GameObject* center, float distanceFromCenter, float rotationSpeed, float scale, Core::RenderContext sphereContext, GLuint textureID, GLuint normalMapID) {
|
||||
this->center = center;
|
||||
this->distanceFromCenter = distanceFromCenter;
|
||||
this->rotationSpeed = rotationSpeed;
|
||||
this->sphereContext = sphereContext;
|
||||
this->scale = scale;
|
||||
this->position = glm::vec3(0);
|
||||
this->textureID = textureID;
|
||||
this->normalMapID = normalMapID;
|
||||
}
|
||||
|
||||
glm::mat4 getPositionMatrix() override {
|
||||
@ -37,6 +41,6 @@ public:
|
||||
float rotationAngle = glm::radians(time * rotationSpeed);
|
||||
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed) * glm::translate(glm::vec3(distanceFromCenter, 0, 0));
|
||||
glm::mat4 modelMatrix = positionMatrix * glm::scale(glm::vec3(scale));
|
||||
Core::drawObjectPBR(sphereContext, modelMatrix, glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0, program);
|
||||
Core::drawObjectPBRTexture(sphereContext, modelMatrix, textureID, 0.7, 0.0, program);
|
||||
}
|
||||
};
|
@ -57,7 +57,7 @@ public:
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
|
||||
return glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f));
|
||||
return glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.02f));
|
||||
}
|
||||
|
||||
void setPerticlesParameters(float speed, float generationInterval) {
|
||||
|
@ -62,6 +62,8 @@
|
||||
<None Include="shaders\shader_skybox.vert" />
|
||||
<None Include="shaders\shader_sprite.frag" />
|
||||
<None Include="shaders\shader_sprite.vert" />
|
||||
<None Include="shaders\shader_tex.frag" />
|
||||
<None Include="shaders\shader_tex.vert" />
|
||||
<None Include="shaders\test.frag" />
|
||||
<None Include="shaders\test.vert" />
|
||||
</ItemGroup>
|
||||
|
@ -59,6 +59,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="SpriteRenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Source.cpp">
|
||||
<Filter>Shader Files</Filter>
|
||||
</ClCompile>
|
||||
@ -122,6 +123,8 @@
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SpriteRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ParticleSystem.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -157,6 +160,14 @@
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_sprite.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="particle.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
|
12
grk/project/models/StarShip2.mtl
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
newmtl Siatka _Material.003
|
||||
illum 2
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 1.000000 1.000000 1.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ns 0.000000
|
||||
map_Kd Material.001_Base_color.jpg
|
||||
|
61184
grk/project/models/StarShip2.obj
Normal file
@ -9,8 +9,8 @@ uniform vec3 cameraPos;
|
||||
|
||||
uniform vec3 color;
|
||||
|
||||
uniform vec3 lightPositions[100];
|
||||
uniform vec3 lightColors[100];
|
||||
uniform vec3 lightPositions[8];
|
||||
uniform vec3 lightColors[8];
|
||||
|
||||
uniform vec3 spotlightPos;
|
||||
uniform vec3 spotlightColor;
|
||||
@ -103,7 +103,7 @@ void main()
|
||||
vec3 ambient = AMBIENT * color;
|
||||
vec3 ilumination = ambient;
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
lightDirs[i] = normalize(lightPositions[i] - worldPos);
|
||||
vec3 attenuatedlightColor = lightColors[i] / pow(length(lightPositions[i] - worldPos), 2);
|
||||
ilumination = ilumination+PBRLight(lightDirs[i], attenuatedlightColor * 300, normal, viewDir);
|
||||
|
@ -12,12 +12,12 @@ uniform mat4 modelMatrix;
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
|
||||
uniform vec3 lightsPositions[100];
|
||||
uniform vec3 lightsPositions[8];
|
||||
uniform vec3 spotlightPos;
|
||||
uniform vec3 cameraPos;
|
||||
|
||||
out vec3 viewDirTS;
|
||||
out vec3 lightDirTS[100];
|
||||
out vec3 lightDirTS[8];
|
||||
out vec3 spotlightDirTS;
|
||||
|
||||
void main()
|
||||
@ -33,7 +33,7 @@ void main()
|
||||
vec3 V = normalize(cameraPos-worldPos);
|
||||
viewDirTS = TBN*V;
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
vec3 L = normalize(lightsPositions[i]-worldPos);
|
||||
lightDirTS[i] = TBN*L;
|
||||
}
|
||||
|
128
grk/project/shaders/shader_tex.frag
Normal file
@ -0,0 +1,128 @@
|
||||
#version 430 core
|
||||
|
||||
float AMBIENT = 0.03;
|
||||
float PI = 3.14;
|
||||
|
||||
uniform sampler2D depthMap;
|
||||
|
||||
uniform vec3 cameraPos;
|
||||
|
||||
|
||||
uniform sampler2D textureSampler;
|
||||
|
||||
uniform vec3 lightPositions[100];
|
||||
uniform vec3 lightColors[100];
|
||||
|
||||
uniform vec3 spotlightPos;
|
||||
uniform vec3 spotlightColor;
|
||||
uniform vec3 spotlightConeDir;
|
||||
uniform vec3 spotlightPhi;
|
||||
|
||||
uniform float metallic;
|
||||
uniform float roughness;
|
||||
|
||||
uniform float exposition;
|
||||
|
||||
in vec3 vecNormal;
|
||||
in vec3 worldPos;
|
||||
in vec2 TexCoords;
|
||||
|
||||
out vec4 outColor;
|
||||
|
||||
|
||||
in vec3 viewDirTS;
|
||||
in vec3 lightDirTS[4];
|
||||
in vec3 spotlightDirTS;
|
||||
in vec3 sunDirTS;
|
||||
|
||||
in vec3 test;
|
||||
|
||||
float DistributionGGX(vec3 normal, vec3 H, float roughness){
|
||||
float a = roughness*roughness;
|
||||
float a2 = a*a;
|
||||
float NdotH = max(dot(normal, H), 0.0);
|
||||
float NdotH2 = NdotH*NdotH;
|
||||
|
||||
float num = a2;
|
||||
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
||||
denom = PI * denom * denom;
|
||||
|
||||
return num / denom;
|
||||
}
|
||||
float GeometrySchlickGGX(float NdotV, float roughness){
|
||||
float r = (roughness + 1.0);
|
||||
float k = (r*r) / 8.0;
|
||||
|
||||
float num = NdotV;
|
||||
float denom = NdotV * (1.0 - k) + k;
|
||||
|
||||
return num / denom;
|
||||
}
|
||||
float GeometrySmith(vec3 normal, vec3 V, vec3 lightDir, float roughness){
|
||||
float NdotV = max(dot(normal, V), 0.0);
|
||||
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
||||
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
||||
|
||||
return ggx1 * ggx2;
|
||||
}
|
||||
vec3 fresnelSchlick(float cosTheta, vec3 F0){
|
||||
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||
}
|
||||
|
||||
vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V, vec3 texcolorRGB){
|
||||
float diffuse=max(0,dot(normal,lightDir));
|
||||
|
||||
vec3 F0 = vec3(0.04);
|
||||
F0 = mix(F0, texcolorRGB , metallic);
|
||||
|
||||
vec3 H = normalize(V + lightDir);
|
||||
|
||||
float NDF = DistributionGGX(normal, H, roughness);
|
||||
float G = GeometrySmith(normal, V, lightDir, roughness);
|
||||
vec3 F = fresnelSchlick(max(dot(H, V), 0.0), F0);
|
||||
|
||||
vec3 kS = F;
|
||||
vec3 kD = vec3(1.0) - kS;
|
||||
kD *= 1.0 - metallic;
|
||||
|
||||
vec3 numerator = NDF * G * F;
|
||||
float denominator = 4.0 * max(dot(normal, V), 0.0) * max(dot(normal, lightDir), 0.0) + 0.0001;
|
||||
vec3 specular = numerator / denominator;
|
||||
|
||||
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||
return (kD * texcolorRGB / PI + specular) * radiance * NdotL;
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec4 texColor = texture(textureSampler, TexCoords);
|
||||
|
||||
vec3 normal = normalize(vecNormal);
|
||||
|
||||
vec3 viewDir = normalize(cameraPos-worldPos);
|
||||
|
||||
vec3 lightDirs[4];
|
||||
vec3 ambient = AMBIENT * texColor.rgb;
|
||||
vec3 ilumination = ambient;
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
lightDirs[i] = normalize(lightPositions[i] - worldPos);
|
||||
vec3 attenuatedlightColor = lightColors[i] / pow(length(lightPositions[i] - worldPos), 2);
|
||||
ilumination = ilumination+PBRLight(lightDirs[i], attenuatedlightColor * 300, normal, viewDir, texColor.rgb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec3 spotlightDir= normalize(spotlightPos-worldPos);
|
||||
|
||||
|
||||
float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1);
|
||||
vec3 attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2);
|
||||
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir, texColor.rgb);
|
||||
|
||||
|
||||
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||
}
|
46
grk/project/shaders/shader_tex.vert
Normal file
@ -0,0 +1,46 @@
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec3 vertexNormal;
|
||||
layout(location = 2) in vec2 vertexTexCoord;
|
||||
layout(location = 3) in vec3 vertexTangent;
|
||||
layout(location = 4) in vec3 vertexBitangent;
|
||||
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
out vec2 TexCoords;
|
||||
|
||||
uniform vec3 lightsPositions[10];
|
||||
uniform vec3 spotlightPos;
|
||||
uniform vec3 cameraPos;
|
||||
|
||||
out vec3 viewDirTS;
|
||||
out vec3 lightDirTS[10];
|
||||
out vec3 spotlightDirTS;
|
||||
|
||||
void main()
|
||||
{
|
||||
TexCoords = vertexTexCoord * -1;
|
||||
|
||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||
|
||||
vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent);
|
||||
vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent);
|
||||
mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal));
|
||||
|
||||
vec3 V = normalize(cameraPos-worldPos);
|
||||
viewDirTS = TBN*V;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
vec3 L = normalize(lightsPositions[i]-worldPos);
|
||||
lightDirTS[i] = TBN*L;
|
||||
}
|
||||
|
||||
vec3 SL = normalize(spotlightPos-worldPos);
|
||||
spotlightDirTS = TBN*SL;
|
||||
}
|
@ -10,6 +10,8 @@
|
||||
#include "../GameUtils.h"
|
||||
#include "../Spaceship.h"
|
||||
|
||||
#include "Texture.h"
|
||||
|
||||
|
||||
|
||||
void Core::RenderContext::initFromAssimpMesh(aiMesh* mesh) {
|
||||
@ -188,6 +190,47 @@ void Core::drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, gl
|
||||
Core::DrawContext(context);
|
||||
}
|
||||
|
||||
void Core::drawObjectPBRTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, float roughness, float metallic, GLuint program) {
|
||||
Spaceship* spaceship = Spaceship::getInstance();
|
||||
glm::mat4 viewProjectionMatrix = Core::createPerspectiveMatrix() * spaceship->createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
|
||||
glUniform1f(glGetUniformLocation(program, "exposition"), 1.f);
|
||||
|
||||
glUniform1f(glGetUniformLocation(program, "roughness"), roughness);
|
||||
glUniform1f(glGetUniformLocation(program, "metallic"), metallic);
|
||||
;
|
||||
//glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
||||
Core::SetActiveTexture(textureID, "textureSampler", program, 0);
|
||||
glUniform1i(glGetUniformLocation(program, "textureSampler"), 0);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "cameraPos"), spaceship->cameraPos.x, spaceship->cameraPos.y, spaceship->cameraPos.z);
|
||||
|
||||
std::list<Sun*>* suns = GameUtils::getInstance()->getSuns();
|
||||
|
||||
glm::vec3 lightsPositions[100];
|
||||
glm::vec3 lightsColors[100];
|
||||
|
||||
int i = 0;
|
||||
for (Sun* sun : *suns) {
|
||||
lightsPositions[i] = sun->getPosition();
|
||||
lightsColors[i] = sun->getColor();
|
||||
++i;
|
||||
}
|
||||
|
||||
glUniform3fv(glGetUniformLocation(program, "lightPositions"), 100, glm::value_ptr(lightsPositions[0]));
|
||||
glUniform3fv(glGetUniformLocation(program, "lightColors"), 100, glm::value_ptr(lightsColors[0]));
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightConeDir"), spaceship->spotlightConeDir.x, spaceship->spotlightConeDir.y, spaceship->spotlightConeDir.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightPos"), spaceship->spotlightPos.x, spaceship->spotlightPos.y, spaceship->spotlightPos.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spaceship->spotlightColor.x, spaceship->spotlightColor.y, spaceship->spotlightColor.z);
|
||||
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spaceship->spotlightPhi);
|
||||
|
||||
Core::DrawContext(context);
|
||||
}
|
||||
|
||||
void Core::drawSkybox(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, GLuint program) {
|
||||
Spaceship* spaceship = Spaceship::getInstance();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
@ -74,4 +74,5 @@ namespace Core
|
||||
glm::mat4 createPerspectiveMatrix();
|
||||
void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float roughness, float metallic, GLuint program);
|
||||
void loadModelToContext(std::string path, Core::RenderContext& context);
|
||||
void drawObjectPBRTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, float roughness, float metallic, GLuint program);
|
||||
}
|
@ -21,9 +21,18 @@ GLuint Core::LoadTexture( const char * filepath )
|
||||
unsigned char* image = SOIL_load_image(filepath, &w, &h, 0, SOIL_LOAD_RGBA);
|
||||
|
||||
|
||||
if (image) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
SOIL_free_image_data(image);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Texture loading failed for path: " << filepath << std::endl;
|
||||
}
|
||||
|
||||
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
//glGenerateMipmap(GL_TEXTURE_2D);
|
||||
//SOIL_free_image_data(image);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
||||
|
||||
int WIDTH = 500, HEIGHT = 500;
|
||||
|
||||
namespace models {
|
||||
Core::RenderContext marbleBustContext;
|
||||
Core::RenderContext spaceshipContext;
|
||||
@ -39,9 +38,19 @@ namespace models {
|
||||
}
|
||||
namespace texture {
|
||||
GLuint cubemapTexture;
|
||||
GLuint spaceshipTexture;
|
||||
GLuint spriteTexture;
|
||||
GLuint earthTexture;
|
||||
}
|
||||
|
||||
struct TextureTuple {
|
||||
GLuint textureID;
|
||||
GLuint normalMapID;
|
||||
};
|
||||
|
||||
std::vector<TextureTuple> planetTextures;
|
||||
|
||||
|
||||
void createGalaxy(glm::vec3 galaxyPosition);
|
||||
|
||||
GLuint depthMapFBO;
|
||||
@ -53,6 +62,7 @@ GLuint programTest;
|
||||
GLuint programSprite;
|
||||
GLuint programCubemap;
|
||||
GLuint programParticle;
|
||||
GLuint programTex;
|
||||
|
||||
std::list<Planet*> planets;
|
||||
Sun* sun;
|
||||
@ -84,6 +94,15 @@ void updateDeltaTime(float time) {
|
||||
lastTime = time;
|
||||
}
|
||||
|
||||
TextureTuple getRandomPlanetTexture() {
|
||||
int textureIndex = rand() % planetTextures.size();
|
||||
TextureTuple selectedTextures = planetTextures[textureIndex];
|
||||
//GLuint textureID = selectedTextures.textureID;
|
||||
//GLuint normalMapID = selectedTextures.normalMapID;
|
||||
|
||||
return planetTextures[textureIndex];
|
||||
}
|
||||
|
||||
void renderShadowapSun() {
|
||||
float time = glfwGetTime();
|
||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||
@ -94,6 +113,7 @@ void renderShadowapSun() {
|
||||
}
|
||||
void renderScene(GLFWwindow* window)
|
||||
{
|
||||
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
float time = glfwGetTime();
|
||||
@ -111,24 +131,36 @@ void renderScene(GLFWwindow* window)
|
||||
sun->draw();
|
||||
}
|
||||
|
||||
glUseProgram(program);
|
||||
|
||||
glUseProgram(programTex);
|
||||
for (Planet* p : planets) {
|
||||
p->draw(time, program);
|
||||
p->draw(time, programTex);
|
||||
}
|
||||
|
||||
glUseProgram(program);
|
||||
|
||||
spaceship->renderBullets(glfwGetTime(), program);
|
||||
|
||||
|
||||
|
||||
drawObjectPBR(models::sphereContext,
|
||||
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)),
|
||||
glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0, program);
|
||||
|
||||
drawObjectPBR(models::spaceshipContext,
|
||||
|
||||
glUseProgram(programTex);
|
||||
//Core::SetActiveTexture(texture::spaceshipTexture, "textureSampler", programTex, 0);
|
||||
drawObjectPBRTexture(models::spaceshipContext,
|
||||
spaceship->calculateModelMatrix(),
|
||||
spaceship->color,
|
||||
spaceship->roughness, spaceship->metallic, program
|
||||
texture::spaceshipTexture,
|
||||
spaceship->roughness, spaceship->metallic, programTex
|
||||
);
|
||||
|
||||
//Core::SetActiveTexture(texture::earthTexture, "textureSampler", programTex, 0);
|
||||
drawObjectPBRTexture(models::sphereContext, glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(1.0f)), texture::earthTexture, 0.3, 0.0, programTex);
|
||||
//glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) *
|
||||
Core::SetActiveTexture(texture::earthTexture, "textureSampler", programTex, 0);
|
||||
drawObjectPBRTexture(models::sphereContext, glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), texture::earthTexture, 0.3, 0.0, programTex);
|
||||
|
||||
glUseProgram(programSprite);
|
||||
for (const auto& enemy : enemies) {
|
||||
if (enemy->isAlive()) {
|
||||
@ -183,8 +215,11 @@ void createSolarSystem(glm::vec3 sunPos, float sunScale, float* planetSizes, int
|
||||
sun = new Sun(programSun, models::sphereContext, sunPos, glm::vec3(-0.93633f, 0.351106, 0.003226f), glm::vec3(0.9f, 0.9f, 0.7f) * 5, sunScale);
|
||||
gu->getSuns()->push_back(sun);
|
||||
for (int i = 0; i < numberOfPlanets; i++) {
|
||||
TextureTuple textures = getRandomPlanetTexture();
|
||||
GLuint texID = textures.textureID;
|
||||
GLuint norMapID = textures.normalMapID;
|
||||
float distanceFromSum = (i + 1) * planetsDistance;
|
||||
Planet* planet = new Planet(sun, distanceFromSum, i * 0.1f + planetSpeedCoef, planetSizes[i], models::sphereContext);
|
||||
Planet* planet = new Planet(sun, distanceFromSum, i * 0.1f + planetSpeedCoef, planetSizes[i], models::sphereContext, texID, norMapID);
|
||||
planets.push_back(planet);
|
||||
}
|
||||
}
|
||||
@ -197,23 +232,44 @@ void createEnemies() {
|
||||
|
||||
}
|
||||
|
||||
void loadPlanetsTextures() {
|
||||
planetTextures.clear();
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> texturePaths = {
|
||||
{"./textures/planets/planet1.png", "./textures/planets/planet1normal.png"},
|
||||
{"./textures/planets/planet2.png", "./textures/planets/planet2normal.png"},
|
||||
{"./textures/planets/planet3.png", "./textures/planets/planet3normal.png"},
|
||||
{"./textures/planets/planet4.png", "./textures/planets/planet4normal.png"}
|
||||
};
|
||||
|
||||
for (const auto& paths : texturePaths) {
|
||||
GLuint textureID = Core::LoadTexture(paths.first.c_str());
|
||||
GLuint normalMapID = Core::LoadTexture(paths.second.c_str());
|
||||
planetTextures.push_back({ textureID, normalMapID });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void init(GLFWwindow* window)
|
||||
{
|
||||
GameUtils* gameUtils = GameUtils::getInstance();
|
||||
spriteRenderer = new Core::SpriteRenderer();
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
program = gameUtils->shaderLoader->CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag");
|
||||
programTest = gameUtils->shaderLoader->CreateProgram("shaders/test.vert", "shaders/test.frag");
|
||||
programSun = gameUtils->shaderLoader->CreateProgram("shaders/shader_8_sun.vert", "shaders/shader_8_sun.frag");
|
||||
programCubemap = gameUtils->shaderLoader->CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
||||
programTex = gameUtils->shaderLoader->CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
|
||||
|
||||
|
||||
programSprite = gameUtils->shaderLoader->CreateProgram("shaders/shader_sprite.vert", "shaders/shader_sprite.frag");
|
||||
programParticle = gameUtils->shaderLoader->CreateProgram("shaders/particle.vert", "shaders/particle.frag");
|
||||
|
||||
loadModelToContext("./models/marbleBust.obj", models::marbleBustContext);
|
||||
loadModelToContext("./models/spaceship.obj", models::spaceshipContext);
|
||||
loadModelToContext("./models/StarShip2.obj", models::spaceshipContext);
|
||||
loadModelToContext("./models/sphere.obj", models::sphereContext);
|
||||
loadModelToContext("./models/cube.obj", models::cubeContext);
|
||||
Core::loadModelToContext("./models/sphere.obj", GameUtils::getInstance()->sphereContext);
|
||||
@ -229,7 +285,10 @@ void init(GLFWwindow* window)
|
||||
"bkg2_back6.png"
|
||||
};
|
||||
|
||||
loadPlanetsTextures();
|
||||
texture::cubemapTexture = Core::LoadCubemap(cubeFaces);
|
||||
texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg");
|
||||
texture::earthTexture = Core::LoadTexture("./textures/planets/8k_earth_daymap.jpg");
|
||||
|
||||
spaceship->createParticles();
|
||||
createSuns();
|
||||
|
BIN
grk/project/textures/planets/8k_earth_clouds.jpg
Normal file
After Width: | Height: | Size: 11 MiB |
BIN
grk/project/textures/planets/8k_earth_daymap.jpg
Normal file
After Width: | Height: | Size: 4.4 MiB |
BIN
grk/project/textures/planets/8k_earth_nightmap.jpg
Normal file
After Width: | Height: | Size: 3.0 MiB |
BIN
grk/project/textures/planets/8k_earth_normal_map.jpg
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
grk/project/textures/planets/earth_daymap.jpg
Normal file
After Width: | Height: | Size: 452 KiB |
BIN
grk/project/textures/planets/planet1.png
Normal file
After Width: | Height: | Size: 3.1 MiB |
BIN
grk/project/textures/planets/planet1normal.png
Normal file
After Width: | Height: | Size: 1.7 MiB |
BIN
grk/project/textures/planets/planet2.png
Normal file
After Width: | Height: | Size: 2.4 MiB |
BIN
grk/project/textures/planets/planet2normal.png
Normal file
After Width: | Height: | Size: 2.1 MiB |
BIN
grk/project/textures/planets/planet3.png
Normal file
After Width: | Height: | Size: 3.7 MiB |
BIN
grk/project/textures/planets/planet3normal.png
Normal file
After Width: | Height: | Size: 2.2 MiB |
BIN
grk/project/textures/planets/planet4.png
Normal file
After Width: | Height: | Size: 3.3 MiB |
BIN
grk/project/textures/planets/planet4normal.png
Normal file
After Width: | Height: | Size: 2.3 MiB |
BIN
grk/project/textures/spaceship/Material.001_Base_color.jpg
Normal file
After Width: | Height: | Size: 2.5 MiB |
BIN
grk/project/textures/spaceship/Material.001_Emissive.jpg
Normal file
After Width: | Height: | Size: 309 KiB |
BIN
grk/project/textures/spaceship/Material.001_Metallic.jpg
Normal file
After Width: | Height: | Size: 3.1 MiB |
BIN
grk/project/textures/spaceship/Material.001_Mixed_AO.jpg
Normal file
After Width: | Height: | Size: 2.9 MiB |
BIN
grk/project/textures/spaceship/Material.001_Normal_DirectX.jpg
Normal file
After Width: | Height: | Size: 2.9 MiB |
BIN
grk/project/textures/spaceship/Material.001_Roughness.jpg
Normal file
After Width: | Height: | Size: 1.3 MiB |