I need sdl_rendergeometry to not interpolate colors in textures, I see on the edges of a texture clipping some pixels with the wrong color because of the adjacent pixels and I think this is the reason.
Is there any way to disable this color smoothing in sdl_rendergeometry?
You can change the scale mode of the texture to “nearest”.
SDL2
SDL_SetTextureScaleMode(texture, SDL_ScaleModeNearest);
SDL3
SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST);
thank you for the reference but not luck. more context:
I try to implement sprite stacking in my lang (forth related), when the camera is near the floor, the layers are almost flat, then the borders of texure are not correct, is like the borders not give the correct pixel color
when the camera in high, the image more big and work correct.
You can see the problems in the image:
Are you sure the “sprites” have the right width or that some aren’t missing?
When looking at the roof in the first image it looks like what’s on the side of the white rectangles is the background.
I guess the size is correct. I made a test drawing only one layer and see the incorrect color in the border, the sprite of right is a layer of house
is like i need no smooth the color of the texture, I test SDL_SetTextureScaleMode but only happen when set to 2 smooth this colors more…the default is 0 ( NONE) and not need set when load the texture.
Is like I need a low resolution rasterizer without smooth pixels
I’m not sure I understand. Using “nearest” scale mode should not result in any “smoothing”/color interpolation. Only “linear” or “best” should do that.
To prevent the edge colours of nearby sprites from “bleeding” into the sprite you might want to surround your sprites with at least one pixel row of transparency. I’m not sure if this is necessary when using “nearest” scale mode but I wouldn’t rule it out due to rounding errors. When using “linear” and “best” the colour of transparent pixels can also affect nearby pixels.
this is when activate linear interpolator, see the smooth transition in the house:
When put in nearest, the smooth transition disapear but take the not good pixel:
but the edge is antialias…i guess i need alias
this is the texture…have full transparent in the borders, is a cut… the upper and lower part are other parts
OK, now I understand better. I agree that you probably don’t want to use linear interpolation for this.
By “not good pixel” you mean that the brown pixels are only shown in some spots? You want them to be visible along the whole side, like in the “texture”?
I think this is because you’re trying to draw the sprite using fewer pixels than is in the texture. The height of the sprite in the texture is 61 but after drawing it’s only about 48. That means some pixels has to be missing.
you are correct.
I’m going to try to find solutions to that thinking alternatives, maybe reimplement in opengl.
the source of this is in r3/r3/dev/spritestackesc.r3 at main · phreda4/r3 · GitHub
if you have windows you can view in action.