poczyszczenie zbędnych części

This commit is contained in:
K4RP4T 2024-01-18 16:50:20 +01:00
parent c4666bb860
commit 1c4579f1d6
8 changed files with 21 additions and 235 deletions

View File

@ -47,7 +47,7 @@
<ProjectGuid>{3952C396-B1C6-44CD-96DD-C1AC15D32978}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>grk-cw6</RootNamespace>
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Planeta</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -55,7 +55,7 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@ -92,7 +92,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp14</LanguageStandard>
<LanguageStandard>Default</LanguageStandard>
<AdditionalIncludeDirectories>D:\STUDIA\Planeta\grk\cw 6\src\imgui-master;D:\STUDIA\Planeta\grk\cw 6\src\imgui-master\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>

View File

@ -16,7 +16,6 @@ void main()
{
vec3 lightDir = normalize(lightPos - worldPos);
vec3 normal = normalize(vecNormal);
//float diffuse = max(0, dot(normal, lightDir));
vec4 textureColor = texture2D(colorTexture, vtc);
outColor = vec4(vec3(textureColor) * 1.5, 1.0);

View File

@ -18,5 +18,4 @@ void main()
gl_Position = transformation * vec4(vertexPosition, 1.0);
vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
//vtc = vertexTexCoord;
}

View File

