Correct scaling and normalizations of binormals and tangents in generated shaders

This commit is contained in:
rdb 2015-06-15 00:19:52 +02:00
parent bac400543a
commit 6d0e4c2662

View File

@ -713,6 +713,8 @@ synthesize_shader(const RenderState *rs) {
text << "\t uniform float4x4 trans_model_to_view,\n";
eye_position_freg = alloc_freg();
text << "\t out float4 l_eye_position : " << eye_position_freg << ",\n";
} else if ((_lighting || _out_aux_normal) && (_map_index_normal >= 0 && _auto_normal_on)) {
text << "\t uniform float4x4 trans_model_to_view,\n";
}
if (_need_eye_normal) {
eye_normal_freg = alloc_freg();
@ -784,9 +786,9 @@ synthesize_shader(const RenderState *rs) {
text << "\t l_color = vtx_color;\n";
}
if ((_lighting || _out_aux_normal) && (_map_index_normal >= 0 && _auto_normal_on)) {
text << "\t l_tangent.xyz = mul((float3x3)tpose_view_to_model, vtx_" << tangent_input << ".xyz);\n";
text << "\t l_tangent.xyz = normalize(mul((float3x3)trans_model_to_view, vtx_" << tangent_input << ".xyz));\n";
text << "\t l_tangent.w = 0;\n";
text << "\t l_binormal.xyz = mul((float3x3)tpose_view_to_model, -vtx_" << binormal_input << ".xyz);\n";
text << "\t l_binormal.xyz = normalize(mul((float3x3)trans_model_to_view, -vtx_" << binormal_input << ".xyz));\n";
text << "\t l_binormal.w = 0;\n";
}
if (_shadows && _auto_shadow_on) {