﻿// Copyright 2014 Joshua R. Rodgers
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//    http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

attribute vec3 a_vertexPosition;
attribute vec2 a_vertexUV;
attribute vec3 a_vertexNormal;
        
uniform mat4 u_modelMatrix;
uniform mat4 u_viewMatrix;
uniform mat4 u_projectionMatrix;

varying vec2 v_textureCoordinates;
varying float v_lightWeighting;
        
void main(void) {
	vec3 lightDirection = vec3(1, 1, 1);

	v_textureCoordinates = a_vertexUV;
	v_lightWeighting = 0.5 + max(dot(a_vertexNormal, lightDirection), 0.0) * 0.5;

    gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * vec4(a_vertexPosition, 1.0);
}
﻿// Copyright 2014 Joshua R. Rodgers
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//    http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

attribute vec3 a_vertexPosition;
attribute vec2 a_vertexUV;
attribute vec3 a_vertexNormal;
        
uniform mat4 u_modelMatrix;
uniform mat4 u_viewMatrix;
uniform mat4 u_projectionMatrix;

varying vec2 v_textureCoordinates;
varying float v_lightWeighting;
        
void main(void) {
	vec3 lightDirection = normalize(vec3(0, 1, 1));

	v_textureCoordinates = a_vertexUV;
	v_lightWeighting = 0.5 + max(dot(a_vertexNormal, lightDirection), 0.0) * 0.5;

    gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * vec4(a_vertexPosition, 1.0);
}
Normalize the light direction to reduce issues with the light being overly intense.
Normalize the light direction to reduce issues with the light being overly intense.
