Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Load 'trackball.js'
Browse files Browse the repository at this point in the history
  • Loading branch information
renatocf committed May 10, 2015
1 parent 6014e30 commit 19e695c
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions App/objViewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
<head>
<meta charset="utf-8" />
<title>Simple OBJ Viewer</title>

<link rel="stylesheet" type="text/css" href="objViewer.css">
</head>

<script id="vertex-shader" type="x-shader/x-vertex">
attribute vec4 vPosition;
attribute vec4 vNormal;
varying vec4 fColor;
uniform vec4 ambientProduct;

uniform vec4 ambientProduct;
uniform vec4 diffuseProduct;
uniform vec4 specularProduct;
uniform float shininess;

uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;

// normal matrix
uniform mat4 normalMatrix;

uniform vec4 lightPosition;

// matriz de translacao
Expand All @@ -37,44 +37,44 @@
void main()
{
vec3 pos = -(modelViewMatrix * vPosition).xyz;

// fixed light postion
vec3 light = lightPosition.xyz;
vec3 L = normalize( light - pos );

vec3 E = normalize( -pos );
vec3 H = normalize( L + E );

// transform vertex normal into eye coordinates
vec3 N = normalize( (normalMatrix * vNormal).xyz );

// compute terms in the illumination equation
vec4 ambient = ambientProduct;

float Kd = max( dot(L, N), 0.0 );
vec4 diffuse = Kd * diffuseProduct;

float Ks = pow( max(dot(N, H), 0.0), shininess );
vec4 specular = Ks * specularProduct;

if ( dot(L, N) < 0.0 ) {
specular = vec4(0.0, 0.0, 0.0, 1.0);
}
gl_Position = projectionMatrix * modelViewMatrix
}

gl_Position = projectionMatrix * modelViewMatrix
* scaleMatrix * transMatrix * vPosition;

fColor = ambient + diffuse +specular;

fColor.a = 1.0;
}
</script>

<script id="fragment-shader" type="x-shader/x-fragment">
precision mediump float;

varying vec4 fColor;

void main()
{
gl_FragColor = fColor;
Expand All @@ -84,24 +84,26 @@
<script type="text/javascript" src="../Common/webgl-utils.js"></script>
<script type="text/javascript" src="../Common/initShaders.js"></script>
<script type="text/javascript" src="../Common/MV.js"></script>

<script type="text/javascript" src="objViewer.js"></script>
<script type="text/javascript" src="objReader.js"></script>

<script type="text/javascript" src="quaternion.js"></script>
<script type="text/javascript" src="trackball.js"></script>
<script type="text/javascript" src="matrix.js"></script>

<script type="text/javascript" src="objViewer.js"></script>
<script type="text/javascript" src="objReader.js"></script>

<body>
<div id="gl-wrapper">
<input type="file" id="files" name="files[]" accept=".obj,"></input>

<canvas id="gl-canvas" width="512" height="512">
Oops ... your browser doesn't support the HTML5 canvas element
</canvas>

<button id = "ButtonF">Flat Shading</button>
<button id = "ButtonS">Smooth Shading</button>
<button id = "ButtonN">File Normals</button>

</div>
</body>
</html>

0 comments on commit 19e695c

Please sign in to comment.