Weaather baseline

This commit is contained in:
2026-07-08 12:57:13 -05:00
parent ef284a15a1
commit 8cfa8ddfeb
+35 -21
View File
@@ -24,6 +24,8 @@
#include "asset/loader/assetloader.h" #include "asset/loader/assetloader.h"
#include "asset/loader/assetentry.h" #include "asset/loader/assetentry.h"
#include "util/memory.h"
errorret_t sceneOverworldInit(scenedata_t *sceneData) { errorret_t sceneOverworldInit(scenedata_t *sceneData) {
assertNotNull(sceneData, "Scene data cannot be null"); assertNotNull(sceneData, "Scene data cannot be null");
errorOk(); errorOk();
@@ -40,55 +42,67 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
sceneoverworld_t *overworld = &sceneData->overworld; sceneoverworld_t *overworld = &sceneData->overworld;
sceneOverworldCullUpdate(overworld); sceneOverworldCullUpdate(overworld);
errorChain(displaySetState((displaystate_t){
.flags = DISPLAY_STATE_FLAG_DEPTH_TEST | DISPLAY_STATE_FLAG_CULL // Overworld camera
}));
mat4 model;
errorChain(shaderBind(&SHADER_UNLIT)); errorChain(shaderBind(&SHADER_UNLIT));
errorChain(shaderSetMatrix(
&SHADER_UNLIT, SHADER_UNLIT_MODEL, SCENE.screenIdentity
));
// Model
glm_mat4_identity(model);
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, model));
// Camera projection
rpgCameraUpdateProjection(); rpgCameraUpdateProjection();
errorChain(shaderSetMatrix( errorChain(shaderSetMatrix(
&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, RPG_CAMERA.projection &SHADER_UNLIT, SHADER_UNLIT_PROJECTION, RPG_CAMERA.projection
)); ));
// Camera Eye
rpgCameraUpdateEye(); rpgCameraUpdateEye();
errorChain(shaderSetMatrix( errorChain(shaderSetMatrix(
&SHADER_UNLIT, SHADER_UNLIT_VIEW, RPG_CAMERA.eye &SHADER_UNLIT, SHADER_UNLIT_VIEW, RPG_CAMERA.eye
)); ));
// Base terrain meshes, drawn with normal depth testing. // Chunk tiles
errorChain(displaySetState((displaystate_t){
.flags = DISPLAY_STATE_FLAG_DEPTH_TEST | DISPLAY_STATE_FLAG_CULL
}));
errorChain(sceneOverworldDrawChunksBase(overworld)); errorChain(sceneOverworldDrawChunksBase(overworld));
// Entities are drawn with depth testing fully disabled so sloped tiles // Entities
// (ramps) never clip them; entity-vs-entity overlap falls back to
// array draw order instead of true depth.
errorChain(displaySetState((displaystate_t){ errorChain(displaySetState((displaystate_t){
.flags = DISPLAY_STATE_FLAG_CULL .flags = DISPLAY_STATE_FLAG_CULL
})); }));
// Entities
for(uint8_t i = 0; i < ENTITY_COUNT; i++) { for(uint8_t i = 0; i < ENTITY_COUNT; i++) {
entity_t *ent = &ENTITIES[i]; entity_t *ent = &ENTITIES[i];
if(ent->type == ENTITY_TYPE_NULL) continue; if(ent->type == ENTITY_TYPE_NULL) continue;
errorChain(sceneOverworldDrawEntity(overworld, ent)); errorChain(sceneOverworldDrawEntity(overworld, ent));
} }
// Other chunk meshes (trees, buildings, etc), drawn last with normal // Chunk props
// depth testing so they correctly occlude entities standing beneath
// them.
errorChain(displaySetState((displaystate_t){ errorChain(displaySetState((displaystate_t){
.flags = DISPLAY_STATE_FLAG_DEPTH_TEST | DISPLAY_STATE_FLAG_CULL .flags = DISPLAY_STATE_FLAG_DEPTH_TEST | DISPLAY_STATE_FLAG_CULL
})); }));
errorChain(sceneOverworldDrawChunksProps(overworld)); errorChain(sceneOverworldDrawChunksProps(overworld));
// Weather effects
// errorChain(shaderSetMatrix(
// &SHADER_UNLIT, SHADER_UNLIT_PROJECTION, SCENE.screenProj
// ));
// errorChain(shaderSetMatrix(
// &SHADER_UNLIT, SHADER_UNLIT_VIEW, SCENE.screenView
// ));
// errorChain(displaySetState((displaystate_t){
// .flags = DISPLAY_STATE_FLAG_BLEND
// }));
// spritebatchsprite_t skyboxSprite;
// memoryZero(&skyboxSprite, sizeof(spritebatchsprite_t));
// skyboxSprite.max[0] = (float_t)(SCREEN.width / SCREEN.scaleUi);
// skyboxSprite.max[1] = (float_t)(SCREEN.height / SCREEN.scaleUi);
// shadermaterial_t skyboxMaterial = {
// .unlit = { .color = color(0xFF, 0x00, 0x00, 0xFF/2), .texture = NULL }
// };
// errorChain(spriteBatchBuffer(&skyboxSprite, 1, &SHADER_UNLIT, skyboxMaterial));
// errorChain(spriteBatchFlush());
errorOk(); errorOk();
} }