2017-10-23 18:31:42 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
|
|
<title>TP - WebGL</title>
|
|
|
|
<link rel="stylesheet" href="tp.css" type="text/css" media="all">
|
|
|
|
|
|
|
|
<script type="text/javascript" src="webgl-utils.js"></script>
|
|
|
|
<script type="text/javascript" src="webgl-debug.js"></script>
|
|
|
|
<script type="text/javascript" src="J3DI.js"></script>
|
|
|
|
<script type="text/javascript" src="J3DIMath.js"></script>
|
|
|
|
<script type="text/javascript" src="main.js"></script>
|
|
|
|
|
|
|
|
<script id="nuanceurSommets" type="x-shader/x-vertex">
|
2017-10-23 21:34:21 +00:00
|
|
|
uniform mat4 mmodel;
|
|
|
|
uniform mat4 mview;
|
|
|
|
uniform mat4 mproj;
|
2017-10-23 18:31:42 +00:00
|
|
|
uniform vec3 lightDir;
|
|
|
|
|
|
|
|
attribute vec4 vPosition;
|
|
|
|
attribute vec4 vColor;
|
|
|
|
|
|
|
|
varying float v_NdotL;
|
|
|
|
varying vec4 v_color;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
// assigner la position du sommet
|
2017-10-23 21:34:21 +00:00
|
|
|
gl_Position = mproj * mview * mmodel * vPosition;
|
2017-10-23 18:31:42 +00:00
|
|
|
|
|
|
|
// assigner les coordonnées de texture
|
|
|
|
v_color = vColor;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script id="nuanceurFragments" type="x-shader/x-fragment">
|
|
|
|
// informer du degré de précision qu'on veut dans les calculs
|
|
|
|
// (Plus à ce sujet: http://stackoverflow.com/questions/5366416/in-opengl-es-2-0-glsl-where-do-you-need-precision-specifiers/6336285#6336285 )
|
|
|
|
precision mediump float;
|
|
|
|
|
|
|
|
uniform sampler2D laTexture;
|
|
|
|
uniform vec2 positionSouris;
|
|
|
|
|
|
|
|
varying float v_NdotL;
|
|
|
|
varying vec4 v_color;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
// obtenir la couleur de la texture
|
|
|
|
vec4 coul = v_color;
|
|
|
|
if ( length( positionSouris - gl_FragCoord.xy ) < 50.0 )
|
|
|
|
{
|
|
|
|
vec4 coulCercle = vec4( 1.0, 0.0, 0.0, 0.7 );
|
|
|
|
coul = coul * (1.0-coulCercle.a) + coulCercle * coulCercle.a;
|
|
|
|
// coul = coul * coulCercle; // réponse aussi acceptée
|
|
|
|
}
|
|
|
|
gl_FragColor = vec4( coul.rgb, coul.a );
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body onload="TPdebut()">
|
|
|
|
<canvas class="canevas" id="tp-canevas" height="600" width="900">
|
|
|
|
Si vous voyez ceci, votre navigateur ne supporte pas webgl.
|
|
|
|
</canvas>
|
|
|
|
|
|
|
|
<div class="text">Les <a href="http://www.khronos.org/registry/webgl/specs/latest/1.0/">spécifications de Webgl</a> sont<br>remplies d'informations intéressantes.</div>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|