Skip to content

Instantly share code, notes, and snippets.

Created April 14, 2014 03:57
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 anonymous/10614782 to your computer and use it in GitHub Desktop.
Save anonymous/10614782 to your computer and use it in GitHub Desktop.
// fragment shader
precision lowp float;
//varying vec4 outputColor;
varying vec3 cnormal;
void main()
{
vec3 col = cnormal.xyz;//vec3(1,1,1) * dot(cnormal, vec3(0,1,0));
gl_FragColor = vec4(col.x, col.y, col.z, 1);
}
// vertex shader
precision lowp float;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 normalMatrix;
attribute vec4 position;
attribute vec4 normal;
varying vec3 cnormal;
void main(){
gl_Position = modelViewProjectionMatrix * position;
cnormal = normal.xyz;//normalize( normalMatrix * normal ).xyz;
}
ofSpherePrimitive cp;
ofShader shader;
//--------------------------------------------------------------
void ofApp::setup(){
cp.enableNormals();
cp.enableColors();
cp.set(10, 20);
cp.setScale(10);
cp.setPosition(0,0,-500);
if(!shader.load("lambert"))
return;
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
static float rot = 0.0f;
ofSetColor(255);
cp.setOrientation(ofVec3f(0,rot,rot));
shader.begin();
cp.draw();
shader.end();
rot += 1.0f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment