mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-26 20:41:21 -08:00
gl_shader_gen: View vector needs to be normalized when computing half angle vector.
This commit is contained in:
parent
021cb0bced
commit
603b619cbe
@ -368,19 +368,19 @@ vec4 secondary_fragment_color = vec4(0.0);
|
|||||||
out += "vec3 specular_sum = vec3(0.0);\n";
|
out += "vec3 specular_sum = vec3(0.0);\n";
|
||||||
out += "vec3 fragment_position = -view;\n";
|
out += "vec3 fragment_position = -view;\n";
|
||||||
out += "vec3 light_vector = vec3(0.0);\n";
|
out += "vec3 light_vector = vec3(0.0);\n";
|
||||||
|
out += "vec3 half_angle_vector = vec3(0.0);\n";
|
||||||
out += "float dist_atten = 1.0;\n";
|
out += "float dist_atten = 1.0;\n";
|
||||||
|
|
||||||
// Gets the index into the specified lookup table for specular lighting
|
// Gets the index into the specified lookup table for specular lighting
|
||||||
auto GetLutIndex = [&](unsigned light_num, Regs::LightingLutInput input, bool abs) {
|
auto GetLutIndex = [&](unsigned light_num, Regs::LightingLutInput input, bool abs) {
|
||||||
const std::string half_angle = "normalize(view + light_vector)";
|
|
||||||
std::string index;
|
std::string index;
|
||||||
switch (input) {
|
switch (input) {
|
||||||
case Regs::LightingLutInput::NH:
|
case Regs::LightingLutInput::NH:
|
||||||
index = "dot(normal, " + half_angle + ")";
|
index = "dot(normal, half_angle_vector)";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Regs::LightingLutInput::VH:
|
case Regs::LightingLutInput::VH:
|
||||||
index = std::string("dot(view, " + half_angle + ")");
|
index = std::string("dot(view, half_angle_vector)");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Regs::LightingLutInput::NV:
|
case Regs::LightingLutInput::NV:
|
||||||
@ -441,6 +441,7 @@ vec4 secondary_fragment_color = vec4(0.0);
|
|||||||
out += "diffuse_sum += ((light_src[" + std::to_string(num) + "].diffuse * " + dot_product + ") + light_src[" + std::to_string(num) + "].ambient) * dist_atten;\n";
|
out += "diffuse_sum += ((light_src[" + std::to_string(num) + "].diffuse * " + dot_product + ") + light_src[" + std::to_string(num) + "].ambient) * dist_atten;\n";
|
||||||
|
|
||||||
// Compute secondary fragment color (specular lighting) function
|
// Compute secondary fragment color (specular lighting) function
|
||||||
|
out += "half_angle_vector = normalize(normalize(view) + light_vector);\n";
|
||||||
std::string clamped_lut_index = GetLutIndex(num, config.lighting_lut.d0_type, config.lighting_lut.d0_abs);
|
std::string clamped_lut_index = GetLutIndex(num, config.lighting_lut.d0_type, config.lighting_lut.d0_abs);
|
||||||
const unsigned lut_num = (unsigned)Regs::LightingSampler::Distribution0;
|
const unsigned lut_num = (unsigned)Regs::LightingSampler::Distribution0;
|
||||||
std::string lut_lookup = "texture(lut[" + std::to_string(lut_num / 4) + "], " + clamped_lut_index + ")[" + std::to_string(lut_num & 3) + "]";
|
std::string lut_lookup = "texture(lut[" + std::to_string(lut_num / 4) + "], " + clamped_lut_index + ")[" + std::to_string(lut_num & 3) + "]";
|
||||||
|
Loading…
Reference in New Issue
Block a user