Skip to content

Instantly share code, notes, and snippets.

@cjcliffe
Created September 23, 2011 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjcliffe/1238401 to your computer and use it in GitHub Desktop.
Save cjcliffe/1238401 to your computer and use it in GitHub Desktop.
Minimal Custom Shader with full pipeline rendering for CubicVR.js
<script id="vs" type="x-shader/x-vertex">
void main(void)
{
vertexTexCoordOut = cubicvr_texCoord();
gl_Position = matrixProjection * matrixModelView * cubicvr_transform();
vertexNormalOut = matrixNormal * cubicvr_normal();
cubicvr_lighting();
}
</script>
<script id="fs" type="x-shader/x-fragment">
void main(void)
{
vec2 texCoord = cubicvr_texCoord();
vec4 color = cubicvr_color(texCoord);
vec3 normal = cubicvr_normal(texCoord);
color = cubicvr_environment(color,normal,texCoord);
color = cubicvr_lighting(color,normal,texCoord);
gl_FragColor = clamp(color,0.0,1.0);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment