mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
Move material multiplication out of inner light loop
This commit is contained in:
parent
b3cee51fd0
commit
dba81db198
3 changed files with 24 additions and 24 deletions
|
@ -112,9 +112,9 @@ namespace swrenderer
|
|||
|
||||
uint8_t PalWall1Command::AddLights(const TriLight *lights, int num_lights, float viewpos_z, uint8_t fg, uint8_t material)
|
||||
{
|
||||
uint32_t lit_r = GPalette.BaseColors[fg].r;
|
||||
uint32_t lit_g = GPalette.BaseColors[fg].g;
|
||||
uint32_t lit_b = GPalette.BaseColors[fg].b;
|
||||
uint32_t lit_r = 0;
|
||||
uint32_t lit_g = 0;
|
||||
uint32_t lit_b = 0;
|
||||
|
||||
uint32_t material_r = GPalette.BaseColors[material].r;
|
||||
uint32_t material_g = GPalette.BaseColors[material].g;
|
||||
|
@ -144,14 +144,14 @@ namespace swrenderer
|
|||
float point_attenuation = lights[i].y * rcp_dist * distance_attenuation;
|
||||
uint32_t attenuation = (uint32_t)(lights[i].y == 0.0f ? simple_attenuation : point_attenuation);
|
||||
|
||||
lit_r += (light_color_r * material_r * attenuation) >> 16;
|
||||
lit_g += (light_color_g * material_g * attenuation) >> 16;
|
||||
lit_b += (light_color_b * material_b * attenuation) >> 16;
|
||||
lit_r += (light_color_r * attenuation) >> 8;
|
||||
lit_g += (light_color_g * attenuation) >> 8;
|
||||
lit_b += (light_color_b * attenuation) >> 8;
|
||||
}
|
||||
|
||||
lit_r = MIN<uint32_t>(lit_r, 255);
|
||||
lit_g = MIN<uint32_t>(lit_g, 255);
|
||||
lit_b = MIN<uint32_t>(lit_b, 255);
|
||||
lit_r = MIN<uint32_t>(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255);
|
||||
lit_g = MIN<uint32_t>(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255);
|
||||
lit_b = MIN<uint32_t>(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255);
|
||||
|
||||
return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)];
|
||||
}
|
||||
|
@ -1722,9 +1722,9 @@ namespace swrenderer
|
|||
|
||||
uint8_t PalSpanCommand::AddLights(const TriLight *lights, int num_lights, float viewpos_x, uint8_t fg, uint8_t material)
|
||||
{
|
||||
uint32_t lit_r = GPalette.BaseColors[fg].r;
|
||||
uint32_t lit_g = GPalette.BaseColors[fg].g;
|
||||
uint32_t lit_b = GPalette.BaseColors[fg].b;
|
||||
uint32_t lit_r = 0;
|
||||
uint32_t lit_g = 0;
|
||||
uint32_t lit_b = 0;
|
||||
|
||||
uint32_t material_r = GPalette.BaseColors[material].r;
|
||||
uint32_t material_g = GPalette.BaseColors[material].g;
|
||||
|
@ -1754,14 +1754,14 @@ namespace swrenderer
|
|||
float point_attenuation = lights[i].z * rcp_dist * distance_attenuation;
|
||||
uint32_t attenuation = (uint32_t)(lights[i].z == 0.0f ? simple_attenuation : point_attenuation);
|
||||
|
||||
lit_r += (light_color_r * material_r * attenuation) >> 16;
|
||||
lit_g += (light_color_g * material_g * attenuation) >> 16;
|
||||
lit_b += (light_color_b * material_b * attenuation) >> 16;
|
||||
lit_r += (light_color_r * attenuation) >> 8;
|
||||
lit_g += (light_color_g * attenuation) >> 8;
|
||||
lit_b += (light_color_b * attenuation) >> 8;
|
||||
}
|
||||
|
||||
lit_r = MIN<uint32_t>(lit_r, 255);
|
||||
lit_g = MIN<uint32_t>(lit_g, 255);
|
||||
lit_b = MIN<uint32_t>(lit_b, 255);
|
||||
lit_r = MIN<uint32_t>(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255);
|
||||
lit_g = MIN<uint32_t>(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255);
|
||||
lit_b = MIN<uint32_t>(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255);
|
||||
|
||||
return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)];
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ SSAVec4i DrawSpanCodegen::Shade(SSAVec4i fg, bool isSimpleShade)
|
|||
else
|
||||
c = shade_bgra_advanced(fg, light, shade_constants);
|
||||
|
||||
stack_lit_color.store(c);
|
||||
stack_lit_color.store(SSAVec4i(0));
|
||||
stack_light_index.store(SSAInt(0));
|
||||
|
||||
SSAForBlock block;
|
||||
|
@ -269,14 +269,14 @@ SSAVec4i DrawSpanCodegen::Shade(SSAVec4i fg, bool isSimpleShade)
|
|||
SSAFloat point_attenuation = light_z * rcp_dist * distance_attenuation;
|
||||
|
||||
SSAInt attenuation = SSAInt((light_z == SSAFloat(0.0f)).select(simple_attenuation, point_attenuation), true);
|
||||
SSAVec4i contribution = (light_color * fg * attenuation) >> 16;
|
||||
SSAVec4i contribution = (light_color * attenuation) >> 8;
|
||||
|
||||
stack_lit_color.store(lit_color + contribution);
|
||||
stack_light_index.store(light_index + 1);
|
||||
}
|
||||
block.end_block();
|
||||
|
||||
return stack_lit_color.load();
|
||||
return c + ((stack_lit_color.load() * fg) >> 8);
|
||||
}
|
||||
|
||||
SSAVec4i DrawSpanCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant)
|
||||
|
|
|
@ -169,7 +169,7 @@ SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, bool isSimpleShade)
|
|||
else
|
||||
c = shade_bgra_advanced(fg, light, shade_constants);
|
||||
|
||||
stack_lit_color.store(c);
|
||||
stack_lit_color.store(SSAVec4i(0));
|
||||
stack_light_index.store(SSAInt(0));
|
||||
|
||||
SSAForBlock block;
|
||||
|
@ -201,14 +201,14 @@ SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, bool isSimpleShade)
|
|||
SSAFloat point_attenuation = light_y * rcp_dist * distance_attenuation;
|
||||
|
||||
SSAInt attenuation = SSAInt((light_y == SSAFloat(0.0f)).select(simple_attenuation, point_attenuation), true);
|
||||
SSAVec4i contribution = (light_color * fg * attenuation) >> 16;
|
||||
SSAVec4i contribution = (light_color * attenuation) >> 8;
|
||||
|
||||
stack_lit_color.store(lit_color + contribution);
|
||||
stack_light_index.store(light_index + 1);
|
||||
}
|
||||
block.end_block();
|
||||
|
||||
return stack_lit_color.load();
|
||||
return c + ((stack_lit_color.load() * fg) >> 8);
|
||||
}
|
||||
|
||||
SSAVec4i DrawWallCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant variant)
|
||||
|
|
Loading…
Reference in a new issue