Skip to content

Commit

Permalink
Clean up some shader messiness
Browse files Browse the repository at this point in the history
  • Loading branch information
sjackso committed Apr 15, 2019
1 parent 9880e95 commit 22dda03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
28 changes: 3 additions & 25 deletions src/shaders/gooch_wireframe.frag
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ uniform float alpha;

const vec3 kblue = vec3 ( 0, .1, .8 );
const vec3 kyellow = vec3( .7, .7, 0 );
const float gooch_beta = .4;
const float gooch_alpha = .2;
const float gooch_beta = .3;
const float gooch_alpha = .1;

in WireframeVertex {
vec3 position;
Expand All @@ -31,29 +31,6 @@ in WireframeVertex {

out vec4 fragColor;

vec3 adsModel( const in vec3 pos, const in vec3 n )
{
// Calculate the vector from the light to the fragment
// vec3 s = normalize( vec3( light.position ) - pos );

// Calculate the vector from the fragment to the eye position (the
// origin since this is in "eye" or "camera" space
vec3 v = normalize( -pos );
vec3 s = v;

// Refleft the light beam using the normal at this fragment
vec3 r = reflect( -s, n );

// Calculate the diffus component
vec3 diffuse = vec3( max( dot( s, n ), 0.0 ) );

// Calculate the specular component
vec3 specular = vec3( pow( max( dot( r, v ), 0.0 ), shininess ) );

// Combine the ambient, diffuse and specular contributions
return light.intensity * ( ka + kd * diffuse + ks * specular );
}

vec3 goochModel( const in vec3 pos, const in vec3 n )
{
// Based upon the original Gooch lighting model paper at:
Expand All @@ -62,6 +39,7 @@ vec3 goochModel( const in vec3 pos, const in vec3 n )
// Calculate the vector from the fragment to the eye position
// (origin since this is in "eye" or "camera" space)
vec3 v = normalize( -pos );
//vec3 s = normalize( vec3( light.position ) - pos );
vec3 s = v;

// Calculate kcool and kwarm from equation (3)
Expand Down
10 changes: 4 additions & 6 deletions src/shaders/wireframe.geom
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ void main()
float area2 = cross2( p[2]-p[0] , p[2]-p[1] );

// Calculate lengths of 3 edges of triangle
float a = distance( p[1], p[2] ); //length( p[1] - p[2] );
float a = distance( p[1], p[2] );
float b = distance( p[2], p[0] );
float c = distance( p[1], p[0] );

// Calculate internal angles using the cosine rule
/*
float alpha_args = ( b * b + c * c - a * a ) / ( 2.0 * b * c );
float alpha;
if( alpha_args > 1-1e3 ){
Expand All @@ -91,8 +92,9 @@ void main()
}
//float alpha = acos( ( b * b + c * c - a * a ) / ( 2.0 * b * c ) );
//float beta = acos( ( a * a + c * c - b * b ) / ( 2.0 * a * c ) );
*/

float degen_offset = line.width+1.1;
float degen_offset = 0; // line.width+1.1;

// Calculate the perpendicular distance of each vertex from the opposing edge
//float ha = abs( c * sin(beta) );
Expand All @@ -101,10 +103,6 @@ void main()
float ha = max( abs( area2 / a ), degen_offset );
float hb = max( abs( area2 / b ), degen_offset );
float hc = max( abs( area2 / c ), degen_offset );
//float ha = max( degen_offset*gs_in[1].interior, abs( c * sin( beta ) ) );
//float hb = max( degen_offset*gs_in[2].interior, abs( c * sin( alpha ) ) );
//float hc = max( degen_offset*gs_in[0].interior, abs( b * sin( alpha ) ) );


// Now add this perpendicular distance as a per-vertex property in addition to
// the position and normal calculated in the vertex shader.
Expand Down

0 comments on commit 22dda03

Please sign in to comment.