#version 460
#extension GL_GOOGLE_include_directive : enable
#include <light.h>
#include <transform.h>
#include "shader-common-generic-lighting.h"
layout (std140, binding = BIND_MATERIAL ) uniform Uni_Material
{
vec4 color_front, color_back;
};
layout ( binding = BIND_BULGE_INFO ) uniform Buldge_Info
{
float bulge_loc;
float bulge_dist_thresh;
float wire_radius;
};
#ifdef BIND_HELIX_COORDS
layout ( binding = BIND_HELIX_COORDS ) buffer Helix_Coord
{ vec4 helix_coord[]; };
#endif
layout ( binding = BIND_TEXUNIT ) uniform sampler2D tex_unit_0;
#ifdef _VERTEX_SHADER_
#ifdef LOC_IN_POS
layout (location = LOC_IN_POS) in vec4 pos;
#define gl_Vertex pos
#endif
#ifdef LOC_IN_INT1
layout ( location = LOC_IN_INT1 ) in int helix_index;
#endif
layout (location = LOC_IN_NORMAL, component = 0) in vec3 inNormal;
#define gl_Normal inNormal
layout (location = LOC_IN_TCOOR) in vec2 texcoord;
#define gl_MultiTexCoord0 texcoord
layout (location = 0) out Data
{
vec3 normal_e;
vec4 vertex_e;
vec2 tex_coord;
int hidx;
};
#endif
#ifdef _FRAGMENT_SHADER_
layout (location = 0) in Data
{
vec3 normal_e;
vec4 vertex_e;
vec2 tex_coord;
int hidx;
};
layout (location = 0) out vec4 frag_color;
#define gl_FragColor frag_color
#endif
#ifdef _VERTEX_SHADER_
#ifdef LOC_IN_POS
void
vs_main_basic()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
vertex_e = gl_ModelViewMatrix * gl_Vertex;
normal_e = normalize(gl_NormalMatrix * gl_Normal);
tex_coord = gl_MultiTexCoord0.xy;
}
#endif
#ifdef BIND_HELIX_COORDS
void
vs_main_helix()
{
hidx = helix_index;
float radius = wire_radius * ( hidx == int(bulge_loc) ? 1.2f : 1.0f );
vec4 vertex_o;
vertex_o.xyz = helix_coord[hidx].xyz + radius * gl_Normal;
vertex_o.w = 1;
gl_Position = gl_ModelViewProjectionMatrix * vertex_o;
vertex_e = gl_ModelViewMatrix * vertex_o;
normal_e = normalize(gl_NormalMatrix * gl_Normal);
tex_coord = gl_MultiTexCoord0.xy;
}
#endif
#endif
#ifdef _FRAGMENT_SHADER_
void
fs_main_phong()
{
vec4 texel = texture(tex_unit_0,tex_coord);
vec4 color = gl_FrontFacing ? color_front : color_back;
vec4 lighted_color = generic_lighting( vertex_e, color, normal_e);
gl_FragColor = texel * lighted_color;
gl_FragDepth = gl_FragCoord.z;
}
#endif