且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用P3D渲染器实现noSmooth()?

更新时间:2023-12-04 12:30:58

您实际上是在正确的轨道上.您只是将错误的值传递给textureSampling().

You were actually on the right track. You were just passing the wrong value to textureSampling().

至少可以说有点稀缺. 我决定使用反编译器来深入研究它,这导致我 Texture::usingMipmaps() . 在那里,我能够看到这些值及其反映的内容(在反编译的代码中).

Since the documentation on PGraphicsOpenGL::textureSampling() is a bit scarce to say the least. I decided to peak into it using a decompiler, which lead me to Texture::usingMipmaps(). There I was able to see the values and what they reflected (in the decompiled code).

2 = POINT
3 = LINEAR
4 = BILINEAR
5 = TRILINEAR

PGraphicsOpenGL的默认textureSampling5(TRILINEAR).

Where PGraphicsOpenGL's default textureSampling is 5 (TRILINEAR).

我后来也发现了关于问题的旧评论同样确认.

I also later found this old comment on an issue equally confirming it.

因此,要获取点/最近过滤,只需要在应用程序本身上调用noSmooth(),然后在PGraphics上调用textureSampling().

So to get point/nearest filtering you only need to call noSmooth() on the application itself, and call textureSampling() on your PGraphics.

size(320, 240, P3D);
noSmooth();

buffer = createGraphics(width/8, height/8, P3D);
((PGraphicsOpenGL) buffer).textureSampling(2);

因此,请考虑以上内容,并且仅包括用于绘制线条和为应用程序绘制buffer的代码.然后,得出以下预期结果.

So considering the above, and only including the code you used to draw the line and drawing buffer to the application. Then that gives the following desired result.