You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
4.1 KiB

2 years ago
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8" />
<base href="../../../../" />
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<p class="desc">Costruttore per il programma GLSL inviato agli shader vertex e fragment, comprese le uniformi e gli attributi.</p>
<h2>Uniformi e attributi incorporati</h2>
<h3>Vertex shader (incondizionato):</h3>
<div>
<code>
// = object.matrixWorld
uniform mat4 modelMatrix;
// = camera.matrixWorldInverse * object.matrixWorld
uniform mat4 modelViewMatrix;
// = camera.projectionMatrix
uniform mat4 projectionMatrix;
// = camera.matrixWorldInverse
uniform mat4 viewMatrix;
// = trasposizione inversa di modelViewMatrix
uniform mat3 normalMatrix;
// = posizione della telecamera nello spazio world
uniform vec3 cameraPosition;
</code>
<code>
// attributi di vertice predefiniti forniti da Geometry e BufferGeometry
attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;
</code>
<p>
Si noti che è possibile quindi calcolare la posizione di un vertice nel vertex shader con:
<code>
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
</code>
o in alternativa
<code>
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4( position, 1.0 );
</code>
</p>
</div>
<h3>Vertex shader (condizionale):</h3>
<div>
<code>
#if defined( USE_COLOR_ALPHA )
// attributo del colore del vertice con alfa
attribute vec4 color;
#elif defined( USE_COLOR )
// attributo del colore del vertice
attribute vec3 color;
#endif
</code>
<code>
#ifdef USE_MORPHTARGETS
attribute vec3 morphTarget0;
attribute vec3 morphTarget1;
attribute vec3 morphTarget2;
attribute vec3 morphTarget3;
#ifdef USE_MORPHNORMALS
attribute vec3 morphNormal0;
attribute vec3 morphNormal1;
attribute vec3 morphNormal2;
attribute vec3 morphNormal3;
#else
attribute vec3 morphTarget4;
attribute vec3 morphTarget5;
attribute vec3 morphTarget6;
attribute vec3 morphTarget7;
#endif
#endif
</code>
<code>
#ifdef USE_SKINNING
attribute vec4 skinIndex;
attribute vec4 skinWeight;
#endif
</code>
<code>
#ifdef USE_INSTANCING
// Si noti che modelViewMatrix non è impostato durante il rendering di un modello istanziato,
// ma può essere calcolato da viewMatrix * modelMatrix.
//
// Utilizzo di base:
// gl_Position = projectionMatrix * viewMatrix * modelMatrix * instanceMatrix * vec4(position, 1.0);
attribute mat4 instanceMatrix;
#endif
</code>
</div>
<h3>Fragment shader:</h3>
<div>
<code>
uniform mat4 viewMatrix;
uniform vec3 cameraPosition;
</code>
</div>
<h2>Costruttore</h2>
<h3>[name]( [param:WebGLRenderer renderer], [param:String cacheKey], [param:Object parameters] )</h3>
<p>Per i parametri vedere [page:WebGLRenderer WebGLRenderer].</p>
<h2>Proprietà</h2>
<h3>[property:String name]</h3>
<p>Il nome del rispettivo programma di shader.</p>
<h3>[property:String id]</h3>
<p>L'identificativo di questa istanza.</p>
<h3>[property:String cacheKey]</h3>
<p>Questa chiave consente la riutilizzabilità di un unico [name] per diversi materiali.</p>
<h3>[property:Integer usedTimes]</h3>
<p>Quante volte questa istanza viene utilizzata per il rendering di elementi di rendering.</p>
<h3>[property:Object program]</h3>
<p>L'attuale programma di shader.</p>
<h3>[property:WebGLShader vertexShader]</h3>
<p>Il vertex shader.</p>
<h3>[property:WebGLShader fragmentShader]</h3>
<p>Il fragment shader.</p>
<h2>Metodi</h2>
<h3>[method:Object getUniforms]()</h3>
<p>
Restituisce una mappa nome-valore di tutte le posizioni uniformi attive.
</p>
<h3>[method:Object getAttributes]()</h3>
<p>
Restituisce una mappa nome-valore di tutte le posizioni degli attributi dei vertici attivi.
</p>
<h3>[method:undefined destroy]()</h3>
<p>
Distrugge un'istanza di [name].
</p>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</p>
</body>
</html>