SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
L'animation Newschool en HTML5
Sommaire
● Oldschool / Newschool
● Canvas
● SVG
● WebGL
Qui... est Christophe Villeneuve ?
Newschool
Old school
Canvas
● HTML : Graphics
– Canvas 2D
– Canvas 3D (WebGL)
– SVG
Canvas
● Format Bitmap dynamique
● Gestion par pixels
● Permet de dessiner dans une résolution précise
● Unique nœud dans le DOM...
Exemple HTML5
3b
Elément : Canvas
<canvas id='animation' width='320' height='200'>
Navigateur non compatible
</canvas>
<script type="text/javascript">
var canvas = document.getElementById('animation');
var demo = canvas.getContext('2d');
</script>
Scrolltext simple... demo
4
2
Newschool : Scrolltext horizontal
var debut = 100;
var text = "(c) Hello / Sector One – VIP 2014";
function boucle()
{
demo.fillRect(0,0,640,480);
i = 0;
demo.font = "30px arial";
demo.fillStyle = "rgb(255,255,255)";
<!-- Boucle while ici -->
debut++;
demo.fillStyle = "rgb(0,0,0)";
}
setInterval(boucle, 40);
●
while(i < text.length)
{
var left = (800 - (debut * 2)) + (i *
25);
demo.fillText(
text.charAt(i),
left ,
100
);
if (i == text.length-1 && left < 0)
debut = 0 ;
i++;
}
Amélioré le résultat par les fonctions
grd=demo.createLinearGradient(100,100,100,250);
grd.addColorStop(0,'rgba(0,128,255,128)');
grd.addColorStop(1,"#770000" );
demo.fillStyle = grd;
Dégradés linéaires
demo.fillText(
text.charAt(i),
left ,
150 + (Math.sin(((pas + i ) / 60) * Math.PI) * 50)
);
pas++;
Effet sur le texte... par exemple... Une vague en Y
Résultat amélioré
5
3
Les objets en HTML5
● Cercle
● Carré
● Ligne
Utilisation
– BeginPath();
– arc(x, y, radius,
startAngle, endAngle,
counterClockwise);
– LineWidth = 15;
– strokeStyle = couleur;
– stroke();
Objets : Cercle
var ex = canvas.getContext('2d');
var centerX = canvas.width / 2;
var centerY = canvas.height / 2;
var radius = 70;
ex.beginPath();
ex.arc(centerX, centerY, radius, 0, 2 *
Math.PI, false);
ex.fillStyle = '#00FFFF';
ex.fill();
ex.lineWidth = 10;
ex.strokeStyle = '#000000';
ex.stroke();
Objets : Arc de cercle
var ex = canvas.getContext('2d');
var x = canvas.width / 2;
var y = canvas.height / 2;
var radius = 75;
var startAngle = 1.1 * Math.PI;
var endAngle = 1.9 * Math.PI;
var counterClockwise = false;
ex.beginPath();
ex.arc(x, y, radius, startAngle, endAngle,
counterClockwise);
ex.lineWidth = 15;
ex.strokeStyle = 'black';
ex.stroke();
Avec plusieurs objets... mode superposé
ex.fillStyle="red";
ex.fillRect(20,20,75,50);
ex.globalCompositeOperation="source-over";
ex.fillStyle="blue";
ex.fillRect(50,50,75,50);
ex.fillStyle="red";
ex.fillRect(150,20,75,50);
ex.globalCompositeOperation="destination-o
ver";
ex.fillStyle="blue";
ex.fillRect(180,50,75,50); Résultat
Element : globalCompositeOperation
Exemple globalCompositeOperation
8
4
Explications
with (graphics) {
ratio = width / height;
globalCompositeOperation = 'xor';
scale(width / 2 / ratio, height / 2);
translate(ratio, 1);
lineWidthFactor = 45 / height;
Lignes mélangés mode additif
For (position ligne par ligne) {
Begin nouveau point
For (point par point) {
Calcul de forme par rapport à la sphere (x,y,z)
Enlever le contour x,y,z
Transition, superposition en x,y,z
Affiche du point 2D en x,y
Définit la couleur et luminosité des points: (r,g,b) (w,l)
If (point en 1er
plan) {
If (point visible par rapport aux autre lignes) {
Affiche le segment en x,y
}
}
else {
Cache le point
}
Position du point départ ligne x,y
}
}
Calcul position par rapport au canvas
Amélioré le résultat par les fonctions
<audio src="zik.mp3" autoplay>
Navigateur non compatible pour l'audio
</audio>
Musique
ScrollText
Animation + musique
10
SVG
● Signifie Scalable Vector Graphics
● Gère les images au format léger
● Format vectoriel en XML
● Mémorise le 'graph' objet en mémoire dans le
DOM
● Couplage à CSS
Les bases du SVG
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<text x="5" y="190"
transform="translate(40) rotate(-45 10 50)"
>Very Important Party</text>
</svg>
Texte
Habillage
<rect x="40" y="5" height="110" width="110"
style="stroke:#ff0000; fill: #CFCFCF;"
transform="translate(30) rotate(28 50 35)">
</rect>
Habiller le SVG
<defs>
<linearGradient id="effetgradient"
x1="0%" y1="20%"
x2="10%" y2="100%"
spreadMethod="pad">
<stop offset="0%" stop-color="#FF44AA"
stop-opacity="1"/>
<stop offset="100%" stop-color="#000066"
stop-opacity="1"/>
</linearGradient>
</defs>
<rect x="10" y="10" width="75" height="100"
rx="10" ry="10"
style="fill:url(#effetgradient);
stroke: #005000;
stroke-width: 2;" />
Animer le SVG
50
Le code de l'animation SVG
<svg>
<rect width="100" height="50">
<animate attributeName="width"
attributeType="XML"
fill="freeze"
from="0" to="300"
begin="0s" dur="3s"/>
</rect>
</svg>
On bouge avec le SVG
51
WebGL
● Balise canvas
● Couplage avec Blender ou logiciel modelage
● 3D
● Sharders
●
WebGL façon simple
<canvas id='balisewebgl'></canvas>
<script>
var balisewebgl =
document.getElementById('balisewebgl');
var webGL =
balisewebgl.getContext('experimental-webgl');
webGL.clearColor(0,1,0,1);
webGL.clear(webGL.COLOR_BUFFER_BIT);
</script>
Shader en 3D
62
Explication exemple : The vertex shader (1/2)
<script id="shader-vs"
type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;
attribute vec2 aTextureCoord;
shader execution.
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform float fTime;
//interpolation
varying vec4 vColor;
// Coordonnées de la texture
varying vec2 vTextureCoord;
● void main(void) {
● vec3 pos=aVertexPosition;
● // -- définir les coordonnées X et Y et Z
● pos.x += cos(fTime + (aVertexPosition.z/4.0));
● pos.y += sin(fTime + (aVertexPosition.z/4.0));
● // -- transforme the vertex
● gl_Position = uPMatrix * uMVMatrix * vec4(pos,
1.0);
●
● vColor = aVertexColor;
● // Simule l'illusion de mouvemnt
● vec2 texcoord=aTextureCoord;
● texcoord.y = texcoord.y + (fTime);
●
● // -- copier la texture
● vTextureCoord = texcoord;
● }
● </script>
Explication exemple : Fragment shader (2/2)
<script id="shader-fs" type="x-shader/x-fragment">
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D uSampler;
varying vec4 vColor;
varying vec2 vTextureCoord;
void main(void) {
// -- récupère la valeur du pixel
vec4 textureColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
// -- multiplie le pixel texture avec la couleur du vertex
gl_FragColor = vColor * textureColor;
}
</script>
Cube
64
Explication Cube
Pas de commentaires
Merci
● Code source inspiré du web
Questions
@hellosct1
@neuro_paris

Contenu connexe

En vedette (9)

Tv magazines
Tv magazinesTv magazines
Tv magazines
 
Evaluation
EvaluationEvaluation
Evaluation
 
Firefox OS 1.1 L'autre systeme pour smartphone
Firefox OS 1.1 L'autre systeme pour smartphoneFirefox OS 1.1 L'autre systeme pour smartphone
Firefox OS 1.1 L'autre systeme pour smartphone
 
Firefox OS dans le web - Journée du libre 2015 Lille
Firefox OS dans le web - Journée du libre 2015  LilleFirefox OS dans le web - Journée du libre 2015  Lille
Firefox OS dans le web - Journée du libre 2015 Lille
 
равжаагийн намтар уран бүтээл.Odt
равжаагийн намтар уран бүтээл.Odtравжаагийн намтар уран бүтээл.Odt
равжаагийн намтар уран бүтээл.Odt
 
Le nouveau AMP : apache mariadb php
Le nouveau AMP : apache mariadb phpLe nouveau AMP : apache mariadb php
Le nouveau AMP : apache mariadb php
 
Ravjaagiin namtar uran buteel
Ravjaagiin namtar uran buteelRavjaagiin namtar uran buteel
Ravjaagiin namtar uran buteel
 
равжаагийн намтар уран бүтээл.Odt
равжаагийн намтар уран бүтээл.Odtравжаагийн намтар уран бүтээл.Odt
равжаагийн намтар уран бүтээл.Odt
 
Tour operators in tehran iran
Tour operators in tehran iranTour operators in tehran iran
Tour operators in tehran iran
 

Similaire à L'animation newschool en html5

#nwxtech6 Frédéric Bisson - SVG pour le web
#nwxtech6 Frédéric Bisson - SVG pour le web#nwxtech6 Frédéric Bisson - SVG pour le web
#nwxtech6 Frédéric Bisson - SVG pour le web
Normandie Web Xperts
 
Création d'une application html5 utilisant canvas, svg et les animations css3
Création d'une application html5 utilisant canvas, svg et les animations css3Création d'une application html5 utilisant canvas, svg et les animations css3
Création d'une application html5 utilisant canvas, svg et les animations css3
davrous
 
Enib cours c.a.i. web - séance #1 - html5 css3-js - 2
Enib   cours c.a.i. web - séance #1 - html5 css3-js - 2Enib   cours c.a.i. web - séance #1 - html5 css3-js - 2
Enib cours c.a.i. web - séance #1 - html5 css3-js - 2
Horacio Gonzalez
 
Atelier autour de UWA à ParisWeb 2007
Atelier autour de UWA à ParisWeb 2007Atelier autour de UWA à ParisWeb 2007
Atelier autour de UWA à ParisWeb 2007
Netvibes
 
Futur du-positionnement-css
Futur du-positionnement-cssFutur du-positionnement-css
Futur du-positionnement-css
Raphaël Goetter
 

Similaire à L'animation newschool en html5 (20)

Trois avancées majeures en CSS3 : Mediaqueries, Grid Layout et Animations (MS...
Trois avancées majeures en CSS3 : Mediaqueries, Grid Layout et Animations (MS...Trois avancées majeures en CSS3 : Mediaqueries, Grid Layout et Animations (MS...
Trois avancées majeures en CSS3 : Mediaqueries, Grid Layout et Animations (MS...
 
Trois avancées majeures en CSS3 : Media Queries, Grid Layout et Animations
Trois avancées majeures en CSS3 : Media Queries, Grid Layout et AnimationsTrois avancées majeures en CSS3 : Media Queries, Grid Layout et Animations
Trois avancées majeures en CSS3 : Media Queries, Grid Layout et Animations
 
#nwxtech6 Frédéric Bisson - SVG pour le web
#nwxtech6 Frédéric Bisson - SVG pour le web#nwxtech6 Frédéric Bisson - SVG pour le web
#nwxtech6 Frédéric Bisson - SVG pour le web
 
#nwxtech6 Frédéric Bisson - SVG pour le web
#nwxtech6 Frédéric Bisson - SVG pour le web#nwxtech6 Frédéric Bisson - SVG pour le web
#nwxtech6 Frédéric Bisson - SVG pour le web
 
Création d'une application html5 utilisant canvas, svg et les animations css3
Création d'une application html5 utilisant canvas, svg et les animations css3Création d'une application html5 utilisant canvas, svg et les animations css3
Création d'une application html5 utilisant canvas, svg et les animations css3
 
Introduction a jQuery
Introduction a jQueryIntroduction a jQuery
Introduction a jQuery
 
Newschool partie1 methode HTML5
Newschool partie1 methode HTML5Newschool partie1 methode HTML5
Newschool partie1 methode HTML5
 
Développement Web - HTML5, CSS3, APIs Web
Développement Web - HTML5, CSS3, APIs WebDéveloppement Web - HTML5, CSS3, APIs Web
Développement Web - HTML5, CSS3, APIs Web
 
HTML5, le nouveau buzzword
HTML5, le nouveau buzzwordHTML5, le nouveau buzzword
HTML5, le nouveau buzzword
 
Gagnez en productivité grâce aux préprocesseurs css
Gagnez en productivité grâce aux préprocesseurs cssGagnez en productivité grâce aux préprocesseurs css
Gagnez en productivité grâce aux préprocesseurs css
 
Enib cours c.a.i. web - séance #1 - html5 css3-js - 2
Enib   cours c.a.i. web - séance #1 - html5 css3-js - 2Enib   cours c.a.i. web - séance #1 - html5 css3-js - 2
Enib cours c.a.i. web - séance #1 - html5 css3-js - 2
 
CSS Facile : organiser ses feuilles de style
CSS Facile : organiser ses feuilles de styleCSS Facile : organiser ses feuilles de style
CSS Facile : organiser ses feuilles de style
 
Introduction à TileMill
Introduction à TileMillIntroduction à TileMill
Introduction à TileMill
 
Atelier autour de UWA à ParisWeb 2007
Atelier autour de UWA à ParisWeb 2007Atelier autour de UWA à ParisWeb 2007
Atelier autour de UWA à ParisWeb 2007
 
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et JavascriptCodedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
 
Javascript #9 : barbarian quest
Javascript #9 : barbarian questJavascript #9 : barbarian quest
Javascript #9 : barbarian quest
 
Barbie explique IEEE754 : pourquoi les calculs informatiques sont faux!
Barbie explique IEEE754 : pourquoi les calculs informatiques sont faux!Barbie explique IEEE754 : pourquoi les calculs informatiques sont faux!
Barbie explique IEEE754 : pourquoi les calculs informatiques sont faux!
 
Microsoft Composition, pierre angulaire de vos applications ?
Microsoft Composition, pierre angulaire de vos applications ?Microsoft Composition, pierre angulaire de vos applications ?
Microsoft Composition, pierre angulaire de vos applications ?
 
Le futur du Responsive Web Design
Le futur du Responsive Web DesignLe futur du Responsive Web Design
Le futur du Responsive Web Design
 
Futur du-positionnement-css
Futur du-positionnement-cssFutur du-positionnement-css
Futur du-positionnement-css
 

Plus de Christophe Villeneuve

Plus de Christophe Villeneuve (20)

MariaDB une base de donnees NewSQL
MariaDB une base de donnees NewSQLMariaDB une base de donnees NewSQL
MariaDB une base de donnees NewSQL
 
La boîte à outils de développements dans Firefox
La boîte à outils de développements dans FirefoxLa boîte à outils de développements dans Firefox
La boîte à outils de développements dans Firefox
 
pister les pisteurs
pister les pisteurspister les pisteurs
pister les pisteurs
 
controler vos donnees éthiques dans le web
controler vos donnees éthiques dans le webcontroler vos donnees éthiques dans le web
controler vos donnees éthiques dans le web
 
Infrastructure as code drupal
Infrastructure as code drupalInfrastructure as code drupal
Infrastructure as code drupal
 
Mariadb une base de données NewSQL
Mariadb une base de données NewSQLMariadb une base de données NewSQL
Mariadb une base de données NewSQL
 
Open Source et contribution : Une association gagnante
Open Source et contribution : Une association gagnanteOpen Source et contribution : Une association gagnante
Open Source et contribution : Une association gagnante
 
Pentest bus pirate
Pentest bus piratePentest bus pirate
Pentest bus pirate
 
Peur de la migration vers l’open source ?
Peur de la migration vers l’open source ?Peur de la migration vers l’open source ?
Peur de la migration vers l’open source ?
 
La sécurité applicative par le design
La sécurité applicative par le designLa sécurité applicative par le design
La sécurité applicative par le design
 
Foxfooding semaine 3
Foxfooding semaine 3Foxfooding semaine 3
Foxfooding semaine 3
 
Foxfooding
FoxfoodingFoxfooding
Foxfooding
 
Accessibilite web wcag rgaa
Accessibilite web wcag rgaaAccessibilite web wcag rgaa
Accessibilite web wcag rgaa
 
Mozilla french speaking community activites
Mozilla french speaking community activitesMozilla french speaking community activites
Mozilla french speaking community activites
 
Monitoring dynamique : Grafana et Microsoft
Monitoring dynamique : Grafana et MicrosoftMonitoring dynamique : Grafana et Microsoft
Monitoring dynamique : Grafana et Microsoft
 
Etes vous-pret pour php8 ?
Etes vous-pret pour php8 ?Etes vous-pret pour php8 ?
Etes vous-pret pour php8 ?
 
Le futur de l'authentification webAuthn
Le futur de l'authentification webAuthnLe futur de l'authentification webAuthn
Le futur de l'authentification webAuthn
 
Send large files with addons
Send large files with addonsSend large files with addons
Send large files with addons
 
Tests d'accessibilite par la pratique
Tests d'accessibilite par la pratiqueTests d'accessibilite par la pratique
Tests d'accessibilite par la pratique
 
Donnez la voix aux machines
Donnez la voix aux machinesDonnez la voix aux machines
Donnez la voix aux machines
 

L'animation newschool en html5

  • 2. Sommaire ● Oldschool / Newschool ● Canvas ● SVG ● WebGL
  • 3. Qui... est Christophe Villeneuve ?
  • 6.
  • 7. Canvas ● HTML : Graphics – Canvas 2D – Canvas 3D (WebGL) – SVG
  • 8. Canvas ● Format Bitmap dynamique ● Gestion par pixels ● Permet de dessiner dans une résolution précise ● Unique nœud dans le DOM...
  • 10. Elément : Canvas <canvas id='animation' width='320' height='200'> Navigateur non compatible </canvas> <script type="text/javascript"> var canvas = document.getElementById('animation'); var demo = canvas.getContext('2d'); </script>
  • 12. Newschool : Scrolltext horizontal var debut = 100; var text = "(c) Hello / Sector One – VIP 2014"; function boucle() { demo.fillRect(0,0,640,480); i = 0; demo.font = "30px arial"; demo.fillStyle = "rgb(255,255,255)"; <!-- Boucle while ici --> debut++; demo.fillStyle = "rgb(0,0,0)"; } setInterval(boucle, 40); ● while(i < text.length) { var left = (800 - (debut * 2)) + (i * 25); demo.fillText( text.charAt(i), left , 100 ); if (i == text.length-1 && left < 0) debut = 0 ; i++; }
  • 13. Amélioré le résultat par les fonctions grd=demo.createLinearGradient(100,100,100,250); grd.addColorStop(0,'rgba(0,128,255,128)'); grd.addColorStop(1,"#770000" ); demo.fillStyle = grd; Dégradés linéaires demo.fillText( text.charAt(i), left , 150 + (Math.sin(((pas + i ) / 60) * Math.PI) * 50) ); pas++; Effet sur le texte... par exemple... Une vague en Y
  • 15. Les objets en HTML5 ● Cercle ● Carré ● Ligne Utilisation – BeginPath(); – arc(x, y, radius, startAngle, endAngle, counterClockwise); – LineWidth = 15; – strokeStyle = couleur; – stroke();
  • 16. Objets : Cercle var ex = canvas.getContext('2d'); var centerX = canvas.width / 2; var centerY = canvas.height / 2; var radius = 70; ex.beginPath(); ex.arc(centerX, centerY, radius, 0, 2 * Math.PI, false); ex.fillStyle = '#00FFFF'; ex.fill(); ex.lineWidth = 10; ex.strokeStyle = '#000000'; ex.stroke();
  • 17. Objets : Arc de cercle var ex = canvas.getContext('2d'); var x = canvas.width / 2; var y = canvas.height / 2; var radius = 75; var startAngle = 1.1 * Math.PI; var endAngle = 1.9 * Math.PI; var counterClockwise = false; ex.beginPath(); ex.arc(x, y, radius, startAngle, endAngle, counterClockwise); ex.lineWidth = 15; ex.strokeStyle = 'black'; ex.stroke();
  • 18. Avec plusieurs objets... mode superposé ex.fillStyle="red"; ex.fillRect(20,20,75,50); ex.globalCompositeOperation="source-over"; ex.fillStyle="blue"; ex.fillRect(50,50,75,50); ex.fillStyle="red"; ex.fillRect(150,20,75,50); ex.globalCompositeOperation="destination-o ver"; ex.fillStyle="blue"; ex.fillRect(180,50,75,50); Résultat Element : globalCompositeOperation
  • 20. Explications with (graphics) { ratio = width / height; globalCompositeOperation = 'xor'; scale(width / 2 / ratio, height / 2); translate(ratio, 1); lineWidthFactor = 45 / height; Lignes mélangés mode additif For (position ligne par ligne) { Begin nouveau point For (point par point) { Calcul de forme par rapport à la sphere (x,y,z) Enlever le contour x,y,z Transition, superposition en x,y,z Affiche du point 2D en x,y Définit la couleur et luminosité des points: (r,g,b) (w,l) If (point en 1er plan) { If (point visible par rapport aux autre lignes) { Affiche le segment en x,y } } else { Cache le point } Position du point départ ligne x,y } } Calcul position par rapport au canvas
  • 21. Amélioré le résultat par les fonctions <audio src="zik.mp3" autoplay> Navigateur non compatible pour l'audio </audio> Musique ScrollText
  • 23.
  • 24. SVG ● Signifie Scalable Vector Graphics ● Gère les images au format léger ● Format vectoriel en XML ● Mémorise le 'graph' objet en mémoire dans le DOM ● Couplage à CSS
  • 25. Les bases du SVG <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <text x="5" y="190" transform="translate(40) rotate(-45 10 50)" >Very Important Party</text> </svg> Texte Habillage <rect x="40" y="5" height="110" width="110" style="stroke:#ff0000; fill: #CFCFCF;" transform="translate(30) rotate(28 50 35)"> </rect>
  • 26. Habiller le SVG <defs> <linearGradient id="effetgradient" x1="0%" y1="20%" x2="10%" y2="100%" spreadMethod="pad"> <stop offset="0%" stop-color="#FF44AA" stop-opacity="1"/> <stop offset="100%" stop-color="#000066" stop-opacity="1"/> </linearGradient> </defs> <rect x="10" y="10" width="75" height="100" rx="10" ry="10" style="fill:url(#effetgradient); stroke: #005000; stroke-width: 2;" />
  • 28. Le code de l'animation SVG <svg> <rect width="100" height="50"> <animate attributeName="width" attributeType="XML" fill="freeze" from="0" to="300" begin="0s" dur="3s"/> </rect> </svg>
  • 29. On bouge avec le SVG 51
  • 30.
  • 31. WebGL ● Balise canvas ● Couplage avec Blender ou logiciel modelage ● 3D ● Sharders ●
  • 32. WebGL façon simple <canvas id='balisewebgl'></canvas> <script> var balisewebgl = document.getElementById('balisewebgl'); var webGL = balisewebgl.getContext('experimental-webgl'); webGL.clearColor(0,1,0,1); webGL.clear(webGL.COLOR_BUFFER_BIT); </script>
  • 34. Explication exemple : The vertex shader (1/2) <script id="shader-vs" type="x-shader/x-vertex"> attribute vec3 aVertexPosition; attribute vec4 aVertexColor; attribute vec2 aTextureCoord; shader execution. uniform mat4 uMVMatrix; uniform mat4 uPMatrix; uniform float fTime; //interpolation varying vec4 vColor; // Coordonnées de la texture varying vec2 vTextureCoord; ● void main(void) { ● vec3 pos=aVertexPosition; ● // -- définir les coordonnées X et Y et Z ● pos.x += cos(fTime + (aVertexPosition.z/4.0)); ● pos.y += sin(fTime + (aVertexPosition.z/4.0)); ● // -- transforme the vertex ● gl_Position = uPMatrix * uMVMatrix * vec4(pos, 1.0); ● ● vColor = aVertexColor; ● // Simule l'illusion de mouvemnt ● vec2 texcoord=aTextureCoord; ● texcoord.y = texcoord.y + (fTime); ● ● // -- copier la texture ● vTextureCoord = texcoord; ● } ● </script>
  • 35. Explication exemple : Fragment shader (2/2) <script id="shader-fs" type="x-shader/x-fragment"> #ifdef GL_ES precision highp float; #endif uniform sampler2D uSampler; varying vec4 vColor; varying vec2 vTextureCoord; void main(void) { // -- récupère la valeur du pixel vec4 textureColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); // -- multiplie le pixel texture avec la couleur du vertex gl_FragColor = vColor * textureColor; } </script>
  • 37. Explication Cube Pas de commentaires
  • 38. Merci ● Code source inspiré du web Questions @hellosct1 @neuro_paris