Ignore:
Timestamp:
06/29/13 20:32:29 (12 years ago)
Author:
epyon
Message:
  • program - set_opt_uniform added
  • example extended to feature per-pixel lighting, self-illumination mapping, specular mapping and dual custom colors mapping
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/objload_test/obj.vert

    r137 r139  
    11#version 120
     2
    23attribute vec3 position;
    34attribute vec2 texcoord;
    45attribute vec3 normal;
    5 varying vec2 f_texcoord;
    6 varying float f_diffuse_value;
     6
     7varying vec3 v_normal;
     8varying vec3 v_light_vector;
     9varying vec3 v_view_vector;
     10varying vec2 v_texcoord;
     11
    712uniform mat4 matrix_mvp;
    8 uniform vec3 light;
     13uniform mat4 nv_m_modelview;
     14uniform mat4 nv_m_projection;
     15uniform mat3 nv_m_normal;
     16uniform vec3 light_position;
    917
    1018void main(void) {
    11         vec3 vnormal    = normalize(normal);
    12         vec3 vlight     = normalize(light - position);
    13         float diffuse   = max(dot(vlight, vnormal), 0.0);
    14         f_diffuse_value = diffuse;
    15         f_texcoord      = texcoord;
    16         gl_Position     = matrix_mvp * vec4(position, 1.0);
     19        vec4 vertex     = vec4( position, 1.0 );
     20        vec3 eye_pos    = vec3( nv_m_modelview * vertex );
     21        v_normal        = normalize( nv_m_normal * normal );
     22        v_light_vector  = vec3( normalize( light_position - eye_pos ) );
     23        v_view_vector   = vec3( normalize( -eye_pos ) );
     24
     25        v_texcoord      = texcoord;
     26        gl_Position     = matrix_mvp * vertex;
    1727}
Note: See TracChangeset for help on using the changeset viewer.