vertex shading in PShape
in
Programming Questions
•
9 months ago
Hi, I'm potting map defined by values on 2D rectangular grid (in vertexes of the grid), for each rectangular tile (Quad) it should be linearly interpolated from the neighboring vertex values. If I do it by direct (immediate) method it works fine. However, if I try to use PShape (Retained rendering) to improve performance* it does not work. It seems that fill() command change color of the whole shape, instead of just one vertex.
Questins:
- Is there any way how to do vertex shading** in PShape ?????
- Is in Processing 2.0 still possible use Opengl RenderList ? How? Would it provide linearly interpolated vertex shading?
- Or VertexBuffer ?
- side question - even with vertex shading of quads, each quad is splitted to 2 triangles, so it is not interpolated correctly. I mean each triangle is interpolated independently, so there is a sharp diagonal seam in between. Is there any fast (GPU based) way how to render really bilinear interpolation between the 4 vertexes of the quad? I was thinking, maybe I can write some GLSL shader to do that?
* - I guess PShape works is something like OpenGL render list or VertexBuffer. I was insporated by examples in Demos>Performance>CubicGridRetained vs. CubicGridImmediate.
** - by vertex shading I mean something like in example Topics>Geometry>RGBcube
Simple example for just one quad:
- void setup(){
- size(800, 800, P3D);
- noStroke();
- colorMode(RGB, 1);
- translate(400,400);
- scale(50);
- // using direct( Immediate rendering) - Correct linear interpolation :))
- beginShape();
- fill( 0x80000000 ); vertex( -1 , -1 );
- fill( 0x8000FF00 ); vertex( -1 , +1 );
- fill( 0x80FFFF00 ); vertex( +1 , +1 );
- fill( 0x80FF0000 ); vertex( +1 , -1 );
- endShape(CLOSE);
- // using PShape (Retained rendering) - just fill it :((
- translate(2.0,0);
- PShape s = createShape();
- s.fill( 0x80000000 ); s.vertex( -1 , -1 );
- s.fill( 0x8000FF00 ); s.vertex( +1 , -1 );
- s.fill( 0x80FFFF00 ); s.vertex( +1 , +1 );
- s.fill( 0x80FF0000 ); s.vertex( -1 , +1 );
- s.end(CLOSE);
- shape(s);
- }
- void draw(){ noLoop(); }
1