Add custom vertex color to instance data
This commit is contained in:
parent
48730d1db4
commit
23470bbde2
@ -15,7 +15,7 @@ void main()
|
|||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_translation + offset *
|
u_object_buffer.m_objects[gl_InstanceIndex].m_translation + offset *
|
||||||
v_color.r,
|
v_color.r,
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_rotation,
|
u_object_buffer.m_objects[gl_InstanceIndex].m_rotation,
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_scale.xyz, v_position);
|
u_object_buffer.m_objects[gl_InstanceIndex].m_scale, v_position);
|
||||||
gl_Position = u_camera.m_projection_view_matrix * v_world_position;
|
gl_Position = u_camera.m_projection_view_matrix * v_world_position;
|
||||||
f_vertex_color = vec4(1.0);
|
f_vertex_color = vec4(1.0);
|
||||||
f_uv = v_uv;
|
f_uv = v_uv;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "utils/spm_layout.h"
|
#include "utils/spm_layout.h"
|
||||||
|
#include "utils/get_vertex_color.h"
|
||||||
#include "../utils/get_world_location.vert"
|
#include "../utils/get_world_location.vert"
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@ -6,9 +7,10 @@ void main()
|
|||||||
vec4 v_world_position = getWorldPosition(
|
vec4 v_world_position = getWorldPosition(
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_translation,
|
u_object_buffer.m_objects[gl_InstanceIndex].m_translation,
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_rotation,
|
u_object_buffer.m_objects[gl_InstanceIndex].m_rotation,
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_scale.xyz, v_position);
|
u_object_buffer.m_objects[gl_InstanceIndex].m_scale, v_position);
|
||||||
gl_Position = u_camera.m_projection_view_matrix * v_world_position;
|
gl_Position = u_camera.m_projection_view_matrix * v_world_position;
|
||||||
f_vertex_color = v_color.zyxw;
|
f_vertex_color = v_color.zyxw * getVertexColor(
|
||||||
|
u_object_buffer.m_objects[gl_InstanceIndex].m_custom_vertex_color);
|
||||||
f_uv = v_uv + u_object_buffer.m_objects[gl_InstanceIndex].m_texture_trans;
|
f_uv = v_uv + u_object_buffer.m_objects[gl_InstanceIndex].m_texture_trans;
|
||||||
f_uv_two = v_uv_two;
|
f_uv_two = v_uv_two;
|
||||||
f_material_id = u_object_buffer.m_objects[gl_InstanceIndex].m_material_id;
|
f_material_id = u_object_buffer.m_objects[gl_InstanceIndex].m_material_id;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "utils/spm_layout.h"
|
#include "utils/spm_layout.h"
|
||||||
|
#include "utils/get_vertex_color.h"
|
||||||
#include "../utils/get_world_location.vert"
|
#include "../utils/get_world_location.vert"
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@ -13,10 +14,11 @@ void main()
|
|||||||
vec4 v_world_position = getWorldPosition(
|
vec4 v_world_position = getWorldPosition(
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_translation,
|
u_object_buffer.m_objects[gl_InstanceIndex].m_translation,
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_rotation,
|
u_object_buffer.m_objects[gl_InstanceIndex].m_rotation,
|
||||||
u_object_buffer.m_objects[gl_InstanceIndex].m_scale.xyz,
|
u_object_buffer.m_objects[gl_InstanceIndex].m_scale,
|
||||||
v_skinning_position.xyz);
|
v_skinning_position.xyz);
|
||||||
gl_Position = u_camera.m_projection_view_matrix * v_world_position;
|
gl_Position = u_camera.m_projection_view_matrix * v_world_position;
|
||||||
f_vertex_color = v_color.zyxw;
|
f_vertex_color = v_color.zyxw * getVertexColor(
|
||||||
|
u_object_buffer.m_objects[gl_InstanceIndex].m_custom_vertex_color);
|
||||||
f_uv = v_uv + u_object_buffer.m_objects[gl_InstanceIndex].m_texture_trans;
|
f_uv = v_uv + u_object_buffer.m_objects[gl_InstanceIndex].m_texture_trans;
|
||||||
f_uv_two = v_uv_two;
|
f_uv_two = v_uv_two;
|
||||||
f_material_id = u_object_buffer.m_objects[gl_InstanceIndex].m_material_id;
|
f_material_id = u_object_buffer.m_objects[gl_InstanceIndex].m_material_id;
|
||||||
|
9
data/shaders/ge_shaders/utils/get_vertex_color.h
Normal file
9
data/shaders/ge_shaders/utils/get_vertex_color.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
vec4 getVertexColor(uint packed)
|
||||||
|
{
|
||||||
|
vec4 vertex_color;
|
||||||
|
vertex_color.a = float(packed >> 24) / 255.0;
|
||||||
|
vertex_color.r = float((packed >> 16) & 0xff) / 255.0;
|
||||||
|
vertex_color.g = float((packed >> 8) & 0xff) / 255.0;
|
||||||
|
vertex_color.b = float(packed & 0xff) / 255.0;
|
||||||
|
return vertex_color;
|
||||||
|
}
|
@ -13,7 +13,8 @@ struct ObjectData
|
|||||||
vec3 m_translation;
|
vec3 m_translation;
|
||||||
float m_hue_change;
|
float m_hue_change;
|
||||||
vec4 m_rotation;
|
vec4 m_rotation;
|
||||||
vec4 m_scale;
|
vec3 m_scale;
|
||||||
|
uint m_custom_vertex_color;
|
||||||
int m_skinning_offest;
|
int m_skinning_offest;
|
||||||
int m_material_id;
|
int m_material_id;
|
||||||
vec2 m_texture_trans;
|
vec2 m_texture_trans;
|
||||||
|
@ -51,7 +51,7 @@ ObjectData::ObjectData(irr::scene::ISceneNode* node, int material_id,
|
|||||||
}
|
}
|
||||||
memcpy(&m_translation_x, translation, sizeof(translation));
|
memcpy(&m_translation_x, translation, sizeof(translation));
|
||||||
memcpy(m_rotation, &rotation, sizeof(irr::core::quaternion));
|
memcpy(m_rotation, &rotation, sizeof(irr::core::quaternion));
|
||||||
memcpy(m_scale, &scale, sizeof(irr::core::vector3df));
|
memcpy(&m_scale_x, &scale, sizeof(irr::core::vector3df));
|
||||||
m_skinning_offset = skinning_offset;
|
m_skinning_offset = skinning_offset;
|
||||||
m_material_id = material_id;
|
m_material_id = material_id;
|
||||||
const irr::core::matrix4& texture_matrix =
|
const irr::core::matrix4& texture_matrix =
|
||||||
@ -63,6 +63,7 @@ ObjectData::ObjectData(irr::scene::ISceneNode* node, int material_id,
|
|||||||
m_hue_change = ri->getHue();
|
m_hue_change = ri->getHue();
|
||||||
else
|
else
|
||||||
m_hue_change = 0.0f;
|
m_hue_change = 0.0f;
|
||||||
|
m_custom_vertex_color = irr::video::SColor((uint32_t)-1);
|
||||||
} // ObjectData
|
} // ObjectData
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "vulkan_wrapper.h"
|
#include "vulkan_wrapper.h"
|
||||||
|
|
||||||
#include "matrix4.h"
|
#include "matrix4.h"
|
||||||
|
#include "SColor.h"
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
@ -33,7 +34,10 @@ struct ObjectData
|
|||||||
float m_translation_z;
|
float m_translation_z;
|
||||||
float m_hue_change;
|
float m_hue_change;
|
||||||
float m_rotation[4];
|
float m_rotation[4];
|
||||||
float m_scale[4];
|
float m_scale_x;
|
||||||
|
float m_scale_y;
|
||||||
|
float m_scale_z;
|
||||||
|
irr::video::SColor m_custom_vertex_color;
|
||||||
int m_skinning_offset;
|
int m_skinning_offset;
|
||||||
int m_material_id;
|
int m_material_id;
|
||||||
float m_texture_trans[2];
|
float m_texture_trans[2];
|
||||||
|
Loading…
Reference in New Issue
Block a user