我想使用P3D渲染器渲染基本的3D形狀而沒有任何別名/平滑的PGraphics實例,但noSmooth()似乎不起作用。如何使用P3D渲染器實現noSmooth()?
在OF我記得在紋理上叫setTextureMinMagFilter(GL_NEAREST,GL_NEAREST);
。
什麼是處理等效?
我試圖用PGL:
PGL.TEXTURE_MIN_FILTER = PGL.NEAREST;
PGL.TEXTURE_MAG_FILTER = PGL.NEAREST;
但我得到一個黑色的圖像作爲結果。 如果我評論PGL.TEXTURE_MIN_FILTER = PGL.NEAREST;
我可以看到渲染,但是它是內插的,而不是尖銳的。
Here'a基本的測試草圖有幾件事我已經試過:
PGraphics buffer;
PGraphicsOpenGL pgl;
void setup() {
size(320, 240, P3D);
noSmooth();
//hint(DISABLE_TEXTURE_MIPMAPS);
//((PGraphicsOpenGL)g).textureSampling(0);
//PGL pgl = beginPGL();
//PGL.TEXTURE_MIN_FILTER = PGL.NEAREST;
//PGL.TEXTURE_MAG_FILTER = PGL.NEAREST;
//endPGL();
buffer=createGraphics(width/8, height/8, P3D);
buffer.noSmooth();
buffer.beginDraw();
//buffer.hint(DISABLE_TEXTURE_MIPMAPS);
//((PGraphicsOpenGL)buffer).textureSampling(0);
PGL bpgl = buffer.beginPGL();
//PGL.TEXTURE_MIN_FILTER = PGL.NEAREST;//commenting this back in results in a blank buffer
PGL.TEXTURE_MAG_FILTER = PGL.NEAREST;
buffer.endPGL();
buffer.background(0);
buffer.stroke(255);
buffer.line(0, 0, buffer.width, buffer.height);
buffer.endDraw();
}
void draw() {
image(buffer, 0, 0, width, height);
}
(我也posted on the Processing Forum,但至今沒有運氣)
如果我沒有記錯,然後'buffer.noSmooth()'不會如預期。但是調用'image()'完全忽略'noSmooth()'。 – Vallentin
@Vallentin感謝您的提示。我的直覺是我可能需要獲得對PGL紋理的引用,綁定它,然後調用像'''pgl.getTexParameteriv(PGL.TEXTURE_2D,PGL.TEXTURE_MIN_FILTER ...'''或者類似的東西? –