Use 4 32bit floats for quaternion for sam's wall
This commit is contained in:
parent
4abdb14a4c
commit
295c793f91
@ -11,13 +11,7 @@ layout(location = 1) in vec4 i_normal;
|
||||
layout(location = 2) in vec4 i_color;
|
||||
layout(location = 3) in vec2 i_uv;
|
||||
layout(location = 8) in vec3 i_origin;
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
layout(location = 9) in vec4 i_rotation_orig;
|
||||
#else
|
||||
layout(location = 9) in vec4 i_rotation;
|
||||
#endif
|
||||
|
||||
layout(location = 10) in vec4 i_scale;
|
||||
layout(location = 12) in ivec2 i_misc_data;
|
||||
|
||||
@ -32,16 +26,14 @@ void main()
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||
#endif
|
||||
|
||||
vec3 test = sin(wind_direction * (i_position.y * 0.1));
|
||||
test += cos(wind_direction) * 0.7;
|
||||
|
||||
vec4 quaternion = normalize(vec4(i_rotation.xyz, i_scale.w));
|
||||
vec4 world_position = getWorldPosition(i_origin + test * i_color.r,
|
||||
quaternion, i_scale.xyz, i_position);
|
||||
vec3 world_normal = rotateVector(quaternion, i_normal.xyz);
|
||||
i_rotation, i_scale.xyz, i_position);
|
||||
vec3 world_normal = rotateVector(i_rotation, i_normal.xyz);
|
||||
|
||||
normal = (u_view_matrix * vec4(world_normal, 0.0)).xyz;
|
||||
uv = i_uv;
|
||||
|
@ -5,13 +5,7 @@ layout(location = 0) in vec3 i_position;
|
||||
layout(location = 2) in vec4 i_color;
|
||||
layout(location = 3) in vec2 i_uv;
|
||||
layout(location = 8) in vec3 i_origin;
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
layout(location = 9) in vec4 i_rotation_orig;
|
||||
#else
|
||||
layout(location = 9) in vec4 i_rotation;
|
||||
#endif
|
||||
|
||||
layout(location = 10) in vec4 i_scale;
|
||||
|
||||
#stk_include "utils/get_world_location.vert"
|
||||
@ -20,17 +14,10 @@ out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||
#endif
|
||||
|
||||
vec3 test = sin(wind_direction * (i_position.y * 0.1));
|
||||
test += cos(wind_direction) * 0.7;
|
||||
|
||||
vec4 quaternion = normalize(vec4(i_rotation.xyz, i_scale.w));
|
||||
vec4 world_position = getWorldPosition(i_origin + test * i_color.r,
|
||||
quaternion, i_scale.xyz, i_position);
|
||||
i_rotation, i_scale.xyz, i_position);
|
||||
|
||||
uv = i_uv;
|
||||
gl_Position = u_shadow_projection_view_matrices[layer] * world_position;
|
||||
|
@ -17,13 +17,7 @@ layout(location = 5) in vec4 i_tangent;
|
||||
layout(location = 6) in ivec4 i_joint;
|
||||
layout(location = 7) in vec4 i_weight;
|
||||
layout(location = 8) in vec3 i_origin;
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
layout(location = 9) in vec4 i_rotation_orig;
|
||||
#else
|
||||
layout(location = 9) in vec4 i_rotation;
|
||||
#endif
|
||||
|
||||
layout(location = 10) in vec4 i_scale;
|
||||
layout(location = 12) in ivec2 i_misc_data;
|
||||
|
||||
@ -39,7 +33,6 @@ void main()
|
||||
#if defined(Converts_10bit_Vector)
|
||||
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||
vec4 i_tangent = convert10BitVector(i_tangent_orig);
|
||||
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||
#endif
|
||||
|
||||
vec4 idle_position = vec4(i_position, 1.0);
|
||||
@ -104,12 +97,11 @@ void main()
|
||||
skinned_position = mix(skinned_position, idle_position, step_mix);
|
||||
skinned_normal = mix(skinned_normal, idle_normal, step_mix);
|
||||
skinned_tangent = mix(skinned_tangent, idle_tangent, step_mix);
|
||||
vec4 quaternion = normalize(vec4(i_rotation.xyz, i_scale.w));
|
||||
|
||||
gl_Position = getWorldPosition(i_origin, quaternion, i_scale.xyz,
|
||||
gl_Position = getWorldPosition(i_origin, i_rotation, i_scale.xyz,
|
||||
skinned_position.xyz);
|
||||
o_normal = normalize(rotateVector(quaternion, skinned_normal.xyz));
|
||||
o_tangent = normalize(rotateVector(quaternion, skinned_tangent.xyz));
|
||||
o_normal = normalize(rotateVector(i_rotation, skinned_normal.xyz));
|
||||
o_tangent = normalize(rotateVector(i_rotation, skinned_tangent.xyz));
|
||||
o_bitangent = cross(o_normal, o_tangent) * i_tangent.w;
|
||||
|
||||
}
|
||||
|
@ -17,13 +17,7 @@ layout(location = 5) in vec4 i_tangent;
|
||||
#endif
|
||||
|
||||
layout(location = 8) in vec3 i_origin;
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
layout(location = 9) in vec4 i_rotation_orig;
|
||||
#else
|
||||
layout(location = 9) in vec4 i_rotation;
|
||||
#endif
|
||||
|
||||
layout(location = 10) in vec4 i_scale;
|
||||
layout(location = 11) in vec2 i_texture_trans;
|
||||
layout(location = 12) in ivec2 i_misc_data;
|
||||
@ -47,14 +41,12 @@ void main()
|
||||
#if defined(Converts_10bit_Vector)
|
||||
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||
vec4 i_tangent = convert10BitVector(i_tangent_orig);
|
||||
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||
#endif
|
||||
|
||||
vec4 quaternion = normalize(vec4(i_rotation.xyz, i_scale.w));
|
||||
vec4 v_world_position = getWorldPosition(i_origin, quaternion, i_scale.xyz,
|
||||
vec4 v_world_position = getWorldPosition(i_origin, i_rotation, i_scale.xyz,
|
||||
i_position);
|
||||
vec3 v_world_normal = rotateVector(quaternion, i_normal.xyz);
|
||||
vec3 world_tangent = rotateVector(quaternion, i_tangent.xyz);
|
||||
vec3 v_world_normal = rotateVector(i_rotation, i_normal.xyz);
|
||||
vec3 world_tangent = rotateVector(i_rotation, i_tangent.xyz);
|
||||
|
||||
tangent = (u_view_matrix * vec4(world_tangent, 0.0)).xyz;
|
||||
bitangent = (u_view_matrix *
|
||||
|
@ -3,13 +3,7 @@ uniform int layer;
|
||||
layout(location = 0) in vec3 i_position;
|
||||
layout(location = 3) in vec2 i_uv;
|
||||
layout(location = 8) in vec3 i_origin;
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
layout(location = 9) in vec4 i_rotation_orig;
|
||||
#else
|
||||
layout(location = 9) in vec4 i_rotation;
|
||||
#endif
|
||||
|
||||
layout(location = 10) in vec4 i_scale;
|
||||
|
||||
#stk_include "utils/get_world_location.vert"
|
||||
@ -18,13 +12,7 @@ out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||
#endif
|
||||
|
||||
vec4 quaternion = normalize(vec4(i_rotation.xyz, i_scale.w));
|
||||
vec4 world_position = getWorldPosition(i_origin, quaternion, i_scale.xyz,
|
||||
vec4 world_position = getWorldPosition(i_origin, i_rotation, i_scale.xyz,
|
||||
i_position);
|
||||
uv = i_uv;
|
||||
gl_Position = u_shadow_projection_view_matrices[layer] * world_position;
|
||||
|
@ -24,13 +24,7 @@ layout(location = 5) in vec4 i_tangent;
|
||||
layout(location = 6) in ivec4 i_joint;
|
||||
layout(location = 7) in vec4 i_weight;
|
||||
layout(location = 8) in vec3 i_origin;
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
layout(location = 9) in vec4 i_rotation_orig;
|
||||
#else
|
||||
layout(location = 9) in vec4 i_rotation;
|
||||
#endif
|
||||
|
||||
layout(location = 10) in vec4 i_scale;
|
||||
layout(location = 11) in vec2 i_texture_trans;
|
||||
layout(location = 12) in ivec2 i_misc_data;
|
||||
@ -52,7 +46,6 @@ void main()
|
||||
#if defined(Converts_10bit_Vector)
|
||||
vec4 i_normal = convert10BitVector(i_normal_orig);
|
||||
vec4 i_tangent = convert10BitVector(i_tangent_orig);
|
||||
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||
#endif
|
||||
|
||||
vec4 idle_position = vec4(i_position, 1.0);
|
||||
@ -113,11 +106,10 @@ void main()
|
||||
skinned_normal = joint_matrix * idle_normal;
|
||||
skinned_tangent = joint_matrix * idle_tangent;
|
||||
|
||||
vec4 quaternion = normalize(vec4(i_rotation.xyz, i_scale.w));
|
||||
vec4 world_position = getWorldPosition(i_origin, quaternion, i_scale.xyz,
|
||||
vec4 world_position = getWorldPosition(i_origin, i_rotation, i_scale.xyz,
|
||||
skinned_position.xyz);
|
||||
vec3 world_normal = rotateVector(quaternion, skinned_normal.xyz);
|
||||
vec3 world_tangent = rotateVector(quaternion, skinned_tangent.xyz);
|
||||
vec3 world_normal = rotateVector(i_rotation, skinned_normal.xyz);
|
||||
vec3 world_tangent = rotateVector(i_rotation, skinned_tangent.xyz);
|
||||
|
||||
tangent = (u_view_matrix * vec4(world_tangent, 0.0)).xyz;
|
||||
bitangent = (u_view_matrix *
|
||||
|
@ -11,13 +11,7 @@ layout(location = 3) in vec2 i_uv;
|
||||
layout(location = 6) in ivec4 i_joint;
|
||||
layout(location = 7) in vec4 i_weight;
|
||||
layout(location = 8) in vec3 i_origin;
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
layout(location = 9) in vec4 i_rotation_orig;
|
||||
#else
|
||||
layout(location = 9) in vec4 i_rotation;
|
||||
#endif
|
||||
|
||||
layout(location = 10) in vec4 i_scale;
|
||||
layout(location = 12) in ivec2 i_misc_data;
|
||||
|
||||
@ -27,11 +21,6 @@ out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
#if defined(Converts_10bit_Vector)
|
||||
vec4 i_rotation = convert10BitVector(i_rotation_orig);
|
||||
#endif
|
||||
|
||||
vec4 idle_position = vec4(i_position, 1.0);
|
||||
vec4 skinned_position = vec4(0.0);
|
||||
int skinning_offset = i_misc_data.x;
|
||||
@ -83,9 +72,7 @@ void main()
|
||||
#endif
|
||||
|
||||
skinned_position = joint_matrix * idle_position;
|
||||
|
||||
vec4 quaternion = normalize(vec4(i_rotation.xyz, i_scale.w));
|
||||
vec4 world_position = getWorldPosition(i_origin, quaternion, i_scale.xyz,
|
||||
vec4 world_position = getWorldPosition(i_origin, i_rotation, i_scale.xyz,
|
||||
skinned_position.xyz);
|
||||
uv = i_uv;
|
||||
gl_Position = u_shadow_projection_view_matrices[layer] * world_position;
|
||||
|
@ -31,13 +31,13 @@ namespace SP
|
||||
class SPInstancedData
|
||||
{
|
||||
private:
|
||||
char m_data[32];
|
||||
char m_data[44];
|
||||
|
||||
public:
|
||||
// ------------------------------------------------------------------------
|
||||
SPInstancedData()
|
||||
{
|
||||
memset(m_data, 0, 32);
|
||||
memset(m_data, 0, 44);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
SPInstancedData(const core::matrix4& model_mat,
|
||||
@ -65,21 +65,19 @@ public:
|
||||
rotation.W = -rotation.W;
|
||||
}
|
||||
memcpy(m_data, position, 12);
|
||||
uint32_t _2101010 = normalizedSignedFloatsTo1010102(
|
||||
{{ rotation.X, rotation.Y, rotation.Z, 0.0f }});
|
||||
memcpy(m_data + 12, &_2101010, 4);
|
||||
memcpy(m_data + 12, &rotation, 16);
|
||||
short s[4] = { toFloat16(scale.X), toFloat16(scale.Y),
|
||||
toFloat16(scale.Z), toFloat16(rotation.W) };
|
||||
memcpy(m_data + 16, s, 8);
|
||||
toFloat16(scale.Z), 0 };
|
||||
memcpy(m_data + 28, s, 8);
|
||||
short tm[2] =
|
||||
{
|
||||
short(texture_trans_x * 32767.0f),
|
||||
short(texture_trans_y * 32767.0f)
|
||||
};
|
||||
memcpy(m_data + 24, tm, 4);
|
||||
memcpy(m_data + 28, &skinning_offset, 2);
|
||||
memcpy(m_data + 36, tm, 4);
|
||||
memcpy(m_data + 40, &skinning_offset, 2);
|
||||
short hue_packed = short(core::clamp(int(hue * 100.0f), 0, 100));
|
||||
memcpy(m_data + 30, &hue_packed, 2);
|
||||
memcpy(m_data + 42, &hue_packed, 2);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
const void* getData() const { return m_data; }
|
||||
|
@ -247,16 +247,16 @@ void SPMeshBuffer::recreateVAO(unsigned i)
|
||||
#ifndef USE_GLES2
|
||||
if (CVS->isARBBufferStorageUsable())
|
||||
{
|
||||
glBufferStorage(GL_ARRAY_BUFFER, m_gl_instance_size[i] * 32, NULL,
|
||||
glBufferStorage(GL_ARRAY_BUFFER, m_gl_instance_size[i] * 44, NULL,
|
||||
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||
m_ins_dat_mapped_ptr[i] = glMapBufferRange(GL_ARRAY_BUFFER, 0,
|
||||
m_gl_instance_size[i] * 32,
|
||||
m_gl_instance_size[i] * 44,
|
||||
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glBufferData(GL_ARRAY_BUFFER, m_gl_instance_size[i] * 32, NULL,
|
||||
glBufferData(GL_ARRAY_BUFFER, m_gl_instance_size[i] * 44, NULL,
|
||||
GL_DYNAMIC_DRAW);
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
@ -346,26 +346,23 @@ void SPMeshBuffer::recreateVAO(unsigned i)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_ins_array[i]);
|
||||
// Origin
|
||||
glEnableVertexAttribArray(8);
|
||||
glVertexAttribPointer(8, 3, GL_FLOAT, GL_FALSE, 32, (void*)0);
|
||||
glVertexAttribPointer(8, 3, GL_FLOAT, GL_FALSE, 44, (void*)0);
|
||||
glVertexAttribDivisorARB(8, 1);
|
||||
// Rotation (quaternion .xyz)
|
||||
// Rotation (quaternion in 4 32bit floats)
|
||||
glEnableVertexAttribArray(9);
|
||||
glVertexAttribPointer(9, 4, GL_INT_2_10_10_10_REV,
|
||||
GraphicsRestrictions::isDisabled
|
||||
(GraphicsRestrictions::GR_CORRECT_10BIT_NORMALIZATION) ? GL_FALSE : GL_TRUE, 32,
|
||||
(void*)12);
|
||||
glVertexAttribPointer(9, 4, GL_FLOAT, GL_FALSE, 44, (void*)12);
|
||||
glVertexAttribDivisorARB(9, 1);
|
||||
// Scale (3 half floats and .w for quaternion .w)
|
||||
// Scale (3 half floats and .w unused)
|
||||
glEnableVertexAttribArray(10);
|
||||
glVertexAttribPointer(10, 4, GL_HALF_FLOAT, GL_FALSE, 32, (void*)16);
|
||||
glVertexAttribPointer(10, 4, GL_HALF_FLOAT, GL_FALSE, 44, (void*)28);
|
||||
glVertexAttribDivisorARB(10, 1);
|
||||
// Texture translation
|
||||
glEnableVertexAttribArray(11);
|
||||
glVertexAttribPointer(11, 2, GL_SHORT, GL_TRUE, 32, (void*)24);
|
||||
glVertexAttribPointer(11, 2, GL_SHORT, GL_TRUE, 44, (void*)36);
|
||||
glVertexAttribDivisorARB(11, 1);
|
||||
// Misc data (skinning offset and hue change)
|
||||
glEnableVertexAttribArray(12);
|
||||
glVertexAttribIPointer(12, 2, GL_SHORT, 32, (void*)28);
|
||||
glVertexAttribIPointer(12, 2, GL_SHORT, 44, (void*)40);
|
||||
glVertexAttribDivisorARB(12, 1);
|
||||
|
||||
glBindVertexArray(0);
|
||||
@ -400,15 +397,15 @@ void SPMeshBuffer::uploadInstanceData()
|
||||
if (CVS->isARBBufferStorageUsable())
|
||||
{
|
||||
memcpy(m_ins_dat_mapped_ptr[i], m_ins_dat[i].data(),
|
||||
m_ins_dat[i].size() * 32);
|
||||
m_ins_dat[i].size() * 44);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_ins_array[i]);
|
||||
void* ptr = glMapBufferRange(GL_ARRAY_BUFFER, 0,
|
||||
m_ins_dat[i].size() * 32, GL_MAP_WRITE_BIT |
|
||||
m_ins_dat[i].size() * 44, GL_MAP_WRITE_BIT |
|
||||
GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
memcpy(ptr, m_ins_dat[i].data(), m_ins_dat[i].size() * 32);
|
||||
memcpy(ptr, m_ins_dat[i].data(), m_ins_dat[i].size() * 44);
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user