Added model preview while dragging model into viewport and outline fully opaque
This commit is contained in:
@@ -134,6 +134,14 @@ namespace Nuake
|
||||
return pixelData;
|
||||
}
|
||||
|
||||
float FrameBuffer::ReadDepth(const Vector2& coords)
|
||||
{
|
||||
glReadBuffer(GL_DEPTH_ATTACHMENT);
|
||||
float pixelData;
|
||||
glReadPixels((int)coords.x, (int)coords.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pixelData);
|
||||
return pixelData;
|
||||
}
|
||||
|
||||
void FrameBuffer::SetDrawBuffer(GLenum draw)
|
||||
{
|
||||
Bind();
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace Nuake
|
||||
|
||||
uint32_t GetRenderID() const { return m_FramebufferID; }
|
||||
int ReadPixel(uint32_t attachment, const Vector2 coords);
|
||||
float ReadDepth(const Vector2& coords);
|
||||
void SetDrawBuffer(GLenum draw);
|
||||
void SetReadBuffer(GLenum read);
|
||||
};
|
||||
|
||||
@@ -330,14 +330,14 @@ namespace Nuake
|
||||
}
|
||||
mOutlineBuffer->Unbind();
|
||||
|
||||
//ImGui::Begin("outline");
|
||||
//ImGui::Image((void*)mOutlineBuffer->GetTexture(GL_COLOR_ATTACHMENT0)->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0));
|
||||
//ImGui::End();
|
||||
ImGui::Begin("normals");
|
||||
ImGui::Image((void*)mGBuffer->GetTexture(GL_COLOR_ATTACHMENT1)->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::End();
|
||||
|
||||
framebuffer.Bind();
|
||||
{
|
||||
RenderCommand::Clear();
|
||||
Shader* shader = ShaderManager::GetShader("Resources/Shaders/combine.shader");
|
||||
Shader* shader = ShaderManager::GetShader("Resources/Shaders/add.shader");
|
||||
shader->Bind();
|
||||
|
||||
shader->SetUniformTex("u_Source", mVignetteBuffer->GetTexture().get(), 0);
|
||||
@@ -368,6 +368,17 @@ namespace Nuake
|
||||
Renderer::EndDraw();
|
||||
}
|
||||
|
||||
void SceneRenderer::DrawTemporaryModel(const std::string & name, Ref<Model> model, Matrix4 transform)
|
||||
{
|
||||
if (IsTempModelLoaded(name))
|
||||
{
|
||||
mTempModels[name].Transform = transform;
|
||||
return;
|
||||
}
|
||||
|
||||
mTempModels[name] = TemporaryModels{ model, transform };
|
||||
}
|
||||
|
||||
void SceneRenderer::DrawDebugLine(const Vector3& start, const Vector3& end, const Color& color, float life)
|
||||
{
|
||||
DebugLine debugLine = {
|
||||
@@ -375,7 +386,8 @@ namespace Nuake
|
||||
.End = end,
|
||||
.LineColor = color,
|
||||
.Life = life,
|
||||
.Width = 2.0f
|
||||
.Width = 2.0f,
|
||||
.DepthTest = true
|
||||
};
|
||||
|
||||
mDebugLines.push_back(debugLine);
|
||||
@@ -389,7 +401,7 @@ namespace Nuake
|
||||
shader->Bind();
|
||||
|
||||
RenderCommand::Disable(RendererEnum::FACE_CULL);
|
||||
glCullFace(GL_FRONT);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
auto meshView = scene.m_Registry.view<TransformComponent, ModelComponent, VisibilityComponent>();
|
||||
auto quakeView = scene.m_Registry.view<TransformComponent, BSPBrushComponent, VisibilityComponent>();
|
||||
@@ -548,6 +560,22 @@ namespace Nuake
|
||||
}
|
||||
Renderer::Flush(gBufferShader, false);
|
||||
|
||||
for (auto& mesh : mTempModels)
|
||||
{
|
||||
if (mesh.second.ModelResource)
|
||||
{
|
||||
for (auto& m : mesh.second.ModelResource->GetMeshes())
|
||||
{
|
||||
Renderer::SubmitMesh(m, mesh.second.Transform, (uint32_t)-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
Renderer::Flush(gBufferShader, true);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
// Quake BSPs
|
||||
auto quakeView = scene.m_Registry.view<TransformComponent, BSPBrushComponent, VisibilityComponent>();
|
||||
for (auto e : quakeView)
|
||||
@@ -562,8 +590,10 @@ namespace Nuake
|
||||
Renderer::SubmitMesh(b, transform.GetGlobalTransform(), (uint32_t)e);
|
||||
}
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glCullFace(GL_FRONT);
|
||||
Renderer::Flush(gBufferShader, false);
|
||||
Renderer::Flush(gBufferShader, true);
|
||||
|
||||
// Sprites
|
||||
auto spriteView = scene.m_Registry.view<TransformComponent, SpriteComponent, VisibilityComponent>();
|
||||
@@ -659,6 +689,12 @@ namespace Nuake
|
||||
Renderer::QuadMesh->SetMaterial(previousMaterial);
|
||||
}
|
||||
|
||||
|
||||
// Temp models
|
||||
|
||||
|
||||
|
||||
|
||||
// Reset material on quadmesh
|
||||
// Renderer::QuadMesh->SetMaterial(previousMaterial);
|
||||
|
||||
@@ -696,6 +732,8 @@ namespace Nuake
|
||||
}
|
||||
|
||||
RenderCommand::Enable(RendererEnum::BLENDING);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SceneRenderer::ShadingPass(Scene& scene)
|
||||
@@ -811,12 +849,18 @@ namespace Nuake
|
||||
shader->SetUniformMat4f("u_Projection", mProjection);
|
||||
shader->SetUniformMat4f("u_View", mView);
|
||||
|
||||
bool depthTestState = true;
|
||||
for (auto& l : mDebugLines)
|
||||
{
|
||||
shader->SetUniformVec4("u_Color", l.LineColor);
|
||||
shader->SetUniformVec3("u_StartPos", l.Start);
|
||||
shader->SetUniformVec3("u_EndPos", l.End);
|
||||
|
||||
if (l.DepthTest)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
glLineWidth(l.Width);
|
||||
RenderCommand::DrawLines(0, 2);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,13 @@ namespace Nuake
|
||||
Color LineColor;
|
||||
float Life;
|
||||
float Width;
|
||||
bool DepthTest = true;
|
||||
};
|
||||
|
||||
struct TemporaryModels
|
||||
{
|
||||
Ref<Model> ModelResource;
|
||||
Matrix4 Transform;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -51,7 +58,17 @@ namespace Nuake
|
||||
return *mGBuffer;
|
||||
}
|
||||
|
||||
bool IsTempModelLoaded(const std::string& name) const
|
||||
{
|
||||
return mTempModels.find(name) != mTempModels.end();
|
||||
}
|
||||
|
||||
void DrawTemporaryModel(const std::string& name, Ref<Model> model, Matrix4 transform);
|
||||
void DrawDebugLine(const Vector3& start, const Vector3& end, const Color& color = Color(1, 0, 0, 1), float life = 0.0f);
|
||||
void ClearTemporaryModels()
|
||||
{
|
||||
mTempModels.clear();
|
||||
}
|
||||
|
||||
uint32_t mOutlineEntityID = 0;
|
||||
private:
|
||||
@@ -68,6 +85,8 @@ namespace Nuake
|
||||
|
||||
Ref<Mesh> mLineMesh;
|
||||
|
||||
|
||||
std::map<std::string, TemporaryModels> mTempModels;
|
||||
std::vector<DebugLine> mDebugLines;
|
||||
|
||||
void ShadowPass(Scene& scene);
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Nuake
|
||||
LoadEmbeddedShader(Resources_Shaders_vignette_shader);
|
||||
LoadEmbeddedShader(Resources_Shaders_volumetric_shader);
|
||||
LoadEmbeddedShader(Resources_Shaders_debugLine_shader);
|
||||
LoadEmbeddedShader(Resources_Shaders_add_shader);
|
||||
}
|
||||
|
||||
Shader* ShaderManager::GetShader(const std::string& path)
|
||||
|
||||
@@ -267186,6 +267186,60 @@ const std::string Resources_Scripts_ScriptableEntity_wren_path = R"(Resources/Sc
|
||||
};
|
||||
unsigned int Resources_Scripts_ScriptableEntity_wren_len = 322;
|
||||
|
||||
// Data for file: Resources_Shaders_add_shader_path
|
||||
const std::string Resources_Shaders_add_shader_path = R"(Resources/Shaders/add.shader)";
|
||||
unsigned char Resources_Shaders_add_shader[] = {
|
||||
0x23, 0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x76, 0x65, 0x72, 0x74,
|
||||
0x65, 0x78, 0x0d, 0x0a, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x34, 0x34, 0x30, 0x20, 0x63, 0x6f, 0x72, 0x65, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x69, 0x6e,
|
||||
0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78,
|
||||
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0d, 0x0a, 0x6c,
|
||||
0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x31, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76,
|
||||
0x65, 0x63, 0x32, 0x20, 0x55, 0x56, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x3b, 0x0d, 0x0a, 0x0d, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x66,
|
||||
0x6c, 0x61, 0x74, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x55, 0x56, 0x3b,
|
||||
0x0d, 0x0a, 0x0d, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x28, 0x29, 0x0d, 0x0a, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
|
||||
0x55, 0x56, 0x20, 0x3d, 0x20, 0x55, 0x56, 0x50, 0x6f, 0x73, 0x69, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x67, 0x6c,
|
||||
0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20,
|
||||
0x76, 0x65, 0x63, 0x34, 0x28, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x50,
|
||||
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x31, 0x2e, 0x30,
|
||||
0x66, 0x29, 0x3b, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x73,
|
||||
0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65,
|
||||
0x6e, 0x74, 0x0d, 0x0a, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x34, 0x34, 0x30, 0x20, 0x63, 0x6f, 0x72, 0x65, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d,
|
||||
0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x75, 0x5f, 0x53, 0x6f, 0x75,
|
||||
0x72, 0x63, 0x65, 0x3b, 0x0d, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72,
|
||||
0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20,
|
||||
0x75, 0x5f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x32, 0x3b, 0x0d, 0x0a,
|
||||
0x0d, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x55, 0x56,
|
||||
0x3b, 0x0d, 0x0a, 0x0d, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63,
|
||||
0x34, 0x20, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b,
|
||||
0x0d, 0x0a, 0x0d, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x28, 0x29, 0x0d, 0x0a, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
|
||||
0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78,
|
||||
0x74, 0x75, 0x72, 0x65, 0x28, 0x75, 0x5f, 0x53, 0x6f, 0x75, 0x72, 0x63,
|
||||
0x65, 0x2c, 0x20, 0x55, 0x56, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20,
|
||||
0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x62, 0x20, 0x3d, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x75, 0x5f, 0x53, 0x6f, 0x75, 0x72,
|
||||
0x63, 0x65, 0x32, 0x2c, 0x20, 0x55, 0x56, 0x29, 0x3b, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6c,
|
||||
0x75, 0x6d, 0x69, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x6d,
|
||||
0x61, 0x78, 0x28, 0x62, 0x2e, 0x72, 0x2c, 0x20, 0x6d, 0x61, 0x78, 0x28,
|
||||
0x62, 0x2e, 0x67, 0x2c, 0x20, 0x62, 0x2e, 0x62, 0x29, 0x29, 0x3b, 0x0d,
|
||||
0x0a, 0x20, 0x20, 0x20, 0x20, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x6d, 0x69,
|
||||
0x78, 0x28, 0x61, 0x2e, 0x72, 0x67, 0x62, 0x2c, 0x20, 0x62, 0x2e, 0x72,
|
||||
0x67, 0x62, 0x2c, 0x20, 0x6c, 0x75, 0x6d, 0x69, 0x6e, 0x61, 0x6e, 0x63,
|
||||
0x65, 0x29, 0x2c, 0x20, 0x61, 0x2e, 0x61, 0x29, 0x3b, 0x0d, 0x0a, 0x7d
|
||||
};
|
||||
unsigned int Resources_Shaders_add_shader_len = 576;
|
||||
|
||||
// Data for file: Resources_Shaders_atmospheric_sky_shader_path
|
||||
const std::string Resources_Shaders_atmospheric_sky_shader_path = R"(Resources/Shaders/atmospheric_sky.shader)";
|
||||
unsigned char Resources_Shaders_atmospheric_sky_shader[] = {
|
||||
@@ -271622,7 +271676,7 @@ const std::string Resources_Shaders_outline_shader_path = R"(Resources/Shaders/o
|
||||
0x74, 0x68, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e,
|
||||
0x64, 0x0d, 0x0a, 0x09, 0x09, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x61,
|
||||
0x6c, 0x70, 0x68, 0x61, 0x20, 0x3d, 0x20, 0x73, 0x6d, 0x6f, 0x6f, 0x74,
|
||||
0x68, 0x73, 0x74, 0x65, 0x70, 0x28, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x30,
|
||||
0x68, 0x73, 0x74, 0x65, 0x70, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30,
|
||||
0x2e, 0x39, 0x2c, 0x20, 0x69, 0x6e, 0x74, 0x28, 0x63, 0x6f, 0x6c, 0x20,
|
||||
0x21, 0x3d, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x29, 0x20, 0x2a,
|
||||
0x20, 0x68, 0x61, 0x73, 0x48, 0x69, 0x74, 0x20, 0x2a, 0x20, 0x31, 0x30,
|
||||
|
||||
@@ -129,6 +129,9 @@ extern unsigned char Resources_Scripts_Scene_wren[];
|
||||
extern const std::string Resources_Scripts_ScriptableEntity_wren_path;
|
||||
extern unsigned int Resources_Scripts_ScriptableEntity_wren_len;
|
||||
extern unsigned char Resources_Scripts_ScriptableEntity_wren[];
|
||||
extern const std::string Resources_Shaders_add_shader_path;
|
||||
extern unsigned int Resources_Shaders_add_shader_len;
|
||||
extern unsigned char Resources_Shaders_add_shader[];
|
||||
extern const std::string Resources_Shaders_atmospheric_sky_shader_path;
|
||||
extern unsigned int Resources_Shaders_atmospheric_sky_shader_len;
|
||||
extern unsigned char Resources_Shaders_atmospheric_sky_shader[];
|
||||
|
||||
32
Resources/Shaders/add.shader
Normal file
32
Resources/Shaders/add.shader
Normal file
@@ -0,0 +1,32 @@
|
||||
#shader vertex
|
||||
#version 440 core
|
||||
|
||||
layout(location = 0) in vec3 VertexPosition;
|
||||
layout(location = 1) in vec2 UVPosition;
|
||||
|
||||
out flat vec2 UV;
|
||||
|
||||
void main()
|
||||
{
|
||||
UV = UVPosition;
|
||||
gl_Position = vec4(VertexPosition, 1.0f);
|
||||
}
|
||||
|
||||
#shader fragment
|
||||
#version 440 core
|
||||
|
||||
uniform sampler2D u_Source;
|
||||
uniform sampler2D u_Source2;
|
||||
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 a = texture(u_Source, UV);
|
||||
vec4 b = texture(u_Source2, UV);
|
||||
|
||||
float luminance = max(b.r, max(b.g, b.b));
|
||||
FragColor = vec4(mix(a.rgb, b.rgb, luminance), a.a);
|
||||
}
|
||||
Reference in New Issue
Block a user