#if 0
@@ -382,7 +382,7 @@ World::init()
pipe_plain
.init( vh.qs ).ds_use_texture().ds_set_material().ds_use( uni_light )
.ds_uniform_use( "BIND_BULGE_INFO", buf_bulge_info )
- .shader_inputs_info_set<pCoor,pNorm,pTCoor>()
+ .shader_inputs_info_set<int,pCoor,pNorm,pTCoor>()
.shader_code_set
("demo-10-shdr-ngeo.cc", "vs_main_basic(); ", #endif
#version 460
#extension GL_GOOGLE_include_directive : enable
#include <light.h>
#include <transform.h>
#include "shader-common-generic-lighting.h"
layout ( 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;
bool opt_texture;
};
#ifdef _VERTEX_SHADER_
layout (location = LOC_IN_NORMAL) in vec3 in_normal_o;
layout (location = LOC_IN_TCOOR) in vec2 in_tex_coord;
layout (location = 0) out Data
{
vec3 normal_e;
vec4 vertex_e;
vec2 tex_coord;
int hidx;
} Out;
#ifdef LOC_IN_POS
layout (location = LOC_IN_INT1 ) in int in_idx;
layout (location = LOC_IN_POS) in vec4 inn_vertex_o;
void
vs_main_basic()
{
int current_loc = in_idx;
float distance = abs( float(in_idx) - bulge_loc );
float dist_th = 2.12;
bool sufficiently_close = distance <= dist_th;
vec4 in_vertex_o = inn_vertex_o;
if ( sufficiently_close )
in_vertex_o.xyz += (dist_th - distance ) * wire_radius * in_normal_o;
gl_Position = ut.clip_from_object * in_vertex_o;
Out.vertex_e = ut.eye_from_object * in_vertex_o;
Out.normal_e = normalize(mat3(ut.eye_from_object) * in_normal_o);
Out.tex_coord = in_tex_coord;
}
#endif
#ifdef BIND_HELIX_COORDS
layout ( binding = BIND_HELIX_COORDS ) buffer Helix_Coord
{ vec4 helix_coord[]; };
layout ( location = LOC_IN_INT1 ) in int in_helix_index;
void
vs_main_helix()
{
Out.hidx = in_helix_index;
float radius =
wire_radius * ( in_helix_index == int(bulge_loc) ? 1.2f : 1.0f );
vec4 vertex_o;
vertex_o.xyz = helix_coord[in_helix_index].xyz + radius * in_normal_o;
vertex_o.w = 1;
gl_Position = ut.clip_from_object * vertex_o;
Out.vertex_e = ut.eye_from_object * vertex_o;
Out.normal_e = normalize(mat3(ut.eye_from_object) * in_normal_o);
Out.tex_coord = in_tex_coord;
}
#endif
#endif
#ifdef _FRAGMENT_SHADER_
layout ( binding = BIND_TEXUNIT ) uniform sampler2D tex_unit_0;
layout (location = 0) in Data
{
vec3 normal_e;
vec4 vertex_e;
vec2 tex_coord;
int hidx;
} In;
layout (location = 0) out vec4 out_frag_color;
void
fs_main_phong()
{
vec4 texel = opt_texture ? texture(tex_unit_0,In.tex_coord) : vec4(1,1,1,1);
vec4 color = gl_FrontFacing ? color_front : color_back;
vec4 lighted_color = generic_lighting( In.vertex_e, color, In.normal_e);
out_frag_color = opt_texture ? texel * lighted_color : lighted_color;
}
#endif