Navigation überspringen
Seiteninhalt:
08 Combined
//$PAGE_TITLE = "WebGL Example Programs";
//$META_DESCRIPTION = "Basic WebGL setup";
$META_KEYWORDS = "webgl,3d,javascript,tutorial,example,snippet";
$LANGUAGES = "en";
$JAVASCRIPT = "required";
?>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
// VERTEX SHADER
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
attribute vec4 aVertexPosition;
attribute vec4 aVertexColor;
attribute vec3 aVertexNormal;
attribute vec2 aTextureCoord;
uniform mat4 uNormalMatrix;
uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
varying lowp vec4 vColor;
varying highp vec2 vTextureCoord;
varying highp vec3 vLighting;
void main () {
gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;
vColor = aVertexColor;
vTextureCoord = aTextureCoord;
highp vec3 ambient_light = vec3( 0.3, 0.3, 0.3 );
highp vec3 directional_light_color = vec3( 1, 1, 1 );
highp vec3 directional_vector = normalize( vec3( 0.85, 0.8, 0.75 ) );
highp vec4 transformed_normal = uNormalMatrix * vec4( aVertexNormal, 1.0 );
highp float directional = max( dot( transformed_normal.xyz, directional_vector ), 0.0 );
vLighting = ambient_light + (directional_light_color * directional);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
// FRAGMENT SHADER
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
varying lowp vec4 vColor;
varying highp vec2 vTextureCoord;
varying highp vec3 vLighting;
uniform sampler2D uSampler;
void main () {
highp vec4 texel_color = texture2D( uSampler, vTextureCoord );
gl_FragColor = vec4( vColor.rgb * texel_color.rgb * vLighting, texel_color.a );
}
Content Management:
μCMS α1.6