This commit is contained in:
2026-10-18 13:02:29 -04:00
parent ac982a2b21
commit a65e3d4f24
5 changed files with 7 additions and 10 deletions
+2 -5
View File
@@ -48,11 +48,6 @@ Character::Character() {
void Character::Render(Shader& shader) { void Character::Render(Shader& shader) {
if (!body || !body->rig || !body->animator) return; if (!body || !body->rig || !body->animator) return;
if (skin) {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, skin->ID);
shader.SetInt("tex", 1);
}
if (body->animator->m_CurrentAnimation == nullptr) { if (body->animator->m_CurrentAnimation == nullptr) {
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), glm::mat4(1.0f)); shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), glm::mat4(1.0f));
@@ -63,7 +58,9 @@ void Character::Render(Shader& shader) {
for (int i = 0; i < transforms.size(); i++) for (int i = 0; i < transforms.size(); i++)
shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), transforms[i]); shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), transforms[i]);
} }
shader.Set4F("colorOverride", colorOverride);
// body->t's scale is the hitbox only; the rig is drawn at visualScale so it fills that hitbox // body->t's scale is the hitbox only; the rig is drawn at visualScale so it fills that hitbox
body->rig->Render(shader, body->t.GetTranslationMatrix() * body->t.GetRotationMatrix() body->rig->Render(shader, body->t.GetTranslationMatrix() * body->t.GetRotationMatrix()
* glm::scale(glm::mat4(1.0f), glm::vec3(visualScale))); * glm::scale(glm::mat4(1.0f), glm::vec3(visualScale)));
shader.Set4F("colorOverride", glm::vec4(0.0f)); // don't leak into other rig draws
} }
+1 -2
View File
@@ -8,7 +8,6 @@
#include "Rig.h" #include "Rig.h"
#include "Object.h" #include "Object.h"
#include "Animator.h" #include "Animator.h"
#include "texture.h"
class CharacterBody; class CharacterBody;
class BodyComponent; class BodyComponent;
@@ -117,8 +116,8 @@ class Character : public Object, public Renderable {
public: public:
CharacterMind* mind = nullptr; CharacterMind* mind = nullptr;
CharacterBody* body = nullptr; CharacterBody* body = nullptr;
glm::vec4 colorOverride = glm::vec4(0.0f); // rgb + strength (0 = keep the rig's own texture)
float visualScale = 1.4f; // rig is ~1.8 tall natively; hitbox is 2.5 float visualScale = 1.4f; // rig is ~1.8 tall natively; hitbox is 2.5
Texture* skin = nullptr; // optional: bound while drawing the rig
Character(); Character();
void Render(Shader& shader) override; void Render(Shader& shader) override;
+1 -3
View File
@@ -130,7 +130,6 @@ void Engine::Initiate()
Texture* blanktex = new Texture("assets/blanktexture.png"); Texture* blanktex = new Texture("assets/blanktexture.png");
Texture* magic = new Texture("assets/itsmagicbitch.jpg"); Texture* magic = new Texture("assets/itsmagicbitch.jpg");
Texture* snowflake = new Texture("assets/snowflake.png"); Texture* snowflake = new Texture("assets/snowflake.png");
Texture* bluetex = new Texture("assets/bluetexture.png");
Texture* shockwavetex = new Texture("assets/shockwave.png"); Texture* shockwavetex = new Texture("assets/shockwave.png");
Texture* leontex = new Texture("assets/revolvertex.png"); Texture* leontex = new Texture("assets/revolvertex.png");
@@ -146,7 +145,6 @@ void Engine::Initiate()
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
Character* testcharacter = new Character(); Character* testcharacter = new Character();
testcharacter->name = "character"; testcharacter->name = "character";
testcharacter->skin = bluetex;
testcharacter->castshadow = true; testcharacter->castshadow = true;
testcharacter->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f }); testcharacter->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f });
testcharacter->body->t.TranslateTo({ 0.0f, 10.0f, 0.0f }); testcharacter->body->t.TranslateTo({ 0.0f, 10.0f, 0.0f });
@@ -200,7 +198,7 @@ void Engine::Initiate()
auto SpawnRemote = [&]() -> Character* { auto SpawnRemote = [&]() -> Character* {
Character* c = new Character(); Character* c = new Character();
c->name = "remote"; c->name = "remote";
c->skin = bluetex; c->colorOverride = glm::vec4(0.1f, 0.3f, 1.0f, 1.0f); // blue
c->castshadow = true; c->castshadow = true;
c->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f }); c->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f });
c->body->SetRig(testrig); c->body->SetRig(testrig);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 B

+3
View File
@@ -39,6 +39,7 @@ uniform vec3 viewPos;
uniform sampler2DShadow shadowMap; uniform sampler2DShadow shadowMap;
uniform sampler2D tex; uniform sampler2D tex;
uniform vec4 colorOverride = vec4(0.0); // rgb replaces the texture colour when w > 0
float ShadowCalculation(vec4 fragposlightspace) float ShadowCalculation(vec4 fragposlightspace)
{ {
@@ -79,6 +80,8 @@ void main()
discard; discard;
} }
lightless.rgb = mix(lightless.rgb, colorOverride.rgb, colorOverride.w);
vec3 norm = normalize(normal); vec3 norm = normalize(normal);
vec3 viewDir = normalize(viewPos - FragPos); vec3 viewDir = normalize(viewPos - FragPos);