Texture filtering

Hi all,

I was wondering if it's possible to set the texture filtering of PGraphics anywhere, or if I'd have to use PGL instead? I searched around in the code and found some bits where it's being set up beforehand, but it'd be nice if I had control over this. https://github.com/processing/processing/blob/master/core/src/processing/opengl/Texture.java

Seems like it's set to NEAREST off the bat, but I'd like to change to LINEAR.

Thanks!

Answers

  • the usingMipmaps() method at line 518, is that useful?

    not sure how / when you'd call it though.

    (and i thought it was LINEAR by default - people have asked questions before asking how to set it to NEAREST for pixely art)

  • Hi Koogs, thanks for the suggestion, but I think that function just returns true or false, if the texture is using mipmaps or not.

  • no, that's the one above that takes no arguments. see line 518 not 513.

  • @koogs is right, LINEAR filtering is the default. See for yourself:

    PImage texture;
    float angle;
    
    void setup() {
        size(800, 800, P3D);
        texture = createImage(2, 2, ARGB);
        texture.loadPixels();
        texture.pixels[0] = 0xffff0000;
        texture.pixels[1] = 0xff00ff00;
        texture.pixels[2] = 0xff0000ff;
        texture.pixels[3] = 0xffffffff;
        texture.updatePixels();
        textureMode(NORMAL);
        noStroke();
    }
    
    void draw() {
        background(0);
        camera(sin(angle += 0.001) * 100, sin(angle) * 50, cos(angle) * 100, 0, 0, 0, 0, 1, 0);
        scale(20);
        texturedCube(texture);
    }
    
    void texturedCube(PImage texture) {
        beginShape(QUADS);
        texture(texture);
        vertex(-1, -1, 1, 0, 0);
        vertex( 1, -1, 1, 1, 0);
        vertex( 1, 1, 1, 1, 1);
        vertex(-1, 1, 1, 0, 1);
        vertex( 1, -1, -1, 0, 0);
        vertex(-1, -1, -1, 1, 0);
        vertex(-1, 1, -1, 1, 1);
        vertex( 1, 1, -1, 0, 1);
        vertex(-1, 1, 1, 0, 0);
        vertex( 1, 1, 1, 1, 0);
        vertex( 1, 1, -1, 1, 1);
        vertex(-1, 1, -1, 0, 1);
        vertex(-1, -1, -1, 0, 0);
        vertex( 1, -1, -1, 1, 0);
        vertex( 1, -1, 1, 1, 1);
        vertex(-1, -1, 1, 0, 1);
        vertex( 1, -1, 1, 0, 0);
        vertex( 1, -1, -1, 1, 0);
        vertex( 1, 1, -1, 1, 1);
        vertex( 1, 1, 1, 0, 1);
        vertex(-1, -1, -1, 0, 0);
        vertex(-1, -1, 1, 1, 0);
        vertex(-1, 1, 1, 1, 1);
        vertex(-1, 1, -1, 0, 1);
        endShape();
    }
    
Sign In or Register to comment.