Sha256: 46d49e3e7e0593779f53ad0744414676610dc330c26935bf1a3cfa7bdf69165a

Contents?: true

Size: 1.8 KB

Versions: 18

Compression:

Stored size: 1.8 KB

Contents

shared attribute vec4 VERTEX_POSITION;
shared attribute vec2 VERTEX_TEXCOORDS;
shared attribute vec4 VERTEX_TANGENT;
shared attribute vec3 VERTEX_NORMAL;

void main(void) {
  // ambient was applied by the basic shader; applying it again will simply brighten some fragments
  // beyond their proper ambient value. So, we really need to apply the bump shader ONLY to diffuse+specular.

  if (PASS_TYPE != <%=Jax.Scene.AMBIENT_PASS%>) {
    vec3 ecPosition = vec3(mvMatrix * VERTEX_POSITION);

    gl_Position = pMatrix * mvMatrix * VERTEX_POSITION;
    vTexCoords = VERTEX_TEXCOORDS;

    vEyeDir = vec3(mvMatrix * VERTEX_POSITION);
  
    vec3 n = normalize(nMatrix * VERTEX_NORMAL);
    vec3 t = normalize(nMatrix * VERTEX_TANGENT.xyz);
    vec3 b = cross(n, t) * VERTEX_TANGENT.w;
  
    vec3 v, p;
  
    vAttenuation = 1.0;
  
    if (LIGHT_TYPE == <%=Jax.POINT_LIGHT%>)
      if (LIGHT_ATTENUATION_CONSTANT == 1.0 && LIGHT_ATTENUATION_LINEAR == 0.0 && LIGHT_ATTENUATION_QUADRATIC == 0.0) {
        // no change to attenuation, but we still need P
        p = vec3(ivMatrix * vec4(LIGHT_POSITION, 1.0)) - ecPosition;
      }
      else {
        // attenuation calculation figures out P for us, so we may as well use it
        vAttenuation = calcAttenuation(ecPosition, p);
      }
    else
      if (LIGHT_TYPE == <%=Jax.SPOT_LIGHT%>) {
        // attenuation calculation figures out P for us, so we may as well use it
        vAttenuation = calcAttenuation(ecPosition, p);
      }
      else
      { // directional light -- all we need is P
        p = vec3(vnMatrix * -normalize(LIGHT_DIRECTION));
      }
    
    
    
    v.x = dot(p, t);
    v.y = dot(p, b);
    v.z = dot(p, n);
    vLightDir = normalize(p);
  
    v.x = dot(vEyeDir, t);
    v.y = dot(vEyeDir, b);
    v.z = dot(vEyeDir, n);
    vEyeDir = normalize(v);
  }
}

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
jax-2.0.12 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.11 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.10 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.9 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.8 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.7 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.6 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.5 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.4 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.3 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.2 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.1 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-2.0.0 lib/assets/javascripts/shaders/normal_map/vertex.glsl
jax-1.1.1 builtin/app/shaders/normal_map/vertex.ejs
jax-1.1.0 builtin/app/shaders/normal_map/vertex.ejs
jax-1.1.0.rc1 builtin/app/shaders/normal_map/vertex.ejs
jax-1.0.1 builtin/shaders/normal_map/vertex.ejs
jax-1.0.1.rc2 builtin/shaders/normal_map/vertex.ejs