Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 25 additions & 43 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,69 +1,51 @@
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The .gitignore file contains markdown code block delimiters (```) at the beginning and end of the file. These should be removed as they are not valid gitignore syntax and were likely included by mistake during code generation.

# Compiled and build artifacts
# Build artifacts
*.o
*.obj
*.exe
*.a
*.lib
*.dll
*.so
*.a
*.dylib
*.exe
*.out

# Dependencies
venv/
.venv/
__pycache__/
.mypy_cache/
.pytest_cache/
node_modules/
dist/
# CMake build directories
build/
target/
.gradle/
cmake-build-*/
CMakeFiles/
CMakeCache.txt
Makefile
compile_commands.json

# Dependencies
vendor/
external/

# Logs and temp files
# Logs
*.log

# Temporary files
*.tmp
*.swp
*.temp

# Environment
.env
.env.local
*.env.*
.env.*

# Editors
.vscode/
.idea/

# System files
.DS_Store
Thumbs.db
*.swp
*.swo

# Coverage
coverage/
htmlcov/
.coverage

# Compressed files
*.zip
*.gz
*.tar
*.tgz
*.bz2
*.xz
*.7z
*.rar
*.zst
*.lz4
*.lzh
*.cab
*.arj
*.rpm
*.deb
*.Z
*.lz
*.lzo
*.tar.gz
*.tar.bz2
*.tar.xz
*.tar.zst
# OS
.DS_Store
Thumbs.db
```
5 changes: 5 additions & 0 deletions FarmEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ endif()
add_library(FarmEngineRenderer STATIC
renderer/Renderer.cpp
renderer/Renderer.h
# Render Graph System
rendering/graph/RenderGraph.h
rendering/graph/RenderGraph.cpp
rendering/graph/RenderPipeline.h
rendering/graph/RenderPipeline.cpp
)
Comment on lines 96 to 104
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Wrong cmake paths 🐞 Bug ≡ Correctness

FarmEngineRenderer lists new RenderGraph sources under rendering/graph/... but the added files are
under src/rendering/graph/..., so the build will fail when CMake can’t find the sources.
Agent Prompt
### Issue description
`FarmEngine/CMakeLists.txt` adds RenderGraph sources using paths that don’t match where the files were added in this PR (`FarmEngine/src/rendering/graph/...`). This breaks the build because CMake won’t find the referenced files.

### Issue Context
The new files are located under `FarmEngine/src/rendering/graph`, but CMake lists them under `rendering/graph`.

### Fix Focus Areas
- FarmEngine/CMakeLists.txt[96-104]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


target_include_directories(FarmEngineRenderer PUBLIC
Expand Down
189 changes: 189 additions & 0 deletions FarmEngine/src/rendering/graph/ExampleUsage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#pragma once

/**
* @file ExampleUsage.h
* @brief Ejemplos de uso del Render Graph para diferentes casos del FarmEngine
*/

#include "RenderGraph.h"
#include "RenderPipeline.h"

namespace FarmEngine::Render::Examples {

/**
* @brief Ejemplo: Pipeline completo para rendering de chunks de terreno
*
* Este es el caso de uso principal para FarmEngine - renderizar chunks
* voxel con iluminación dinámica y oclusión ambiental.
*/
inline void ChunkRenderingExample(RenderGraph& graph, VkExtent2D swapchainExtent) {
RenderGraphBuilder builder;

// 1. Recursos principales
builder.addColorTarget("SceneColor", VK_FORMAT_R16G16B16A16_SFLOAT, swapchainExtent, ResourceLifetime::Frame);
builder.addDepthTarget("SceneDepth", VK_FORMAT_D32_SFLOAT, swapchainExtent, ResourceLifetime::Frame);

// 2. Geometry Pass - Renderiza todos los chunks visibles
builder.addPass("ChunkGeometry", [](RenderPass& pass) {
pass.colorAttachments.push_back("SceneColor");
pass.depthAttachment = "SceneDepth";
pass.clearColor = true;
pass.clearDepth = true;
pass.clearColorValue = {{0.4f, 0.6f, 0.9f, 1.0f}}; // Sky blue

// Callback que se ejecutará durante el render pass
pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// Aquí se integrarían con ChunkManager::getVisibleChunks()
// for (auto* chunk : visibleChunks) {
// chunk->renderOpaque(cmd);
// }
};
});

// 3. Transparency Pass - Plantas, agua, partículas
builder.addPass("Transparency", [](RenderPass& pass) {
pass.colorAttachments.push_back("SceneColor");
pass.depthAttachment = "SceneDepth";
pass.colorLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; // Preserve previous pass
pass.depthLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;

pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// Render transparent crops, water, animals
};
});

// 4. Post-Processing - Tonemapping a swapchain
builder.addPass("Tonemapping", [](RenderPass& pass) {
pass.inputAttachments = {"SceneColor"};
pass.colorAttachments.push_back("Swapchain"); // External
pass.clearColor = false;

pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// ACES tonemapping + gamma correction
};
});

graph.compile(std::move(builder));
}

