deferred rendering can be enabled for certain meshes
This commit is contained in:
parent
13f67a7cdb
commit
79b68fbff1
@ -82,6 +82,8 @@ public:
|
||||
auto& render3d = selected.GetComponent<Render3DComponent>();
|
||||
if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color));
|
||||
|
||||
ImGui::Checkbox("Use static rendering:", &render3d.isStatic);
|
||||
}
|
||||
}
|
||||
static bool deferred = true;
|
||||
|
@ -81,14 +81,12 @@ public:
|
||||
const float sensitivity = 0.1;
|
||||
static bool firstMouse = true;
|
||||
|
||||
if (MouseButtonPressed(YOGGIE_MOUSE_BUTTON_RIGHT) ){
|
||||
|
||||
if (MouseButtonPressed(YOGGIE_MOUSE_BUTTON_MIDDLE) ){
|
||||
|
||||
|
||||
glfwSetInputMode(AppWindow.GetGLFWHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
auto newX = getCursorPosX(&AppWindow);
|
||||
auto newY = getCursorPosY(&AppWindow);
|
||||
|
||||
|
||||
if (firstMouse)
|
||||
{
|
||||
lastX = newX;
|
||||
@ -115,31 +113,25 @@ public:
|
||||
cam.pitch = -89.0f;
|
||||
|
||||
}
|
||||
|
||||
else if (firstMouse == false)
|
||||
{
|
||||
glfwSetInputMode(AppWindow.GetGLFWHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
firstMouse = true;
|
||||
}
|
||||
|
||||
// Check for Camara movement input here!
|
||||
if (keyIsPressed(YOGGIE_KEY_W)) {
|
||||
if (keyIsPressed(YOGGIE_KEY_W))
|
||||
cam.Position += cam.Front * movement_speed;
|
||||
}
|
||||
|
||||
if (keyIsPressed(YOGGIE_KEY_A))
|
||||
{
|
||||
cam.Position -= cam.Right * movement_speed;
|
||||
|
||||
}
|
||||
|
||||
if (keyIsPressed(YOGGIE_KEY_S)) {
|
||||
if (keyIsPressed(YOGGIE_KEY_S))
|
||||
cam.Position -= cam.Front * movement_speed;
|
||||
|
||||
}
|
||||
|
||||
if (keyIsPressed(YOGGIE_KEY_D)) {
|
||||
if (keyIsPressed(YOGGIE_KEY_D))
|
||||
cam.Position += cam.Right * movement_speed;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,12 +2,14 @@
|
||||
#include "Scene/Components.h"
|
||||
namespace YoggieEngine {
|
||||
struct DrawCommand {
|
||||
bool isDynamic;
|
||||
unsigned int VAO_identifier;
|
||||
unsigned int num_elements;
|
||||
unsigned int IBO_identifier;
|
||||
TransformComponent& transform;
|
||||
Shader& shader;
|
||||
glm::vec3& color;
|
||||
|
||||
|
||||
// Material
|
||||
};
|
||||
};
|
||||
|
@ -21,7 +21,6 @@ std::vector<glm::vec3> vegetation = {
|
||||
unsigned int transparentVAO, transparentVBO;
|
||||
Texture grassTexture;
|
||||
|
||||
|
||||
float skyboxVertices[]{
|
||||
// positions
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
@ -72,7 +71,8 @@ Renderer::Renderer(RendererConfig& config)
|
||||
gBufferShader("build/Debug/Shaders/deferred/geometry.vert", "build/Debug/Shaders/deferred/geometry.frag"),
|
||||
lightingPassShader("build/Debug/Shaders/deferred/lightPass.vert", "build/Debug/Shaders/deferred/lightPass.frag"),
|
||||
SkyboxShader("build/Debug/Shaders/Cubemaps/Skybox.vert", "build/Debug/Shaders/Cubemaps/Skybox.frag"),
|
||||
BlendingShader("build/Debug/Shaders/forward/Blending.vert", "build/Debug/Shaders/forward/Blending.frag")
|
||||
BlendingShader("build/Debug/Shaders/forward/Blending.vert", "build/Debug/Shaders/forward/Blending.frag"),
|
||||
forwardShader("build/Debug/Shaders/forward/geometry.vert", "build/Debug/Shaders/forward/geometry.frag")
|
||||
{
|
||||
width = config.ScreenWidth;
|
||||
height = config.ScreenHeight;
|
||||
@ -231,7 +231,7 @@ void Renderer::Submit( Render3DComponent& renderComponent, TransformComponent& t
|
||||
renderComponent.IBO = elementBuffer.getBufferID();
|
||||
}
|
||||
|
||||
DrawCommand dc = { renderComponent.VAO, renderComponent.mesh.elements.size(), renderComponent.IBO, transform, renderComponent.shader, renderComponent.color };
|
||||
DrawCommand dc = { renderComponent.isStatic , renderComponent.VAO, renderComponent.mesh.elements.size(), renderComponent.IBO, transform, renderComponent.color };
|
||||
commands.push_back(dc);
|
||||
|
||||
}
|
||||
@ -242,6 +242,9 @@ void Renderer::GeometryPass() {
|
||||
|
||||
for (const DrawCommand& command : commands)
|
||||
{
|
||||
if (command.isDynamic == true)
|
||||
continue;
|
||||
|
||||
glBindVertexArray(command.VAO_identifier);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, command.IBO_identifier);
|
||||
|
||||
@ -396,15 +399,18 @@ void Renderer::Render(Scene& scene)
|
||||
|
||||
for (const DrawCommand& command : commands)
|
||||
{
|
||||
if (command.isDynamic == false)
|
||||
continue;
|
||||
|
||||
glBindVertexArray(command.VAO_identifier);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, command.IBO_identifier);
|
||||
|
||||
command.shader.Use();
|
||||
forwardShader.Use();
|
||||
|
||||
command.shader.setUniformVec3("Color", command.color);
|
||||
command.shader.setUniformMat4("M", command.transform.LocalTransform);
|
||||
command.shader.setUniformMat4("V", cam.ViewMatrix);
|
||||
command.shader.setUniformMat4("P", cam.ProjectionMatrix);
|
||||
forwardShader.setUniformVec3("Color", command.color);
|
||||
forwardShader.setUniformMat4("M", command.transform.LocalTransform);
|
||||
forwardShader.setUniformMat4("V", cam.ViewMatrix);
|
||||
forwardShader.setUniformMat4("P", cam.ProjectionMatrix);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(command.num_elements),
|
||||
GL_UNSIGNED_INT, NULL);
|
||||
|
@ -50,6 +50,8 @@ namespace YoggieEngine {
|
||||
unsigned int skyboxVAO = 0;
|
||||
CubeMap sky;
|
||||
|
||||
Shader forwardShader;
|
||||
|
||||
// deferred rending parameters
|
||||
unsigned int gBuffer, gPosition, gNormal, gColorSpec, gDepth;
|
||||
Shader lightingPassShader;
|
||||
|
@ -48,11 +48,10 @@ namespace YoggieEngine {
|
||||
Mesh mesh;
|
||||
// TODO: becomes a material
|
||||
glm::vec3 color;
|
||||
Shader shader;
|
||||
bool isStatic;
|
||||
|
||||
Render3DComponent()
|
||||
: shader(Shader("build/Debug/Shaders/forward/geometry.vert", "build/Debug/Shaders/forward/geometry.frag")),
|
||||
color(glm::vec3(1.0f, 0.0f, 0.0f))
|
||||
: color(glm::vec3(1.0f, 0.0f, 0.0f)) , isStatic(true)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user