@ -15,21 +15,21 @@ out vec4 outColor;
vec3 outputColor;
uniform sampler2D colorTexture;
vec3 toneMapping(vec3 color){
vec3 toneMapping(vec3 color) {
float exposure = 0.06;
vec3 mapped = 1 - exp(-color*exposure);
return mapped;
}
void main()
{
vec3 lightDir = normalize(lightPos - worldPos);
vec3 normal = normalize(vecNormal);
float diffuse = max(0, dot(normal, lightDir));
textureColor = texture2D(colorTexture, vtc);
vec3 distance = lightColor/pow(length(lightPos - worldPos), 2.0) * 200;
outputColor = vec3(textureColor) * min(1, AMBIENT + diffuse)* distance;
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 200;
outputColor = vec3(textureColor) * min(1, AMBIENT + diffuse) * distance;
//gamma correction
//outputColor = pow(outputColor, vec3(1.0/2.2));

View File

@ -18,5 +18,4 @@ void main()
gl_Position = transformation * vec4(vertexPosition, 1.0);
vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
//vtc = vertexTexCoord;
}

View File

@ -1,24 +1,10 @@
#include "glew.h"
//#include "imgui.h"
//#include "imgui_impl_glfw.h"
//#include "imgui_impl_opengl3.h"
//#include <stdio.h>
//#define GL_SILENCE_DEPRECATION
//#if defined(IMGUI_IMPL_OPENGL_ES2)
//#include <GLES2/gl2.h>
//#endif
#include <GLFW/glfw3.h>
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
//#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
//#pragma comment(lib, "legacy_stdio_definitions")
//#endif
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Texture.h"
@ -33,17 +19,10 @@ namespace texture {
GLuint earth;
GLuint clouds;
GLuint moon;
GLuint ship;
GLuint mercury;
GLuint venus;
GLuint mars;
GLuint sun;
GLuint grid;
GLuint earthNormal;
GLuint asteroidNormal;
GLuint shipNormal;
}
GLuint program;
@ -53,7 +32,6 @@ GLuint programTex;
Core::Shader_Loader shaderLoader;
//Core::RenderContext shipContext;
Core::RenderContext sphereContext;
glm::vec3 sunPosition = glm::vec3(12.f, 0.f, 12.f);
@ -70,30 +48,11 @@ unsigned int colorBuffers[2];
unsigned int depthMap;
unsigned int depthMapFBO;
int HDR_WIDTH = 1024;
int HDR_HEIGHT = 1024;
glm::vec3 lightColor = glm::vec3(50, 50, 50);
/*
glm::mat4 createShipMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, cameraDir));
glm::mat4 shipRotationMatrix = glm::mat4({
cameraSide.x,cameraSide.y,cameraSide.z,0,
cameraUp.x,cameraUp.y,cameraUp.z ,0,
shipDir.x,shipDir.y,shipDir.z,0,
0.,0.,0.,1.,
});
shipRotationMatrix = glm::transpose(shipRotationMatrix);
return shipRotationMatrix;
}
*/
glm::mat4 createCameraMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
@ -202,18 +161,6 @@ void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture
glUseProgram(0);
}
/*
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) {
glUseProgram(program);
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
Core::DrawContext(context);
glUseProgram(0);
}
void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float roughness, float metallic) {
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
@ -244,7 +191,6 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
}
*/
void renderScene(GLFWwindow* window)
{
glClearColor(0.0f, 0.0f, 0.15f, 1.0f);
@ -252,58 +198,6 @@ void renderScene(GLFWwindow* window)
glm::mat4 transformation;
float time = glfwGetTime();
/*
glm::mat4 mercuryScale = glm::scale(glm::vec3(0.24));
glm::mat4 mercuryRotate = glm::rotate(time * 0.24f, glm::vec3(0, 1, 0));
glm::mat4 mercuryTranslate = glm::translate(glm::vec3(0, 0, -3));
glm::mat4 venusScale = glm::scale(glm::vec3(0.55));
glm::mat4 venusRotate = glm::rotate(time * 0.61f, glm::vec3(0, 1, 0));
glm::mat4 venusTranslate = glm::translate(glm::vec3(0, 0, -5));
glm::mat4 earthScale = glm::scale(glm::vec3(0.6));
glm::mat4 earthRotate = glm::rotate(time, glm::vec3(0, 1, 0));
glm::mat4 earthTranslate = glm::translate(glm::vec3(0, 0, -7));
glm::mat4 moonScale = glm::scale(glm::vec3(0.2));
glm::mat4 moonRotate = glm::rotate(time, glm::vec3(0, 1, 0));
glm::mat4 moonTranslate = glm::translate(glm::vec3(0, 0, -2));
glm::mat4 marsScale = glm::scale(glm::vec3(0.3));
glm::mat4 marsRotate = glm::rotate(time * 1.8f, glm::vec3(0, 1, 0));
glm::mat4 marsTranslate = glm::translate(glm::vec3(0, 0, -9));
//glm::mat4 shipScale = glm::scale(glm::vec3(0.3));
//glm::mat4 shipRotate = createShipMatrix();
//glm::mat4 shipTranslate = glm::translate(shipPos);
//glUseProgram(program);
//glUniform3f(glGetUniformLocation(program, "lightDir"), 1.0, -1.0, 0.0);
//glUniform3f(glGetUniformLocation(program, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
//glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
//glUniform3f(glGetUniformLocation(program, "lightPos"), 0.0, 0.0, 0.0);
//glUseProgram(0);
drawObjectColor(sphereContext, sunScale, glm::vec3(0.9, 0.9, 0.2)); //sun
drawObjectTexture(sphereContext, mercuryRotate * mercuryTranslate * mercuryScale, texture::mercury); //mercury
drawObjectTexture(sphereContext, venusRotate * venusTranslate * venusScale, texture::venus); //venus
drawObjectTexture(sphereContext, earthRotate * earthTranslate * earthScale, texture::earth); //earth
drawObjectTexture(sphereContext, earthRotate * earthTranslate * earthScale * moonRotate * moonTranslate * moonScale, texture::moon); //moon
drawObjectTexture(sphereContext, marsRotate * marsTranslate * marsScale, texture::mars); //mars
drawObjectTexture(shipContext, shipTranslate * shipRotate * shipScale, texture::ship); //ship
*/
//glUseProgram(programTex);
//glUniform3f(glGetUniformLocation(programTex, "lightDir"), cameraDir.x, cameraDir.y, cameraDir.z);
//glUseProgram(0);
glm::mat4 sunScale = glm::scale(glm::vec3(0.04f));
glm::mat4 sunTranslate = glm::translate(sunPosition);
@ -347,7 +241,6 @@ void init(GLFWwindow* window)
initHDR();
programDepth = shaderLoader.CreateProgram("shaders/shader_smap.vert", "shaders/shader_smap.frag");
program = shaderLoader.CreateProgram("shaders/shader.vert", "shaders/shader.frag");
programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
programSun = shaderLoader.CreateProgram("shaders/shader_sun.vert", "shaders/shader_sun.frag");
@ -360,7 +253,9 @@ void init(GLFWwindow* window)
void shutdown(GLFWwindow* window)
{
shaderLoader.DeleteProgram(program);
shaderLoader.DeleteProgram(programDepth);
shaderLoader.DeleteProgram(programTex);
shaderLoader.DeleteProgram(programSun);
}
//obsluga wejscia
@ -368,8 +263,8 @@ void processInput(GLFWwindow* window)
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
float angleSpeed = 0.02f;
float moveSpeed = 0.04f;
float angleSpeed = 0.002f;
float moveSpeed = 0.004f;
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
@ -378,107 +273,24 @@ void processInput(GLFWwindow* window)
cameraPos += cameraDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
cameraPos -= cameraDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
cameraPos += cameraSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
cameraPos -= cameraSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
cameraDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(cameraDir, 0));
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
cameraDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(cameraDir, 0));
//shipPos = cameraPos + 0.75 * cameraDir + glm::vec3(0, -0.25f, 0);
//shipDir = cameraDir;
cameraPos += cameraSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
cameraPos -= cameraSide * moveSpeed;
//if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
// cameraDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(cameraDir, 0));
//if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
// cameraDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(cameraDir, 0));
//cameraDir = glm::normalize(-cameraPos);
cameraDir = glm::normalize(-cameraPos);
}
// Our state
//bool show_demo_window = true;
//bool show_another_window = false;
//ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
// funkcja jest glowna petla
void renderLoop(GLFWwindow* window) {
// Setup Dear ImGui context
//IMGUI_CHECKVERSION();
//ImGui::CreateContext();
//ImGuiIO& io = ImGui::GetIO(); (void)io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
// Setup Dear ImGui style
//ImGui::StyleColorsDark();
while (!glfwWindowShouldClose(window))
{
/*glfwPollEvents();
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window);
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
{
static float f = 0.0f;
static int counter = 0;
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
ImGui::Checkbox("Another Window", &show_another_window);
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
counter++;
ImGui::SameLine();
ImGui::Text("counter = %d", counter);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::End();
}
// 3. Show another simple window.
if (show_another_window)
{
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me"))
show_another_window = false;
ImGui::End();
}
// Rendering
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
*/
processInput(window);
renderScene(window);
glfwPollEvents();
}
/*
// Cleanup
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
return 0;*/
}
//}

