Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Shading PShape

$
0
0
To fix things for 2.0 follow these steps...

1. Change your vertex shader to this:
  1. uniform mat4 projmodelviewMatrix;
  2. attribute vec4 inVertex;
  3. varying vec2 surfacePos;

  4. void main() {
  5.   surfacePos = inVertex.xy;
  6.   gl_Position = projmodelviewMatrix * inVertex;
  7. }
2. Change your main sketch to this:
  1. // peasycam + 2.0 crashes my sketch so I had to remove it
  2. import toxi.geom.Vec3D;
  3.  
  4. PShader shader;
  5. PShape torus;
  6.  
  7. void setup() {
  8.   size(800, 600, P3D);
  9.   shader = loadShader("check.fs", "check.vs");
  10.   torus = createTorus( 40, 40, 40, 40, 40, 40);
  11. }
  12.  
  13. void draw() {
  14.   background(50);
  15.   translate(width/2, height/2);
  16.   rotateX(radians(90));
  17.   rotateZ(frameCount*0.01);
  18.   scale(2);
  19.   shader(shader);
  20.   shape(torus);
  21. }
3. In the Torus class uncomment:
  1. tor.noStroke();


Viewing all articles
Browse latest Browse all 1768

Trending Articles