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
69 changes: 68 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
Nothing should be ignored based on the provided file changes. The only modified file is README.md, which is a source/config file and should not be added to .gitignore.
```
# Compiled and build artifacts
*.o
*.obj
*.exe
*.dll
*.so
*.a
*.out
build/
dist/
target/

# Dependencies
node_modules/
venv/
.venv/
__pycache__/
.mypy_cache/
.pytest_cache/
.gradle/
julia-*/
zig*/

# Editors and IDEs
.vscode/
.idea/
*.swp
*.swo
*.tmp

# System files
.DS_Store
Thumbs.db
.env
.env.local
*.env.*

# Logs and coverage
*.log
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
```
Comment on lines +1 to +68
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.

medium

The .gitignore file contains markdown code block backticks (```) at the beginning and end. These are not valid syntax for a .gitignore file and will cause git to misinterpret the entries or ignore the file entirely.

20 changes: 20 additions & 0 deletions FarmEngine/assets/shaders/sprite.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#version 450

// Fragment shader básico para sprites 2D
layout(location = 0) in vec2 fragTexCoord;
layout(location = 1) in vec4 fragColor;

layout(location = 0) out vec4 outColor;

layout(binding = 1) uniform sampler2D spriteTexture;

void main() {
vec4 texColor = texture(spriteTexture, fragTexCoord);

// Alpha test para recortes
if (texColor.a < 0.1) {
discard;
}

outColor = texColor * fragColor;
}
21 changes: 21 additions & 0 deletions FarmEngine/assets/shaders/sprite.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#version 450

// Vertex shader básico para sprites 2D
layout(location = 0) in vec2 inPosition;
layout(location = 1) in vec2 inTexCoord;
layout(location = 2) in vec4 inColor;

layout(location = 0) out vec2 fragTexCoord;
layout(location = 1) out vec4 fragColor;

layout(binding = 0) uniform MVP {
mat4 model;
mat4 view;
mat4 projection;
};

void main() {
gl_Position = projection * view * model * vec4(inPosition, 0.0, 1.0);
fragTexCoord = inTexCoord;
fragColor = inColor;
}
68 changes: 68 additions & 0 deletions FarmEngine/assets/shaders/terrain.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#version 450

// Fragment shader para terreno 3D con PBR básico
layout(location = 0) in vec3 fragPosition;
layout(location = 1) in vec3 fragNormal;
layout(location = 2) in vec2 fragTexCoord;
layout(location = 3) in mat4 fragTBN;

layout(location = 0) out vec4 outColor;

layout(binding = 1) uniform sampler2D albedoMap;
layout(binding = 2) uniform sampler2D normalMap;
layout(binding = 3) uniform sampler2D roughnessMap;
layout(binding = 4) uniform sampler2D metalnessMap;

layout(binding = 5) uniform LightData {
vec3 position;
vec3 color;
float intensity;
vec3 ambientColor;
float ambientIntensity;
};

// PBR helper functions
vec3 getNormalFromMap() {
vec3 tangentNormal = texture(normalMap, fragTexCoord).xyz * 2.0 - 1.0;
return normalize(fragTBN * vec4(tangentNormal, 0.0)).xyz;
}

float calculateShadow(vec3 lightDir) {
// Simplified shadow calculation
return 1.0;
}

void main() {
// Albedo
vec3 albedo = texture(albedoMap, fragTexCoord).rgb;

// Normal
vec3 normal = getNormalFromMap();

// Material properties
float roughness = texture(roughnessMap, fragTexCoord).r;
float metalness = texture(metalnessMap, fragTexCoord).r;

// Lighting
vec3 lightDir = normalize(position - fragPosition);
vec3 viewDir = normalize(cameraPosition - fragPosition);
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 variable cameraPosition is used here but has not been declared in this fragment shader. In GLSL, all uniforms must be declared in every shader stage where they are accessed. You should declare it, likely within a uniform block matching the one in the vertex shader.

vec3 halfDir = normalize(lightDir + viewDir);
Comment on lines +46 to +49
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

4. Terrain shader missing uniform 🐞 Bug ≡ Correctness

terrain.frag.glsl uses cameraPosition but never declares it as a uniform/input, so the shader will
not compile. This blocks using the terrain shader for lighting calculations.
Agent Prompt
### Issue description
`terrain.frag.glsl` references `cameraPosition` but it is not declared in the fragment shader, so compilation fails.

### Issue Context
`cameraPosition` currently exists only in the vertex shader’s `UniformBuffer` block.

### Fix Focus Areas
- FarmEngine/assets/shaders/terrain.frag.glsl[35-49]
- FarmEngine/assets/shaders/terrain.vert.glsl[14-20]

### What to change
- Add a matching uniform block in the fragment shader that contains `cameraPosition` (same set/binding/layout as the vertex stage), **or** pass `cameraPosition` (or `viewDir`) from vertex to fragment as an interpolant.
- Keep bindings consistent across stages to match Vulkan descriptor set layout.

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


// Diffuse (Lambert)
float NdotL = max(dot(normal, lightDir), 0.0);
vec3 diffuse = albedo * NdotL;

// Specular (Blinn-Phong simplificado)
float NdotH = max(dot(normal, halfDir), 0.0);
float specPow = pow(2.0, (1.0 - roughness) * 10.0);
vec3 specular = vec3(pow(NdotH, specPow)) * metalness;

// Shadow
float shadow = calculateShadow(lightDir);

// Final lighting
vec3 lighting = (diffuse + specular) * color * intensity * shadow;
lighting += albedo * ambientColor * ambientIntensity;

outColor = vec4(lighting, 1.0);
}
36 changes: 36 additions & 0 deletions FarmEngine/assets/shaders/terrain.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#version 450

// Vertex shader para terreno 3D
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec2 inTexCoord;
layout(location = 3) in vec4 inTangent;

layout(location = 0) out vec3 fragPosition;
layout(location = 1) out vec3 fragNormal;
layout(location = 2) out vec2 fragTexCoord;
layout(location = 3) out mat4 fragTBN;

layout(binding = 0) uniform UniformBuffer {
mat4 model;
mat4 view;
mat4 projection;
vec3 cameraPosition;
float time;
};

void main() {
vec4 worldPos = model * vec4(inPosition, 1.0);
fragPosition = worldPos.xyz;

// Normal mapping
vec3 normal = normalize(mat3(model) * inNormal);
vec3 tangent = normalize(mat3(model) * inTangent.xyz);
vec3 bitangent = cross(normal, tangent) * inTangent.w;
fragTBN = mat4(tangent, bitangent, normal, vec4(0, 0, 0, 1));

fragNormal = normal;
fragTexCoord = inTexCoord;

gl_Position = projection * view * worldPos;
}
47 changes: 47 additions & 0 deletions FarmEngine/core/ecs/ECS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "ECS.h"

namespace FarmEngine {

ECS::ECS() {
entities.reserve(MAX_ENTITIES);
}

ECS::~ECS() = default;

EntityID ECS::createEntity() {
EntityID id;

if (!availableIDs.empty()) {
id = availableIDs.back();
availableIDs.pop_back();
entities[id].active = true;
} else {
id = static_cast<EntityID>(entities.size());
entities.emplace_back(id);
}

return id;
}

void ECS::destroyEntity(EntityID entity) {
if (entity >= entities.size()) return;

entities[entity].active = false;
entities[entity].mask.reset();

// Limpiar componentes
for (auto& componentList : components) {
if (componentList.second && entity < componentList.second->size()) {
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

In C++, std::vector does not have an implicit conversion to bool. The check if (componentList.second) will cause a compilation error. If you intended to check if the vector is not empty, use !componentList.second.empty(), though given the logic in addComponent, you might just need to check if the element at entity index is not null.

(*componentList.second)[entity].reset();
}
}

availableIDs.push_back(entity);
}

void ECS::update(float deltaTime) {
// Actualizar sistemas basados en ECS
(void)deltaTime;
}

} // namespace FarmEngine
Loading