stuff
This commit is contained in:
parent
dc5654ba9a
commit
3ffed086b1
7 changed files with 54 additions and 9 deletions
BIN
assets/DefaultTexture.jpg
(Stored with Git LFS)
BIN
assets/DefaultTexture.jpg
(Stored with Git LFS)
Binary file not shown.
|
|
@ -90,9 +90,8 @@ void main()
|
||||||
vec3 viewDir = normalize(viewPos - FragPos);
|
vec3 viewDir = normalize(viewPos - FragPos);
|
||||||
|
|
||||||
vec3 albedo = calcTextures();
|
vec3 albedo = calcTextures();
|
||||||
albedo = vec3(1,1,1);
|
|
||||||
|
|
||||||
//result += calcDirectLight(dirLight, norm, viewDir, albedo);
|
result += calcDirectLight(dirLight, norm, viewDir, albedo);
|
||||||
|
|
||||||
for(int i = 0; i < numberOfPointLights; i++){
|
for(int i = 0; i < numberOfPointLights; i++){
|
||||||
if (pointLights[i].disabled) continue;
|
if (pointLights[i].disabled) continue;
|
||||||
|
|
|
||||||
|
|
@ -96,4 +96,9 @@ namespace engine::Backend
|
||||||
void scroll_callback(GLFWwindow* window2, double xoffset, double yoffset)
|
void scroll_callback(GLFWwindow* window2, double xoffset, double yoffset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWwindow* getWindow()
|
||||||
|
{
|
||||||
|
return window;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,4 +18,6 @@ namespace engine::Backend
|
||||||
|
|
||||||
bool Init(const char* title, int width, int height);
|
bool Init(const char* title, int width, int height);
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
|
GLFWwindow* getWindow();
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +187,7 @@ vector<Texture> Model::loadMaterialTextures(aiMaterial *mat, aiTextureType type,
|
||||||
string defaultPath = "DefaultTexture.jpg";
|
string defaultPath = "DefaultTexture.jpg";
|
||||||
|
|
||||||
Texture texture;
|
Texture texture;
|
||||||
texture.id = TextureFromFile(defaultPath.c_str(), "assets/");
|
texture.id = TextureFromFile(defaultPath.c_str(), "assets");
|
||||||
texture.type = typeName;
|
texture.type = typeName;
|
||||||
texture.path = defaultPath;
|
texture.path = defaultPath;
|
||||||
textures.push_back(texture);
|
textures.push_back(texture);
|
||||||
|
|
@ -201,8 +201,7 @@ vector<Texture> Model::loadMaterialTextures(aiMaterial *mat, aiTextureType type,
|
||||||
|
|
||||||
unsigned inline int TextureFromFile(const char *path, const string &directory, bool gamma)
|
unsigned inline int TextureFromFile(const char *path, const string &directory, bool gamma)
|
||||||
{
|
{
|
||||||
string filename = string(path);
|
string filename = directory + '/' + path;
|
||||||
filename = directory + '/' + filename;
|
|
||||||
|
|
||||||
unsigned int textureID;
|
unsigned int textureID;
|
||||||
glGenTextures(1, &textureID);
|
glGenTextures(1, &textureID);
|
||||||
|
|
@ -232,7 +231,8 @@ unsigned inline int TextureFromFile(const char *path, const string &directory, b
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Texture failed to load at path: " << path << std::endl;
|
std::cout << "Texture failed to load at path: " << filename << std::endl;
|
||||||
|
std::cerr << "STB Reason: " << stbi_failure_reason() << "\n";
|
||||||
stbi_image_free(data);
|
stbi_image_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
|
||||||
#include <stb/stb_image.h>
|
#include <stb/stb_image.h>
|
||||||
|
|
||||||
Texture::Texture(const char* texturePath, bool flip)
|
Texture::Texture(const char* texturePath, bool flip)
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,14 @@
|
||||||
#include <engine/Backend/Model.h>
|
#include <engine/Backend/Model.h>
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
#include <glfw/include/GLFW/glfw3.h>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
|
#include "engine/Backend/Backend.h"
|
||||||
|
|
||||||
namespace game
|
namespace game
|
||||||
{
|
{
|
||||||
const int SCREEN_WIDTH = 1366;
|
const int SCREEN_WIDTH = 1366;
|
||||||
|
|
@ -26,9 +30,19 @@ namespace game
|
||||||
shader.emplace("assets/shaders/basicVertex.vert", "assets/shaders/basicFragment.frag");
|
shader.emplace("assets/shaders/basicVertex.vert", "assets/shaders/basicFragment.frag");
|
||||||
shader->Use();
|
shader->Use();
|
||||||
|
|
||||||
|
shader->setInt("ourTexture", 0);
|
||||||
|
shader->setInt("material.diffuse", 0);
|
||||||
|
shader->setInt("material.specular", 1);
|
||||||
|
|
||||||
|
shader->setInt("numberOfPointLights", 1);
|
||||||
|
shader->setInt("numberOfSpotLights", 1);
|
||||||
|
|
||||||
camera.emplace(glm::vec3(0.0f, 0.0f, 0.0f));
|
camera.emplace(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
model.emplace("assets/models/sponza/Sponza.gltf");
|
model.emplace("assets/models/sponza/Sponza.gltf");
|
||||||
|
|
||||||
|
glfwSetInputMode(engine::Backend::getWindow(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
|
glfwSetInputMode(engine::Backend::getWindow(), GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,6 +54,32 @@ namespace game
|
||||||
shader->Use();
|
shader->Use();
|
||||||
|
|
||||||
camera->Update(shader.value(), SCREEN_WIDTH, SCREEN_HEIGHT);
|
camera->Update(shader.value(), SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
|
|
||||||
|
shader->setFloat("material.shininess", 32.0f);
|
||||||
|
|
||||||
|
shader->setVec3("dirLight.direction", -0.2f, -1.0f, -0.3f);
|
||||||
|
shader->setVec3("dirLight.ambient", 0.05f, 0.05f, 0.05f);
|
||||||
|
shader->setVec3("dirLight.diffuse", 0.8f, 0.8f, 0.8f);
|
||||||
|
shader->setVec3("dirLight.specular", 0.8f, 0.8f, 0.8f);
|
||||||
|
|
||||||
|
shader->setVec3("pointLights[0].position", -1.88f, 8.45f, -0.98f);
|
||||||
|
shader->setVec3("pointLights[0].ambient", 0.05f, 0.05f, 0.05f);
|
||||||
|
shader->setVec3("pointLights[0].diffuse", 1.0f, 0.7f, 0.4f);
|
||||||
|
shader->setVec3("pointLights[0].specular", 1.0f, 1.0f, 1.0f);
|
||||||
|
shader->setFloat("pointLights[0].constant", 1.0f);
|
||||||
|
shader->setFloat("pointLights[0].linear", 0.09f);
|
||||||
|
shader->setFloat("pointLights[0].quadratic", 0.032f);
|
||||||
|
|
||||||
|
shader->setVec3("spotLights[0].position", camera->position);
|
||||||
|
shader->setVec3("spotLights[0].direction", camera->front);
|
||||||
|
shader->setVec3("spotLights[0].ambient", 0.0f, 0.0f, 0.0f);
|
||||||
|
shader->setVec3("spotLights[0].diffuse", 1.0f, 1.0f, 1.0f);
|
||||||
|
shader->setVec3("spotLights[0].specular", 1.0f, 1.0f, 1.0f);
|
||||||
|
shader->setFloat("spotLights[0].constant", 1.0f);
|
||||||
|
shader->setFloat("spotLights[0].linear", 0.09f);
|
||||||
|
shader->setFloat("spotLights[0].quadratic", 0.032f);
|
||||||
|
shader->setFloat("spotLights[0].cutOff", glm::cos(glm::radians(12.5f)));
|
||||||
|
shader->setFloat("spotLights[0].outerCutOff", glm::cos(glm::radians(15.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render()
|
void Render()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue