Skip to content

Commit

Permalink
reset world2d shader and render_entity
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzzhHe committed Jan 20, 2025
1 parent 3dc759f commit 64620ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 43 deletions.
12 changes: 10 additions & 2 deletions assets/shaders/world2d.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ void main() {

// do not save the ID
return;
//@INSERT_COMMANDS@
case 254:
col = vec4(1.0f, 0.0f, 0.0f, 1.0f);
break;
case 252:
col = vec4(0.0f, 1.0f, 0.0f, 1.0f);
break;
case 250:
col = vec4(0.0f, 0.0f, 1.0f, 1.0f);
break;
default:
col = tex_val;
break;
}
id = u_id;
}
}
30 changes: 3 additions & 27 deletions libopenage/renderer/stages/world/render_stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,12 @@ void WorldRenderStage::initialize_render_pass(size_t width,
vert_shader_file.read());
vert_shader_file.close();

// Initialize shader command system before loading fragment shader
this->shader_commands = std::make_unique<WorldShaderCommands>();
this->init_shader_commands();

auto frag_shader_file = (shaderdir / "world2d.frag.glsl").open();
auto base_shader = frag_shader_file.read();
frag_shader_file.close();

auto frag_shader_src = renderer::resources::ShaderSource(
resources::shader_lang_t::glsl,
resources::shader_stage_t::fragment,
this->shader_commands->integrate_command(base_shader));
frag_shader_file.read());
frag_shader_file.close();

this->output_texture = renderer->add_texture(resources::Texture2dInfo(width, height, resources::pixel_format::rgba8));
this->depth_texture = renderer->add_texture(resources::Texture2dInfo(width, height, resources::pixel_format::depth24));
Expand All @@ -162,22 +156,4 @@ void WorldRenderStage::init_uniform_ids() {
WorldObject::anchor_offset = this->display_shader->get_uniform_id("anchor_offset");
}

void WorldRenderStage::init_shader_commands() {
// Register default shader commands
this->shader_commands->add_command(
254,
"col = vec4(1.0f, 0.0f, 0.0f, 1.0f);",
"Red tint command");
this->shader_commands->add_command(
252,
"col = vec4(0.0f, 1.0f, 0.0f, 1.0f);",
"Green tint command");
this->shader_commands->add_command(
250,
"col = vec4(0.0f, 0.0f, 1.0f, 1.0f);",
"Blue tint command");

// Additional commands can be added here
}

} // namespace openage::renderer::world
} // namespace openage::renderer::world
15 changes: 1 addition & 14 deletions libopenage/renderer/stages/world/render_stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <vector>

#include "util/path.h"
#include "world_shader_commands.h"

namespace openage {

Expand Down Expand Up @@ -112,12 +111,6 @@ class WorldRenderStage {
*/
void init_uniform_ids();

/**
* Initialize the shader command system and register default commands.
* This must be called before initializing the shader program.
*/
void init_shader_commands();

/**
* Reference to the openage renderer.
*/
Expand Down Expand Up @@ -181,13 +174,7 @@ class WorldRenderStage {
* Mutex for protecting threaded access.
*/
std::shared_mutex mutex;

/**
* Shader command system for the world fragment shader.
* Manages custom rendering behaviors through alpha channel commands.
*/
std::unique_ptr<WorldShaderCommands> shader_commands;
};
} // namespace world
} // namespace renderer
} // namespace openage
} // namespace openage

0 comments on commit 64620ae

Please sign in to comment.