View File

@ -1,33 +1,17 @@
#include "glew.h"
//#include "imgui.h"
//#include "imgui_impl_glfw.h"
//#include "imgui_impl_opengl3.h"
//#include <stdio.h>
//#define GL_SILENCE_DEPRECATION
//#if defined(IMGUI_IMPL_OPENGL_ES2)
//#include <GLES2/gl2.h>
//#endif
#include <GLFW/glfw3.h>
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
//#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
//#pragma comment(lib, "legacy_stdio_definitions")
//#endif
#include "Planet.hpp"
int main(int argc, char** argv)
{
// inicjalizacja glfw
glfwInit();
//const char* glsl_version = "#version 150";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
@ -45,11 +29,6 @@ int main(int argc, char** argv)
return -1;
}
glfwMakeContextCurrent(window);
//glfwSwapInterval(1); // Enable vsync
// Setup Platform/Renderer backends
//ImGui_ImplGlfw_InitForOpenGL(window, true);
//ImGui_ImplOpenGL3_Init(glsl_version);
// ladowanie OpenGL za pomoca glew
glewInit();

View File

@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw6", "cw 6\grk-cw6.vcxproj", "{3952C396-B1C6-44CD-96DD-C1AC15D32978}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw6", "cw 6\grk-cw6.vcxproj", "{3952C396-B1C6-44CD-96DD-C1AC15D32978}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Planeta", "cw 6\grk-cw6.vcxproj", "{3952C396-B1C6-44CD-96DD-C1AC15D32978}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution