Compare commits
3 Commits
ShootEvent
...
NormalMaps
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b0cc1d80b | |||
| 8cf83454d7 | |||
| 41f0daaf3f |
+1
-1
Submodule assets updated: 6ffb46e155...f7e349a316
@@ -9,7 +9,7 @@
|
|||||||
#include "../Core/EntityFilePreprocessor.h"
|
#include "../Core/EntityFilePreprocessor.h"
|
||||||
#include "../Core/EntityFileParser.h"
|
#include "../Core/EntityFileParser.h"
|
||||||
#include "../Core/EntityFileWriter.h"
|
#include "../Core/EntityFileWriter.h"
|
||||||
#include "../Core/EMouseRelease.h"
|
#include "../Core/EMousePress.h"
|
||||||
#include "EditorGUI.h"
|
#include "EditorGUI.h"
|
||||||
#include "EditorStats.h"
|
#include "EditorStats.h"
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ private:
|
|||||||
void OnComponentDelete(EntityWrapper entity, const std::string& componentType);
|
void OnComponentDelete(EntityWrapper entity, const std::string& componentType);
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
EventRelay<EditorSystem, Events::MouseRelease> m_EMouseRelease;
|
EventRelay<EditorSystem, Events::MousePress> m_EMousePress;
|
||||||
bool OnMouseRelease(const Events::MouseRelease& e);
|
bool OnMousePress(const Events::MousePress& e);
|
||||||
EventRelay<EditorSystem, Events::WidgetDelta> m_EWidgetDelta;
|
EventRelay<EditorSystem, Events::WidgetDelta> m_EWidgetDelta;
|
||||||
bool OnWidgetDelta(const Events::WidgetDelta& e);
|
bool OnWidgetDelta(const Events::WidgetDelta& e);
|
||||||
};
|
};
|
||||||
@@ -27,6 +27,7 @@ private:
|
|||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
|
Texture* m_NeutralNormalMap;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ uniform mat4 V;
|
|||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
uniform vec2 ScreenDimensions;
|
uniform vec2 ScreenDimensions;
|
||||||
uniform sampler2D texture0;
|
layout(binding = 0) uniform sampler2D DiffuseTexture;
|
||||||
|
layout(binding = 1) uniform sampler2D NormalMapTexture;
|
||||||
|
|
||||||
#define TILE_SIZE 16
|
#define TILE_SIZE 16
|
||||||
|
|
||||||
@@ -44,6 +45,8 @@ layout (std430, binding = 4) buffer LightIndexBuffer
|
|||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
|
vec3 Tangent;
|
||||||
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 DiffuseColor;
|
vec4 DiffuseColor;
|
||||||
}Input;
|
}Input;
|
||||||
@@ -96,12 +99,18 @@ LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensi
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
|
||||||
|
{
|
||||||
|
mat3 TBN = mat3(tangent, bitangent, normal);
|
||||||
|
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
|
||||||
|
return vec4(TBN * normalize(NormalMap), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 texel = texture2D(texture0, Input.TextureCoordinate);
|
vec4 texel = texture2D(DiffuseTexture, Input.TextureCoordinate);
|
||||||
vec4 position = V * M * vec4(Input.Position, 1.0);
|
vec4 position = V * M * vec4(Input.Position, 1.0);
|
||||||
vec4 normal = V * vec4(Input.Normal, 0.0);
|
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture);
|
||||||
vec4 viewVec = normalize(-position);
|
vec4 viewVec = normalize(-position);
|
||||||
|
|
||||||
vec2 tilePos;
|
vec2 tilePos;
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ layout(location = 10) in vec4 BoneWeights2;
|
|||||||
out VertexData{
|
out VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
|
vec3 Tangent;
|
||||||
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 DiffuseColor;
|
vec4 DiffuseColor;
|
||||||
}Output;
|
}Output;
|
||||||
@@ -30,5 +32,7 @@ void main()
|
|||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
||||||
|
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
|
||||||
|
Output.BiTangent = vec3(M * vec4(BiTangent, 0.0));
|
||||||
Output.DiffuseColor = DiffuseVertexColor;
|
Output.DiffuseColor = DiffuseVertexColor;
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ EditorSystem::EditorSystem(World* world, EventBroker* eventBroker, IRenderer* re
|
|||||||
m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2));
|
m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1));
|
m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1));
|
||||||
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorSystem::OnMouseRelease);
|
EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &EditorSystem::OnMousePress);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EWidgetDelta, &EditorSystem::OnWidgetDelta);
|
EVENT_SUBSCRIBE_MEMBER(m_EWidgetDelta, &EditorSystem::OnWidgetDelta);
|
||||||
|
|
||||||
m_EditorStats = new EditorStats();
|
m_EditorStats = new EditorStats();
|
||||||
@@ -121,9 +121,10 @@ void EditorSystem::OnComponentDelete(EntityWrapper entity, const std::string& co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorSystem::OnMouseRelease(const Events::MouseRelease& e)
|
bool EditorSystem::OnMousePress(const Events::MousePress& e)
|
||||||
{
|
{
|
||||||
if (e.Button == GLFW_MOUSE_BUTTON_1) {
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (!io.WantCaptureMouse && !io.WantCaptureKeyboard && e.Button == GLFW_MOUSE_BUTTON_1) {
|
||||||
PickData pick = m_Renderer->Pick(glm::vec2(e.X, e.Y));
|
PickData pick = m_Renderer->Pick(glm::vec2(e.X, e.Y));
|
||||||
if (pick.World == m_World) {
|
if (pick.World == m_World) {
|
||||||
m_CurrentSelection = EntityWrapper(m_World, pick.Entity);
|
m_CurrentSelection = EntityWrapper(m_World, pick.Entity);
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ bool EditorWidgetSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
|
|
||||||
bool EditorWidgetSystem::OnMousePress(const Events::MousePress & e)
|
bool EditorWidgetSystem::OnMousePress(const Events::MousePress & e)
|
||||||
{
|
{
|
||||||
if (e.Button == GLFW_MOUSE_BUTTON_1) {
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (!io.WantCaptureMouse && !io.WantCaptureKeyboard && e.Button == GLFW_MOUSE_BUTTON_1) {
|
||||||
m_PickData = m_Renderer->Pick(glm::vec2(e.X, e.Y));
|
m_PickData = m_Renderer->Pick(glm::vec2(e.X, e.Y));
|
||||||
if (m_PickData.Entity != EntityID_Invalid && m_PickData.World == m_World) {
|
if (m_PickData.Entity != EntityID_Invalid && m_PickData.World == m_World) {
|
||||||
m_PickEntity = EntityWrapper(m_World, m_PickData.Entity);
|
m_PickEntity = EntityWrapper(m_World, m_PickData.Entity);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling
|
|||||||
void DrawFinalPass::InitializeTextures()
|
void DrawFinalPass::InitializeTextures()
|
||||||
{
|
{
|
||||||
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
||||||
|
m_NeutralNormalMap = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeShaderPrograms()
|
void DrawFinalPass::InitializeShaderPrograms()
|
||||||
@@ -59,6 +60,15 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modelJob->NormalTexture != nullptr) {
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture->m_Texture);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalMap->m_Texture);
|
||||||
|
}
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
|
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user