/**
* @brief Ejemplo: Shadow mapping para iluminación dinámica
*
* Muestra cómo añadir un pass de shadow map antes del geometry pass
*/
inline void ShadowMappingExample(RenderGraph& graph, VkExtent2D extent) {
RenderGraphBuilder builder;

// Shadow map resource (alta resolución para calidad)
builder.addDepthTarget("ShadowMap", VK_FORMAT_D32_SFLOAT, {2048, 2048}, ResourceLifetime::Frame);

// Shadow pass - renderiza desde perspectiva de la luz
builder.addPass("ShadowPass", [](RenderPass& pass) {
pass.depthAttachment = "ShadowMap";
pass.clearDepth = true;
pass.clearDepthValue = {1.0f, 0};

pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// Bind shadow pipeline
// Set light view/projection matrices
// Render depth-only pass de chunks
};
});

// Main geometry pass que usa el shadow map
builder.addPass("MainGeometry", [](RenderPass& pass) {
pass.colorAttachments.push_back("SceneColor");
pass.depthAttachment = "SceneDepth";
pass.inputAttachments.push_back("ShadowMap"); // Para sampling en shader

pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// Fragment shader samplea ShadowMap para calcular oclusión
};
});

// Dependencia explícita: ShadowPass -> MainGeometry
builder.addDependency(
0, 1, // From pass 0 to pass 1
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
VK_ACCESS_SHADER_READ_BIT
);

graph.compile(std::move(builder));
}

/**
* @brief Ejemplo: SSAO (Screen Space Ambient Occlusion)
*
* Técnica post-process para oclusión ambiental en tiempo real
*/
inline void SSAOExample(RenderGraph& graph, VkExtent2D extent) {
RenderGraphBuilder builder;

// GBuffer básico
builder.addColorTarget("GBuffer_Albedo", VK_FORMAT_R8G8B8A8_UNORM, extent, ResourceLifetime::Frame);
builder.addColorTarget("GBuffer_Normals", VK_FORMAT_A2B10G10R10_UNORM_PACK32, extent, ResourceLifetime::Frame);
builder.addDepthTarget("SceneDepth", VK_FORMAT_D32_SFLOAT, extent, ResourceLifetime::Frame);

// SSAO buffer (half-res para performance)
builder.addColorTarget("SSAO_Buffer", VK_FORMAT_R8_UNORM, {extent.width / 2, extent.height / 2}, ResourceLifetime::Frame);

// 1. Geometry
builder.addPass("Geometry", [](RenderPass& pass) {
pass.colorAttachments = {"GBuffer_Albedo", "GBuffer_Normals"};
pass.depthAttachment = "SceneDepth";
// ... configurar callbacks
});

// 2. SSAO Pass
builder.addPass("SSAO", [](RenderPass& pass) {
pass.inputAttachments = {"GBuffer_Normals", "SceneDepth"};
pass.colorAttachments.push_back("SSAO_Buffer");
pass.clearColor = true;

pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// Full-screen quad con SSAO calculation
// Samplea normals + depth para calcular oclusión
};
});

// 3. Lighting con SSAO aplicado
builder.addPass("Lighting", [](RenderPass& pass) {
pass.inputAttachments = {"GBuffer_Albedo", "GBuffer_Normals", "SSAO_Buffer"};
pass.colorAttachments.push_back("FinalColor");

pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// Lighting calculation con SSAO factor
};
});

graph.compile(std::move(builder));
}

/**
* @brief Ejemplo: Minimizado para testing
*
* Pipeline más simple posible para validar integración
*/
inline void MinimalExample(RenderGraph& graph, VkExtent2D extent) {
RenderGraphBuilder builder;

builder.addColorTarget("Backbuffer", VK_FORMAT_B8G8R8A8_SRGB, extent, ResourceLifetime::External);
builder.addDepthTarget("Depth", VK_FORMAT_D32_SFLOAT, extent, ResourceLifetime::Frame);

builder.addPass("ClearAndDraw", [](RenderPass& pass) {
pass.colorAttachments.push_back("Backbuffer");
pass.depthAttachment = "Depth";
pass.clearColor = true;
pass.clearDepth = true;

pass.executeCallback = [](VkCommandBuffer cmd, const ResourceRegistry& registry) {
// Draw single triangle or quad
};
});

graph.compile(std::move(builder));
}

} // namespace FarmEngine::Render::Examples
Loading