refractoring

This commit is contained in:
Wojtek 2024-01-24 22:49:58 +01:00
parent 6e7c437aa8
commit 2054a2919e
5 changed files with 57305 additions and 57292 deletions

View File

@ -1,14 +1,12 @@
# Blender 3.4.1 MTL File: 'StarShip2.blend' #
# www.blender.org #
#
newmtl Material.003 newmtl Siatka _Material.003
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ni 1.450000
d 1.000000
illum 2 illum 2
map_Kd C:/Users/dovgo/OneDrive/Desktop/3D/Texture/StarShip2/Material.001_Base_color.jpg Ka 1.000000 1.000000 1.000000
map_Ns C:/Users/dovgo/OneDrive/Desktop/3D/Texture/StarShip2/Material.001_Roughness.jpg Kd 1.000000 1.000000 1.000000
map_refl C:/Users/dovgo/OneDrive/Desktop/3D/Texture/StarShip2/Material.001_Metallic.jpg Ks 0.500000 0.500000 0.500000
map_Ke C:/Users/dovgo/OneDrive/Desktop/3D/Texture/StarShip2/Material.001_Emissive.jpg Ns 0.000000
map_Bump -bm 1.000000 C:/Users/dovgo/OneDrive/Desktop/3D/Texture/StarShip2/Material.001_Normal_DirectX.jpg map_Kd Material.001_Base_color.jpg

File diff suppressed because it is too large Load Diff

View File

@ -70,11 +70,11 @@ vec3 fresnelSchlick(float cosTheta, vec3 F0){
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0); 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 albedo){ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V, vec3 texcolorRGB){
float diffuse=max(0,dot(normal,lightDir)); float diffuse=max(0,dot(normal,lightDir));
vec3 F0 = vec3(0.04); vec3 F0 = vec3(0.04);
F0 = mix(F0, albedo , metallic); F0 = mix(F0, texcolorRGB , metallic);
vec3 H = normalize(V + lightDir); vec3 H = normalize(V + lightDir);
@ -91,7 +91,7 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V, vec3 albedo){
vec3 specular = numerator / denominator; vec3 specular = numerator / denominator;
float NdotL = max(dot(normal, lightDir), 0.0); float NdotL = max(dot(normal, lightDir), 0.0);
return (kD * albedo / PI + specular) * radiance * NdotL; return (kD * texcolorRGB / PI + specular) * radiance * NdotL;
} }

View File

@ -10,6 +10,8 @@
#include "../GameUtils.h" #include "../GameUtils.h"
#include "../Spaceship.h" #include "../Spaceship.h"
#include "Texture.h"
void Core::RenderContext::initFromAssimpMesh(aiMesh* mesh) { void Core::RenderContext::initFromAssimpMesh(aiMesh* mesh) {
@ -201,6 +203,7 @@ void Core::drawObjectPBRTexture(Core::RenderContext& context, glm::mat4 modelMat
glUniform1f(glGetUniformLocation(program, "metallic"), metallic); glUniform1f(glGetUniformLocation(program, "metallic"), metallic);
; ;
//glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z); //glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
Core::SetActiveTexture(textureID, "textureSampler", program, 0);
glUniform1i(glGetUniformLocation(program, "textureSampler"), 0); glUniform1i(glGetUniformLocation(program, "textureSampler"), 0);
glUniform3f(glGetUniformLocation(program, "cameraPos"), spaceship->cameraPos.x, spaceship->cameraPos.y, spaceship->cameraPos.z); glUniform3f(glGetUniformLocation(program, "cameraPos"), spaceship->cameraPos.x, spaceship->cameraPos.y, spaceship->cameraPos.z);

View File

@ -30,7 +30,6 @@
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
int WIDTH = 500, HEIGHT = 500; int WIDTH = 500, HEIGHT = 500;
namespace models { namespace models {
Core::RenderContext marbleBustContext; Core::RenderContext marbleBustContext;
Core::RenderContext spaceshipContext; Core::RenderContext spaceshipContext;
@ -128,14 +127,18 @@ void renderScene(GLFWwindow* window)
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::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); glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0, program);
Core::SetActiveTexture(texture::spaceshipTexture, "textureSampler", programTex, 0);
glUseProgram(programTex); glUseProgram(programTex);
//Core::SetActiveTexture(texture::spaceshipTexture, "textureSampler", programTex, 0);
drawObjectPBRTexture(models::spaceshipContext, drawObjectPBRTexture(models::spaceshipContext,
spaceship->calculateModelMatrix(), spaceship->calculateModelMatrix(),
texture::spaceshipTexture, texture::spaceshipTexture,
spaceship->roughness, spaceship->metallic, programTex 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); 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); 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);
@ -212,7 +215,6 @@ void init(GLFWwindow* window)
GameUtils* gameUtils = GameUtils::getInstance(); GameUtils* gameUtils = GameUtils::getInstance();
spriteRenderer = new Core::SpriteRenderer(); spriteRenderer = new Core::SpriteRenderer();
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
program = gameUtils->shaderLoader->CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag"); program = gameUtils->shaderLoader->CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag");
@ -245,8 +247,6 @@ void init(GLFWwindow* window)
texture::cubemapTexture = Core::LoadCubemap(cubeFaces); texture::cubemapTexture = Core::LoadCubemap(cubeFaces);
texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg"); texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg");
texture::earthTexture = Core::LoadTexture("./textures/spaceship/earth_daymap.jpg"); texture::earthTexture = Core::LoadTexture("./textures/spaceship/earth_daymap.jpg");
//texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/541.jpg");
spaceship->createParticles(); spaceship->createParticles();
createSuns(); createSuns();