mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 23:44:56 +01:00
147 lines
3.1 KiB
HTML
147 lines
3.1 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="utf-8" />
|
||
|
<script src="../../../list.js"></script>
|
||
|
<script src="../../../page.js"></script>
|
||
|
<link type="text/css" rel="stylesheet" href="../../../page.css" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>[name]</h1>
|
||
|
|
||
|
<div class="desc">Constructor for the GLSL program sent to vertex and fragment shaders, including default uniforms and attributes.</div>
|
||
|
|
||
|
<h2>Built-in uniforms and attributes</h2>
|
||
|
|
||
|
<h3>Vertex shader (unconditional):</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;
|
||
|
|
||
|
// = inverse transpose of modelViewMatrix
|
||
|
uniform mat3 normalMatrix;
|
||
|
|
||
|
// = camera position in world space
|
||
|
uniform vec3 cameraPosition;
|
||
|
</code>
|
||
|
<code>
|
||
|
// default vertex attributes provided by Geometry and BufferGeometry
|
||
|
attribute vec3 position;
|
||
|
attribute vec3 normal;
|
||
|
attribute vec2 uv;
|
||
|
attribute vec2 uv2;
|
||
|
</code>
|
||
|
<p>
|
||
|
Note that you can therefore calculate the position of a vertex in the vertex shader by:
|
||
|
<code>
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
</code>
|
||
|
or alternatively
|
||
|
<code>
|
||
|
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4( position, 1.0 );
|
||
|
</code>
|
||
|
</p>
|
||
|
</div>
|
||
|
|
||
|
<h3>Vertex shader (conditional):</h3>
|
||
|
<code>
|
||
|
#ifdef USE_COLOR
|
||
|
// vertex color attribute
|
||
|
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>
|
||
|
</div>
|
||
|
|
||
|
<h3>Fragment shader:</h3>
|
||
|
<div>
|
||
|
<code>
|
||
|
uniform mat4 viewMatrix;
|
||
|
uniform vec3 cameraPosition;
|
||
|
</code>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<h2>Constructor</h2>
|
||
|
|
||
|
<h3>[name]( [page:WebGLRenderer renderer], [page:Object code], [page:Material material], [page:Object parameters] )</h3>
|
||
|
<div>For parameters see [page:WebGLRenderer WebGLRenderer]</div>
|
||
|
|
||
|
<h2>Properties</h2>
|
||
|
|
||
|
<h3>[property:Object uniforms]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h3>[property:Object attributes]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h3>[property:String id]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h3>[property:String code]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h3>[property:Integer usedTimes]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h3>[property:Object program]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h3>[property:WebGLShader vertexShader]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h3>[property:WebGLShader fragmentShader]</h3>
|
||
|
<div></div>
|
||
|
|
||
|
|
||
|
<h2>Methods</h2>
|
||
|
|
||
|
<h3>none</h3>
|
||
|
<div></div>
|
||
|
|
||
|
<h2>Source</h2>
|
||
|
|
||
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
||
|
</body>
|
||
|
</html>
|