Antialiasing(?) problem

Previous topic - Next topic

FutureCow

I have a 32x32 texture (right hand side of the image - resized to make it easily visible). It's saved as a 24bit png, but there's no alpha data, it's just a plain 3 colours.

I've created a 3D object (just a quad) as follows
Code (glbasic) Select
O_GridHitMiss=GENX_OBJ()
X_OBJSTART O_GridHitMiss
X_OBJADDVERTEX   0, 0, 1, 1, 0, RGB(255,255,255) // Create quad
X_OBJADDVERTEX   0, 0, 0, 1, 1, RGB(255,255,255)
X_OBJADDVERTEX   1, 0, 1, 0, 0, RGB(255,255,255)
X_OBJADDVERTEX   1, 0, 0, 0, 1, RGB(255,255,255)
X_OBJEND


When I texture it with the image, and display it on screen
Code (glbasic) Select
X_SETTEXTURE T_GridHit2, -1
X_MOVEMENT XLoop, 0, YLoop
X_DRAWOBJ O_GridHitMiss,0


I get the awful greeny colour around the edges of the "2". Anyone have any ideas how I stop that happening?

[attachment deleted by admin]

Schranz0r

SMOOTHSHADING FALSE  :blink:

:D
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

FutureCow

I just tried it before the X_SETTEXTURE, then before the X_DRAWOBJ, and then before both of the commands just in case. Nothing fixed it.

Any other ideas?
Changing the Multisampling setting for the project didn't fix it (that was all I could think of)

Hatonastick

This is a real long-shot here, but have you tried it on another computer with a different graphics card?  Just to eliminate that possibility.  It's probably in reality a setting or command -- in which case I can't really help due to practically zero 3D experience.  Just think you should double check it's not drivers or the card to be safe while waiting for someone with more knowledge to give an answer.

FutureCow

I'll be trying it on the work PC tomorrow to see what it does.

Schranz0r

Set SMOOTHSHADING FALSE befor you load your sprites!
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

matchy

Not a solution, but try higher resolution maps and set the ALPHAMODE to something like to 0.99 or -0.99.

MikeHart

After every SHOWSCREEN, ALPHAMODE and SMOOTHSHADING are setback to the default values. So make sure that you set them every frame after a SHOWSCREEN.

MrTAToad

Could also try enabling mipmapping before you load your sprites.

FutureCow

Quote from: Schranz0r on 2010-Jan-10
Set SMOOTHSHADING FALSE befor you load your sprites!

I'll try it, but that's different to what the manual says is needed : as MikeHart pointed out -

Quote from: MikeHart on 2010-Jan-10
After every SHOWSCREEN, ALPHAMODE and SMOOTHSHADING are setback to the default values. So make sure that you set them every frame after a SHOWSCREEN.

MikeHart - that's why I put them right before the drawing command that's causing me issues - they'll be set for the next SHOWSCREEN.

Quote from: matchy on 2010-Jan-10
Not a solution, but try higher resolution maps and set the ALPHAMODE to something like to 0.99 or -0.99.

Thanks matchy - not quite sure what the slight change in ALPHAMODE will achieve, but I'll give it a shot anyway!  ;)
I'll try the higher resolution maps if I can't get anything else to work (I don't like chewing up extra memory unnecessarily if I can help it!)

Quote from: MrTAToad on 2010-Jan-10
Could also try enabling mipmapping before you load your sprites.

Enabling mipmapping? I would've thought disabling it would've been more beneficial as it's a small sprite. I'll try it though.

Thanks!

FutureCow

I've tried all the suggestions
SMOOTHSHADING FALSE before loadsprite, applying texture to the object or drawing the object : Nothing
ALPHAMODE = 0.01, -0.01, 0.99, -0.99 : Nothing
X_MIPMAPPING 1 (or X_MIPMAPPING 0) before loadsprite : Nothing

So nothing has made a difference. Any more ideas?

Moru

Change the color of the transparent color to black or near black?

matchy

Code (glbasic) Select

// --------------------------------- //
// Project: maptest
// Start: Monday, January 11, 2010
// IDE Version: 7.230

GLOBAL MAP_WATER=0
GLOBAL MAP_NUMBER=1
GLOBAL OBJ_WATER=0
GLOBAL OBJ_NUMBER=1

funMapTest()

FUNCTION funMapTest:
SETCURRENTDIR("Media")
SETSCREEN 640,480,0
funCreateObjects()
funAnimate()
ENDFUNCTION

FUNCTION funCreateObjects:
LOADSPRITE "map1.png",MAP_NUMBER
LOADSPRITE "map2.png",MAP_WATER
X_OBJSTART OBJ_WATER
  X_OBJADDVERTEX   0, 0, 1, 1, 0, RGB(255,255,255)
  X_OBJADDVERTEX   0, 0, 0, 1, 1, RGB(255,255,255)
  X_OBJADDVERTEX   1, 0, 1, 0, 0, RGB(255,255,255)
  X_OBJADDVERTEX   1, 0, 0, 0, 1, RGB(255,255,255)
X_OBJEND
X_OBJSTART OBJ_NUMBER
  X_OBJADDVERTEX   0, 0, 1, 1, 0, RGB(255,255,255)
  X_OBJADDVERTEX   0, 0, 0, 1, 1, RGB(255,255,255)
  X_OBJADDVERTEX   1, 0, 1, 0, 0, RGB(255,255,255)
  X_OBJADDVERTEX   1, 0, 0, 0, 1, RGB(255,255,255)
X_OBJEND
ENDFUNCTION

FUNCTION funAnimate:
WHILE TRUE
X_MAKE3D 1,10,45
X_CAMERA 0,2,-1, 0,0,0.5
funDrawObj(OBJ_WATER ,  0, -0.1 , 0,     0)
funDrawObj(OBJ_NUMBER,  0,     0, 0,     0)
funDrawObj(OBJ_WATER , -1, -0.1 , 0,     0)
funDrawObj(OBJ_NUMBER, -1,     0, 0, -0.99)
SHOWSCREEN
WEND
ENDFUNCTION

FUNCTION funDrawObj: obj, x,y,z, alpha
X_SETTEXTURE obj, -1
X_MOVEMENT x,y,z
ALPHAMODE alpha
X_DRAWOBJ obj,0
ENDFUNCTION


[attachment deleted by admin]

FutureCow

Transparency set to RGB(0,0,0) for that one sprite didn't do anything either. This is really frustrating me!

I'll try Matchy's code with my sprites and see what I get.

FutureCow

Awesome work Matchy! Your suggestions (resize and alpha setting) fix - (or at least hide  :P ) - the problem. Not exactly sure what was causing it, or why my number "2" has problems yet my image texture for 3,4 and 5 dont. They're different colours so I'm wondering what about the pink colour in particular is conflicting. I'm assuming it's the (white) colour of the object verticies interfering with it somehow, but who knows. At least your solution stops it showing up. Many thanks to everyone!!!

I realised why I wasn't having any luck with ALPHAMODE either - stupid me was doing
Code (glbasic) Select

ALPHAMODE -0.99
X_SETTEXTURE T_GridHit1, -1
ALPHAMODE 0

[...]

X_DRAWOBJ O_GridHitMiss,0


rather than
Code (glbasic) Select

ALPHAMODE -0.99
X_DRAWOBJ O_GridHitMiss,0
ALPHAMODE 0