mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 01:22:37 -06:00
gl_shader_gen: don't call SampleTexture when bump map is not used
This commit is contained in:
parent
53ef90d1bd
commit
686fb3e78c
1 changed files with 5 additions and 4 deletions
|
@ -525,11 +525,12 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
|
||||||
"float geo_factor = 1.0;\n";
|
"float geo_factor = 1.0;\n";
|
||||||
|
|
||||||
// Compute fragment normals and tangents
|
// Compute fragment normals and tangents
|
||||||
const std::string pertubation =
|
auto Perturbation = [&]() {
|
||||||
"2.0 * (" + SampleTexture(config, lighting.bump_selector) + ").rgb - 1.0";
|
return "2.0 * (" + SampleTexture(config, lighting.bump_selector) + ").rgb - 1.0";
|
||||||
|
};
|
||||||
if (lighting.bump_mode == LightingRegs::LightingBumpMode::NormalMap) {
|
if (lighting.bump_mode == LightingRegs::LightingBumpMode::NormalMap) {
|
||||||
// Bump mapping is enabled using a normal map
|
// Bump mapping is enabled using a normal map
|
||||||
out += "vec3 surface_normal = " + pertubation + ";\n";
|
out += "vec3 surface_normal = " + Perturbation() + ";\n";
|
||||||
|
|
||||||
// Recompute Z-component of perturbation if 'renorm' is enabled, this provides a higher
|
// Recompute Z-component of perturbation if 'renorm' is enabled, this provides a higher
|
||||||
// precision result
|
// precision result
|
||||||
|
@ -543,7 +544,7 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
|
||||||
out += "vec3 surface_tangent = vec3(1.0, 0.0, 0.0);\n";
|
out += "vec3 surface_tangent = vec3(1.0, 0.0, 0.0);\n";
|
||||||
} else if (lighting.bump_mode == LightingRegs::LightingBumpMode::TangentMap) {
|
} else if (lighting.bump_mode == LightingRegs::LightingBumpMode::TangentMap) {
|
||||||
// Bump mapping is enabled using a tangent map
|
// Bump mapping is enabled using a tangent map
|
||||||
out += "vec3 surface_tangent = " + pertubation + ";\n";
|
out += "vec3 surface_tangent = " + Perturbation() + ";\n";
|
||||||
// Mathematically, recomputing Z-component of the tangent vector won't affect the relevant
|
// Mathematically, recomputing Z-component of the tangent vector won't affect the relevant
|
||||||
// computation below, which is also confirmed on 3DS. So we don't bother recomputing here
|
// computation below, which is also confirmed on 3DS. So we don't bother recomputing here
|
||||||
// even if 'renorm' is enabled.
|
// even if 'renorm' is enabled.
|
||||||
|
|
Loading…
Reference in a new issue