#version 460
#extension GL_GOOGLE_include_directive : enable
#include <light.h>
#include "shader-common-generic-lighting.h"
layout ( binding = BIND_TRANSFORM ) uniform Uni_Transform
{
mat4 eye_from_object; mat4 clip_from_eye; mat4 clip_from_object; mat4 object_from_eye; mat4 eye_from_clip; mat4 object_from_clip; };
layout (binding = BIND_MAT_COLOR ) uniform Uni_Material
{
vec4 color_front, color_back;
};
#ifdef _VERTEX_SHADER_
layout ( location = LOC_IN_POS ) in vec4 in_vertex;
layout ( location = LOC_IN_NORMAL ) in vec3 in_normal;
layout ( location = LOC_IN_TCOOR ) in vec2 in_tcoor;
layout (location = 0) out VF
{
vec4 vertex_e;
vec3 normal_e;
vec2 texcoord;
} Out;
void
vs_main_phong()
{
gl_Position = clip_from_object * in_vertex;
Out.vertex_e = eye_from_object * in_vertex;
Out.normal_e = normalize( mat3(eye_from_object) * in_normal );
Out.texcoord = in_tcoor;
}
#endif
#ifdef _FRAGMENT_SHADER_
layout ( binding = BIND_TEXUNIT ) uniform sampler2D tex_unit_0;
layout ( location = 0 ) in VF
{
vec4 vertex_e;
vec3 normal_e;
vec2 texcoord;
} In;
layout ( location = 0 ) out vec4 out_frag_color;
void
fs_main_phong()
{
vec4 texel = texture( tex_unit_0, In.texcoord );
vec4 our_color = gl_FrontFacing ? color_front : color_back;
vec4 lighted_color = generic_lighting( In.vertex_e, our_color, In.normal_e );
out_frag_color = texel * lighted_color;
}
#endif