1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #version 150
- in vec4 vPosition;
- in vec2 vTexCoord;
- in vec3 vNormal;
- out vec2 texCoord;
- out float fog_factor;
- // output values that will be interpretated per-fragment
- out vec3 fN0;
- out vec3 fE0;
- out vec3 fL0;
- out vec3 fN1;
- out vec3 fE1;
- out vec3 fL1;
- uniform int foggy;
- uniform vec3 eye_pos;
- uniform mat4 model_view;
- uniform mat4 projection;
- void main() {
- texCoord = vTexCoord;
- gl_Position = projection * model_view * vPosition / vPosition.w;
- // light0
- vec4 LightPosition0 = vec4(eye_pos.x, eye_pos.y, eye_pos.z, 1.0);
- fN0 = vNormal;
- fE0 = -(model_view * vPosition).xyz;
- fL0 = LightPosition0.xyz - (model_view * vPosition).xyz;
- // light1
- vec4 LightPosition1 = vec4(0.5, 0.25, 10, 0.0);
- fN1 = vNormal;
- fE1 = -(model_view * vPosition).xyz;
- fL1 = LightPosition1.xyz;
- // fog
- if (foggy > 0) {
- // distance
- float dis = (vPosition.x - eye_pos.x) * (vPosition.x - eye_pos.x) +
- (vPosition.y - eye_pos.y) * (vPosition.y - eye_pos.y) +
- (vPosition.z - eye_pos.z) * (vPosition.z - eye_pos.z);
- fog_factor = exp(-dis);
- } else { // not foggy
- fog_factor = 1.0;
- }
- }
|