Sha256: cb033ec0a09accb4b8489118d28407239fca567bd0dfdff93afbe297da6b0528

Contents?: true

Size: 950 Bytes

Versions: 12

Compression:

Stored size: 950 Bytes

Contents

void main(inout vec4 ambient, inout vec4 diffuse, inout vec4 specular) {
  // 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%>) return;
  
  vec3 nLightDir = normalize(vLightDir);
  vec3 nEyeDir = normalize(vEyeDir);
  vec4 color = texture2D(NormalMap, vTexCoords);
  vec3 map = //nMatrix * 
             normalize(color.xyz * 2.0 - 1.0);
             
  float litColor = max(dot(map, nLightDir), 0.0) * vAttenuation;

  // specular
  vec3 reflectDir = reflect(nLightDir, map);
  float spec = max(dot(nEyeDir, reflectDir), 0.0);
  spec = pow(spec, materialShininess);

  // Treat alpha in the normal map as a specular map; if it's unused it will be 1 and this
  // won't matter.
  spec *= color.a;
  
  diffuse *= litColor;
  specular *= spec;
}

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
jax-1.0.1.rc1 builtin/shaders/normal_map/fragment.ejs
jax-1.0.0 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.10 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.9 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.8 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.7 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.6 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.5 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.4 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.3 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.2 builtin/shaders/normal_map/fragment.ejs
jax-0.0.0.1 builtin/shaders/normal_map/fragment.ejs