mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-28 10:02:31 -06:00
Merge pull request #2729 from yuriks/quaternion-fix
OpenGL: Improve accuracy of quaternion interpolation
This commit is contained in:
commit
3df85a103a
1 changed files with 5 additions and 3 deletions
|
@ -535,8 +535,8 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rotate the surface-local normal by the interpolated normal quaternion to convert it to
|
// Rotate the surface-local normal by the interpolated normal quaternion to convert it to
|
||||||
// eyespace
|
// eyespace.
|
||||||
out += "vec3 normal = normalize(quaternion_rotate(normquat, surface_normal));\n";
|
out += "vec3 normal = quaternion_rotate(normalize(normquat), surface_normal);\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 = [&lighting](unsigned light_num, LightingRegs::LightingLutInput input,
|
auto GetLutIndex = [&lighting](unsigned light_num, LightingRegs::LightingLutInput input,
|
||||||
|
@ -1002,7 +1002,9 @@ uniform sampler1D proctex_diff_lut;
|
||||||
// Rotate the vector v by the quaternion q
|
// Rotate the vector v by the quaternion q
|
||||||
vec3 quaternion_rotate(vec4 q, vec3 v) {
|
vec3 quaternion_rotate(vec4 q, vec3 v) {
|
||||||
return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);
|
return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);
|
||||||
})";
|
}
|
||||||
|
|
||||||
|
)";
|
||||||
|
|
||||||
if (config.state.proctex.enable)
|
if (config.state.proctex.enable)
|
||||||
AppendProcTexSampler(out, config);
|
AppendProcTexSampler(out, config);
|
||||||
|
|
Loading…
Reference in a new issue