Entity positions.

This commit is contained in:
2025-03-02 12:57:20 -06:00
parent 6c3305be10
commit c8abdcb82e
16 changed files with 175 additions and 31 deletions

View File

@ -1,16 +0,0 @@
// Copyright (c) 2025 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "../fragments/quad.glsl"
#include "../../../../dusk/overworld/overworlddefs.h"
struct Entity {
vec2 position;
};
layout(std140) uniform b_Entities {
Entity entities[OVERWORLD_ENTITY_COUNT_MAX];
uint entityCount;
};

View File

@ -4,7 +4,7 @@
// https://opensource.org/licenses/MIT
#include "../fragments/header.glsl"
#include "entity.glsl"
#include "../data/entities.glsl"
// Inputs from vertex shader
in vec2 v_TextureCoord;

View File

@ -4,9 +4,8 @@
// https://opensource.org/licenses/MIT
#include "../fragments/header.glsl"
#include "../fragments/transforms.glsl"
#include "../fragments/quad.glsl"
#include "entity.glsl"
#include "../data/transforms.glsl"
#include "../data/entities.glsl"
// Outputs to fragment shader
out vec2 v_TextureCoord;
@ -15,7 +14,7 @@ void main() {
uint instanceIndex = uint(gl_InstanceID);
uint indiceIndex = uint(gl_VertexID % 6);
vec2 vert = quadGetVertice(indiceIndex);
vec2 vert = entityGetVertice(instanceIndex, indiceIndex);
vec2 uv = quadGetTextureCoordinate(indiceIndex);
gl_Position = transforms.projection * transforms.view * vec4(vert, 0.0, 1.0);

View File

@ -11,6 +11,7 @@
#include "entity_vert.glsl.h"
#include "entity_frag.glsl.h"
#include "display/shader/data/transforms.h"
#include "display/shader/data/entities.h"
entityshader_t ENTITY_SHADER;
@ -29,10 +30,16 @@ void entityShaderInit() {
TRANSFORMS_BLOCK_NAME
);
ENTITY_SHADER.entitiesBlock = shaderGetBlock(
&ENTITY_SHADER.shader,
ENTITIES_BLOCK_NAME
);
// Uniforms
// Bind
shaderBufferBindToBlock(&TRANSFORMS_BUFFER, ENTITY_SHADER.transformsBlock);
shaderBufferBindToBlock(&ENTITIES_BUFFER, ENTITY_SHADER.entitiesBlock);
}
void entityShaderUse() {

View File

@ -10,12 +10,8 @@
typedef struct {
shader_t shader;
GLuint entitiesBlock;
GLuint transformsBlock;
// GLuint tilesetsBlock;
// GLuint uniformTilesetTextures;
} entityshader_t;
extern entityshader_t ENTITY_SHADER;