mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-02-20 08:14:55 -05:00
Add unlit rendering for M2 glow/additive batches
Batches with the M2 unlit material flag (0x01) or additive blend modes (3+) now skip lighting, shadows, and fog, emitting texture color directly. Fixes lantern glow quads appearing as dull transparent circles.
This commit is contained in:
@@ -33,6 +33,7 @@ struct M2ModelGPU {
|
||||
bool hasAlpha = false;
|
||||
uint16_t textureAnimIndex = 0xFFFF; // 0xFFFF = no texture animation
|
||||
uint16_t blendMode = 0; // 0=Opaque, 1=AlphaKey, 2=Alpha, 3=Add, etc.
|
||||
uint16_t materialFlags = 0; // M2 material flags (0x01=Unlit, 0x04=TwoSided, 0x10=NoDepthWrite)
|
||||
};
|
||||
|
||||
GLuint vao = 0;
|
||||
|
||||
@@ -261,6 +261,7 @@ bool M2Renderer::initialize(pipeline::AssetManager* assets) {
|
||||
uniform sampler2D uTexture;
|
||||
uniform bool uHasTexture;
|
||||
uniform bool uAlphaTest;
|
||||
uniform bool uUnlit;
|
||||
uniform float uFadeAlpha;
|
||||
|
||||
uniform vec3 uFogColor;
|
||||
@@ -293,6 +294,12 @@ bool M2Renderer::initialize(pipeline::AssetManager* assets) {
|
||||
discard;
|
||||
}
|
||||
|
||||
// Unlit path: emit texture color directly (glow effects, emissive surfaces)
|
||||
if (uUnlit) {
|
||||
FragColor = vec4(texColor.rgb, finalAlpha);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 normal = normalize(Normal);
|
||||
vec3 lightDir = normalize(uLightDir);
|
||||
|
||||
@@ -729,9 +736,10 @@ bool M2Renderer::loadModel(const pipeline::M2Model& model, uint32_t modelId) {
|
||||
gpuModel.hasTextureAnimation = true;
|
||||
}
|
||||
|
||||
// Store blend mode from material
|
||||
// Store blend mode and flags from material
|
||||
if (batch.materialIndex < model.materials.size()) {
|
||||
bgpu.blendMode = model.materials[batch.materialIndex].blendMode;
|
||||
bgpu.materialFlags = model.materials[batch.materialIndex].flags;
|
||||
}
|
||||
|
||||
// Resolve texture: batch.textureIndex → textureLookup → allTextures
|
||||
@@ -1298,6 +1306,10 @@ void M2Renderer::render(const Camera& camera, const glm::mat4& view, const glm::
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
|
||||
// Unlit: material flag 0x01 or additive/mod blend modes
|
||||
bool unlit = (batch.materialFlags & 0x01) != 0 || batch.blendMode >= 3;
|
||||
shader->setUniform("uUnlit", unlit);
|
||||
|
||||
bool hasTexture = (batch.texture != 0);
|
||||
shader->setUniform("uHasTexture", hasTexture);
|
||||
shader->setUniform("uAlphaTest", batch.blendMode == 1);
|
||||
|
||||
Reference in New Issue
Block a user