rework model VS

main
Dominik Madarász 2024-08-24 19:19:18 +02:00
parent 7ceab7fe0f
commit 5d0ed47b3a
2 changed files with 20 additions and 11 deletions

View File

@ -33,7 +33,6 @@ uniform ColorMap map_emissive; uniform sampler2D map_emissive_tex;
uniform float skysphere_rotation; /// set:0 uniform float skysphere_rotation; /// set:0
uniform float skysphere_mip_count; uniform float skysphere_mip_count;
uniform float exposure; /// set:1 uniform float exposure; /// set:1
uniform uint frame_count;
uniform float specular_shininess; uniform float specular_shininess;
uniform sampler2D tex_skysphere; uniform sampler2D tex_skysphere;

View File

@ -6,6 +6,7 @@
void main() { void main() {
vec3 objPos = get_object_pos(); vec3 objPos = get_object_pos();
// Set attributes up
v_normal_ws = normalize(vec3(att_instanced_matrix * vec4(v_normal, 0.))); // normal to world/model space v_normal_ws = normalize(vec3(att_instanced_matrix * vec4(v_normal, 0.))); // normal to world/model space
v_normal = normalize(v_normal); v_normal = normalize(v_normal);
v_position = att_position; v_position = att_position;
@ -15,22 +16,31 @@ void main() {
mat4 modelView = view * att_instanced_matrix; mat4 modelView = view * att_instanced_matrix;
mat4 l_model = att_instanced_matrix; mat4 l_model = att_instanced_matrix;
v_position_ws = (l_model * vec4( objPos, 1.0 )).xyz; v_position_ws = (l_model * vec4( objPos, 1.0 )).xyz;
vec3 binormal = cross(att_normal, att_tangent.xyz) * att_tangent.w;
v_binormal = normalize(mat3(att_instanced_matrix) * binormal);
// Optional: Billboarding
{
billboard_t bb = setup_billboard(modelView, l_model); billboard_t bb = setup_billboard(modelView, l_model);
modelView = bb.modelView; modelView = bb.modelView;
l_model = bb.l_model; l_model = bb.l_model;
v_position_ws = (l_model * vec4( objPos, 1.0 )).xyz; v_position_ws = (l_model * vec4( objPos, 1.0 )).xyz;
v_tangent = normalize(mat3(att_instanced_matrix) * att_tangent.xyz); v_tangent = normalize(mat3(att_instanced_matrix) * att_tangent.xyz);
}
vec3 binormal = cross(att_normal, att_tangent.xyz) * att_tangent.w; // Compute lighting (vertex-lit models)
v_binormal = normalize(mat3(att_instanced_matrix) * binormal); material_t dummy_mat;
v_vertcolor = lighting(dummy_mat);
// Compute final position and camera vector
vec4 finalPos = modelView * vec4( objPos, 1.0 ); vec4 finalPos = modelView * vec4( objPos, 1.0 );
vec3 to_camera = normalize( -finalPos.xyz ); vec3 to_camera = normalize( -finalPos.xyz );
v_to_camera = mat3( inv_view ) * to_camera; v_to_camera = mat3( inv_view ) * to_camera;
material_t dummy_mat;
v_vertcolor = lighting(dummy_mat); // Set final position
gl_Position = P * finalPos; gl_Position = P * finalPos;
// Prepare shadow data for shadow mapping
do_shadow(); do_shadow();
} }