All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jogamp.opengl.util.glsl.fixedfunc.shaders.FixedFuncColorLight.vp Maven / Gradle / Ivy

The newest version!

#if __VERSION__ >= 130
  #define attribute in
  #define varying out
#endif

#include es_precision.glsl
#include mgl_lightdef.glsl

#include mgl_const.glsl
#include mgl_uniform.glsl
#include mgl_uniform_light.glsl
#include mgl_attribute.glsl
#include mgl_varying.glsl

#include mgl_settexcoord.vp

void main(void)
{
  vec4 position;
  vec3 normal, lightDir, cameraDir, halfDir;
  vec4 ambient, diffuse, specular;
  float NdotL, NdotHV, dist, attenuation;
  int i;

  position  = mgl_PMVMatrix[1] * mgl_Vertex; // vertex eye position 

  normal = normalize(mgl_PMVMatrix[3] * mgl_Normal).xyz; 
  // cameraPosition:      (mgl_PMVMatrix[2] * vec4(0,0,0,1.0)).xyz                   
  cameraDir  = normalize( (mgl_PMVMatrix[2] * vec4(0,0,0,1.0)).xyz - mgl_Vertex.xyz ); 

  ambient = vec4(0,0,0,0);
  diffuse = vec4(0,0,0,0);
  specular = vec4(0,0,0,0);

  bool lightEnabled = false;

  for(i=0; i0) {
    frontColor=mgl_Color;
  } else {
    frontColor=mgl_ColorStatic;
  }
  if( lightEnabled ) {
    //                   light-ambient                               +                 global-ambient
    // ( mgl_LightSource[0..n].ambient * mgl_FrontMaterial.ambient ) + ( mgl_LightModel.ambient * mgl_FrontMaterial.ambient )
    ambient   = ( ambient + mgl_LightModel.ambient ) * mgl_FrontMaterial.ambient;
    diffuse  *= mgl_FrontMaterial.diffuse;
    specular *= mgl_FrontMaterial.specular;

    frontColor *= ambient + diffuse + specular;
  }

  gl_Position  = mgl_PMVMatrix[0] * position;

  setTexCoord(gl_Position);
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy