Normalize in shader for broken drivers
This commit is contained in:
parent
891b053358
commit
dbc3cd5ff5
@ -3,7 +3,7 @@ uniform vec3 wind_direction;
|
|||||||
layout(location = 0) in vec3 i_position;
|
layout(location = 0) in vec3 i_position;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 1) in int i_normal_pked;
|
layout(location = 1) in vec4 i_normal_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 1) in vec4 i_normal;
|
layout(location = 1) in vec4 i_normal;
|
||||||
#endif
|
#endif
|
||||||
@ -13,7 +13,7 @@ layout(location = 3) in vec2 i_uv;
|
|||||||
layout(location = 8) in vec3 i_origin;
|
layout(location = 8) in vec3 i_origin;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 9) in int i_rotation_pked;
|
layout(location = 9) in vec4 i_rotation_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 9) in vec4 i_rotation;
|
layout(location = 9) in vec4 i_rotation;
|
||||||
#endif
|
#endif
|
||||||
@ -56,8 +56,8 @@ void main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
vec4 i_normal = convert10BitVector(i_normal_pked);
|
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||||
vec4 i_rotation = convert10BitVector(i_rotation_pked);
|
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Use_Bindless_Texture)
|
#if defined(Use_Bindless_Texture)
|
||||||
|
@ -7,7 +7,7 @@ layout(location = 3) in vec2 i_uv;
|
|||||||
layout(location = 8) in vec3 i_origin;
|
layout(location = 8) in vec3 i_origin;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 9) in int i_rotation_pked;
|
layout(location = 9) in vec4 i_rotation_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 9) in vec4 i_rotation;
|
layout(location = 9) in vec4 i_rotation;
|
||||||
#endif
|
#endif
|
||||||
@ -47,7 +47,7 @@ void main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
vec4 i_rotation = convert10BitVector(i_rotation_pked);
|
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Use_Bindless_Texture)
|
#if defined(Use_Bindless_Texture)
|
||||||
|
@ -21,7 +21,7 @@ void main()
|
|||||||
vec3 V1 = gl_in[2].gl_Position.xyz - gl_in[1].gl_Position.xyz;
|
vec3 V1 = gl_in[2].gl_Position.xyz - gl_in[1].gl_Position.xyz;
|
||||||
// calculate normal as perpendicular to two vectors of the triangle
|
// calculate normal as perpendicular to two vectors of the triangle
|
||||||
vec3 V0_V1_crossed = cross(V1, V0);
|
vec3 V0_V1_crossed = cross(V1, V0);
|
||||||
float normal_scale = clamp(length(V0_V1_crossed) * 10.0, 0.0, 0.25);
|
float normal_scale = min(length(V0_V1_crossed) * 10.0, 0.25);
|
||||||
vec3 N = normalize(V0_V1_crossed);
|
vec3 N = normalize(V0_V1_crossed);
|
||||||
|
|
||||||
// normals of each vertex of the triangle
|
// normals of each vertex of the triangle
|
||||||
|
@ -3,13 +3,13 @@ uniform samplerBuffer skinning_tex;
|
|||||||
layout(location = 0) in vec3 i_position;
|
layout(location = 0) in vec3 i_position;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 1) in int i_normal_pked;
|
layout(location = 1) in vec4 i_normal_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 1) in vec4 i_normal;
|
layout(location = 1) in vec4 i_normal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 5) in int i_tangent_pked;
|
layout(location = 5) in vec4 i_tangent_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 5) in vec4 i_tangent;
|
layout(location = 5) in vec4 i_tangent;
|
||||||
#endif
|
#endif
|
||||||
@ -19,7 +19,7 @@ layout(location = 7) in vec4 i_weight;
|
|||||||
layout(location = 8) in vec3 i_origin;
|
layout(location = 8) in vec3 i_origin;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 9) in int i_rotation_pked;
|
layout(location = 9) in vec4 i_rotation_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 9) in vec4 i_rotation;
|
layout(location = 9) in vec4 i_rotation;
|
||||||
#endif
|
#endif
|
||||||
@ -37,9 +37,9 @@ void main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
vec4 i_normal = convert10BitVector(i_normal_pked);
|
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||||
vec4 i_tangent = convert10BitVector(i_tangent_pked);
|
vec4 i_tangent = convert10BitVector(i_tangent_orig);
|
||||||
vec4 i_rotation = convert10BitVector(i_rotation_pked);
|
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec4 idle_position = vec4(i_position, 1.0);
|
vec4 idle_position = vec4(i_position, 1.0);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
layout(location = 0) in vec3 i_position;
|
layout(location = 0) in vec3 i_position;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 1) in int i_normal_pked;
|
layout(location = 1) in vec4 i_normal_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 1) in vec4 i_normal;
|
layout(location = 1) in vec4 i_normal;
|
||||||
#endif
|
#endif
|
||||||
@ -11,7 +11,7 @@ layout(location = 3) in vec2 i_uv;
|
|||||||
layout(location = 4) in vec2 i_uv_two;
|
layout(location = 4) in vec2 i_uv_two;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 5) in int i_tangent_pked;
|
layout(location = 5) in vec4 i_tangent_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 5) in vec4 i_tangent;
|
layout(location = 5) in vec4 i_tangent;
|
||||||
#endif
|
#endif
|
||||||
@ -19,7 +19,7 @@ layout(location = 5) in vec4 i_tangent;
|
|||||||
layout(location = 8) in vec3 i_origin;
|
layout(location = 8) in vec3 i_origin;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 9) in int i_rotation_pked;
|
layout(location = 9) in vec4 i_rotation_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 9) in vec4 i_rotation;
|
layout(location = 9) in vec4 i_rotation;
|
||||||
#endif
|
#endif
|
||||||
@ -68,9 +68,9 @@ void main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
vec4 i_normal = convert10BitVector(i_normal_pked);
|
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||||
vec4 i_tangent = convert10BitVector(i_tangent_pked);
|
vec4 i_tangent = convert10BitVector(i_tangent_orig);
|
||||||
vec4 i_rotation = convert10BitVector(i_rotation_pked);
|
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Use_Bindless_Texture)
|
#if defined(Use_Bindless_Texture)
|
||||||
|
@ -5,7 +5,7 @@ layout(location = 3) in vec2 i_uv;
|
|||||||
layout(location = 8) in vec3 i_origin;
|
layout(location = 8) in vec3 i_origin;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 9) in int i_rotation_pked;
|
layout(location = 9) in vec4 i_rotation_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 9) in vec4 i_rotation;
|
layout(location = 9) in vec4 i_rotation;
|
||||||
#endif
|
#endif
|
||||||
@ -45,7 +45,7 @@ void main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
vec4 i_rotation = convert10BitVector(i_rotation_pked);
|
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Use_Bindless_Texture)
|
#if defined(Use_Bindless_Texture)
|
||||||
|
@ -6,7 +6,7 @@ uniform samplerBuffer skinning_tex;
|
|||||||
|
|
||||||
layout(location = 0) in vec3 i_position;
|
layout(location = 0) in vec3 i_position;
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 1) in int i_normal_pked;
|
layout(location = 1) in vec4 i_normal_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 1) in vec4 i_normal;
|
layout(location = 1) in vec4 i_normal;
|
||||||
#endif
|
#endif
|
||||||
@ -16,7 +16,7 @@ layout(location = 3) in vec2 i_uv;
|
|||||||
layout(location = 4) in vec2 i_uv_two;
|
layout(location = 4) in vec2 i_uv_two;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 5) in int i_tangent_pked;
|
layout(location = 5) in vec4 i_tangent_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 5) in vec4 i_tangent;
|
layout(location = 5) in vec4 i_tangent;
|
||||||
#endif
|
#endif
|
||||||
@ -26,7 +26,7 @@ layout(location = 7) in vec4 i_weight;
|
|||||||
layout(location = 8) in vec3 i_origin;
|
layout(location = 8) in vec3 i_origin;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 9) in int i_rotation_pked;
|
layout(location = 9) in vec4 i_rotation_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 9) in vec4 i_rotation;
|
layout(location = 9) in vec4 i_rotation;
|
||||||
#endif
|
#endif
|
||||||
@ -75,9 +75,9 @@ void main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
vec4 i_normal = convert10BitVector(i_normal_pked);
|
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||||
vec4 i_tangent = convert10BitVector(i_tangent_pked);
|
vec4 i_tangent = convert10BitVector(i_tangent_orig);
|
||||||
vec4 i_rotation = convert10BitVector(i_rotation_pked);
|
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Use_Bindless_Texture)
|
#if defined(Use_Bindless_Texture)
|
||||||
|
@ -14,7 +14,7 @@ layout(location = 7) in vec4 i_weight;
|
|||||||
layout(location = 8) in vec3 i_origin;
|
layout(location = 8) in vec3 i_origin;
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
layout(location = 9) in int i_rotation_pked;
|
layout(location = 9) in vec4 i_rotation_orig;
|
||||||
#else
|
#else
|
||||||
layout(location = 9) in vec4 i_rotation;
|
layout(location = 9) in vec4 i_rotation;
|
||||||
#endif
|
#endif
|
||||||
@ -55,7 +55,7 @@ void main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Converts_10bit_Vector)
|
#if defined(Converts_10bit_Vector)
|
||||||
vec4 i_rotation = convert10BitVector(i_rotation_pked);
|
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Use_Bindless_Texture)
|
#if defined(Use_Bindless_Texture)
|
||||||
|
@ -11,24 +11,12 @@ vec4 getWorldPosition(vec3 origin, vec4 rotation, vec3 scale, vec3 local_pos)
|
|||||||
return vec4(local_pos, 1.0);
|
return vec4(local_pos, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 convert10BitVector(int pked)
|
vec4 convert10BitVector(vec4 orig)
|
||||||
{
|
{
|
||||||
vec4 ret;
|
vec4 ret;
|
||||||
int part = pked & 1023;
|
ret.x = orig.x * 0.00195694715;
|
||||||
float part_mix = float(clamp(int(part & 512), 0, 1));
|
ret.y = orig.y * 0.00195694715;
|
||||||
ret.x = mix(float(part), float(-1024 + part), part_mix) * 0.00195694715;
|
ret.z = orig.z * 0.00195694715;
|
||||||
|
ret.w = max(orig.w, -1.0);
|
||||||
part = (pked >> 10) & 1023;
|
|
||||||
part_mix = float(clamp(int(part & 512), 0, 1));
|
|
||||||
ret.y = mix(float(part), float(-1024 + part), part_mix) * 0.00195694715;
|
|
||||||
|
|
||||||
part = (pked >> 20) & 1023;
|
|
||||||
part_mix = float(clamp(int(part & 512), 0, 1));
|
|
||||||
ret.z = mix(float(part), float(-1024 + part), part_mix) * 0.00195694715;
|
|
||||||
|
|
||||||
part = pked >> 30;
|
|
||||||
part_mix = float(clamp(int(part & 2), 0, 1));
|
|
||||||
ret.w = mix(float(part), -1.0f, part_mix);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
// SuperTuxKart - a fun racing game with go-kart
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
// SuperTuxKart - a fun racing game with go-kart
|
|
||||||
// Copyright (C) 2017 SuperTuxKart-Team
|
// Copyright (C) 2017 SuperTuxKart-Team
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
|
@ -317,18 +317,13 @@ void SPMeshBuffer::recreateVAO(unsigned i)
|
|||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, pitch, (void*)offset);
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, pitch, (void*)offset);
|
||||||
offset += 12;
|
offset += 12;
|
||||||
// Normal
|
// Normal, if 10bit vector normalization is wrongly done by drivers, use
|
||||||
|
// original value and normalize ourselves in shader
|
||||||
glEnableVertexAttribArray(1);
|
glEnableVertexAttribArray(1);
|
||||||
if (GraphicsRestrictions::isDisabled
|
glVertexAttribPointer(1, 4, GL_INT_2_10_10_10_REV,
|
||||||
(GraphicsRestrictions::GR_10BIT_VECTOR))
|
GraphicsRestrictions::isDisabled
|
||||||
{
|
(GraphicsRestrictions::GR_10BIT_VECTOR) ? GL_FALSE : GL_TRUE, pitch,
|
||||||
glVertexAttribIPointer(1, 1, GL_INT, pitch, (void*)offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glVertexAttribPointer(1, 4, GL_INT_2_10_10_10_REV, GL_TRUE, pitch,
|
|
||||||
(void*)offset);
|
(void*)offset);
|
||||||
}
|
|
||||||
offset += 4;
|
offset += 4;
|
||||||
// Vertex color
|
// Vertex color
|
||||||
if (m_vertex_color)
|
if (m_vertex_color)
|
||||||
@ -363,17 +358,10 @@ void SPMeshBuffer::recreateVAO(unsigned i)
|
|||||||
{
|
{
|
||||||
// Tangent and bi-tanget sign
|
// Tangent and bi-tanget sign
|
||||||
glEnableVertexAttribArray(5);
|
glEnableVertexAttribArray(5);
|
||||||
if (GraphicsRestrictions::isDisabled
|
glVertexAttribPointer(5, 4, GL_INT_2_10_10_10_REV,
|
||||||
(GraphicsRestrictions::GR_10BIT_VECTOR))
|
GraphicsRestrictions::isDisabled
|
||||||
{
|
(GraphicsRestrictions::GR_10BIT_VECTOR) ? GL_FALSE : GL_TRUE,
|
||||||
glVertexAttribIPointer(5, 1, GL_INT, pitch,
|
pitch, (void*)offset);
|
||||||
(void*)offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glVertexAttribPointer(5, 4, GL_INT_2_10_10_10_REV, GL_TRUE, pitch,
|
|
||||||
(void*)offset);
|
|
||||||
}
|
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
if (m_skinned)
|
if (m_skinned)
|
||||||
@ -418,16 +406,10 @@ void SPMeshBuffer::recreateVAO(unsigned i)
|
|||||||
glVertexAttribDivisorARB(8, 1);
|
glVertexAttribDivisorARB(8, 1);
|
||||||
// Rotation (quaternion .xyz)
|
// Rotation (quaternion .xyz)
|
||||||
glEnableVertexAttribArray(9);
|
glEnableVertexAttribArray(9);
|
||||||
if (GraphicsRestrictions::isDisabled
|
glVertexAttribPointer(9, 4, GL_INT_2_10_10_10_REV,
|
||||||
(GraphicsRestrictions::GR_10BIT_VECTOR))
|
GraphicsRestrictions::isDisabled
|
||||||
{
|
(GraphicsRestrictions::GR_10BIT_VECTOR) ? GL_FALSE : GL_TRUE, 32,
|
||||||
glVertexAttribIPointer(9, 1, GL_INT, 32, (void*)12);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glVertexAttribPointer(9, 4, GL_INT_2_10_10_10_REV, GL_TRUE, 32,
|
|
||||||
(void*)12);
|
(void*)12);
|
||||||
}
|
|
||||||
glVertexAttribDivisorARB(9, 1);
|
glVertexAttribDivisorARB(9, 1);
|
||||||
// Scale (3 half floats and .w for quaternion .w)
|
// Scale (3 half floats and .w for quaternion .w)
|
||||||
glEnableVertexAttribArray(10);
|
glEnableVertexAttribArray(10);
|
||||||
|
Loading…
Reference in New Issue
Block a user