Anti-aliasing

Started by
8 comments, last by dr_slash_uh 20 years, 3 months ago
The problem I am having eith my 2d sprite based games is that when I enable anti-aliaing my textures get messed up. I am using bitmaps for my textures. I think I read somewhere that if I use PNG files that, that would fix the problem. Is there a way to forece a program not to use anti-aliaing even if it is enabled in Windows display properties. I would really hate to convert all of my bmps to png.
Advertisement
That has nothing to do with the texture file formats.
D3D considers the textures exactly same after actually loading them.

Define "messed-up", a screenshot maybe?

-Nik

EDIT: As a side note, I recommend png files over bmp:s anyway, they have number of benefits - innate lossless compression and alpha channel support not being the smallest of them

[edited by - Nik02 on January 15, 2004 11:38:03 AM]

Niko Suni

I am not familiar with posting screen shots. What I mean by messud up is that there are lines in between each textured tile in the game where normally there isn''t any. It is like someone drew an antialised line around each of my textures.
What are you using to render your 2D Sprites? quads? or ID3DXSprite?, also, is your app runing on full screen or windowed.

sometimes you just have to do this in the right place:
// if We don´t want any antialias (Note: it only works if your // display is full screen or if you do not rezise your window )pDevice->SetTextureStageState(0,D3DTSS_MAGFILTER, D3DTEXF_POINT);pDevice->SetTextureStageState(0,D3DTSS_MINFILTER, D3DTEXF_POINT); 
My site Jvitel.com
Try to disable texture coordinate wrapping using pDev->SetSamplerState(0, D3DSAMP_ADDRESS*, D3DTADDRESS_CLAMP).
I used asterisk in place of U and V in the previous statement

See if that helps.

Other than that - if you can modify your sprite''s effective texture coords, try to move them about by amount of 0.5 in both u and v directions.

-Nik

Niko Suni

I am using
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,verts,sizeof(D3DTLVERTEX));

to display textures.

I tried your code and it still didn''t work. Here is my entire blit routine If you have any optimization tips, let me know:



lpDevice->SetTextureStageState(0,
D3DTSS_COLOROP, D3DTOP_SELECTARG1);
lpDevice->SetTextureStageState(0,
D3DTSS_COLORARG1, D3DTA_TEXTURE);
lpDevice->SetTextureStageState(0,
D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
lpDevice->SetTextureStageState(0,
D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
lpDevice->SetRenderState(D3DRS_SRCBLEND,
D3DBLEND_SRCALPHA);
lpDevice->SetRenderState(D3DRS_DESTBLEND,
D3DBLEND_INVSRCALPHA);
lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
lpDevice->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1);

verts[0]=D3DTLVERTEX(D3DXVECTOR3(x+0-0.5f, y+0-0.5f, z),rhw,col,0.0f,0.0f);
verts[1]=D3DTLVERTEX(D3DXVECTOR3(x+1024-0.5f, y+0-0.5f, z),rhw,col,1.0f,0.0f);
verts[2]=D3DTLVERTEX(D3DXVECTOR3(x+1024-0.5f, y+562-0.5f, z),rhw,col,1.0f,1.0f);
verts[3]=D3DTLVERTEX(D3DXVECTOR3(x+0-0.5f, y+562-0.5f, z),rhw,col,0.0f,1.0f);

lpDevice->SetTexture(0,lpSrc);
// configure shader for vertex type
lpDevice->SetVertexShader(D3DFVF_TLVERTEX);
// draw the rectangle
lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,verts,sizeof(D3DTLVERTEX));
quote:Is there a way to forece a program not to use anti-aliaing even if it is enabled in Windows display properties.
I think that you can solve that problem by filling out the D3DPRESENT_PARAMETERS properly.
D3DPRESENT_PARAMETERS d3dpp;d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;d3dpp.MultiSampleQuality = 0;  


[edited by - constans on January 15, 2004 12:34:34 PM]
what library file uses

MultiSampleQuality

I get an error stating:

Compiling...
main.cpp
E:\MarioDX\main.cpp(241) : error C2039: ''MultiSampleQuality'' : is not a member of ''_D3DPRESENT_PARAMETERS_''
e:\dtemp\dxf\dxsdk\include\d3d8types.h(1368) : see declaration of ''_D3DPRESENT_PARAMETERS_''
Error executing cl.exe.

mariodx.exe - 1 error(s), 0 warning(s)


I looked in the d3d8types.h file and couldn''t find it
Multisample quality is not explicitly available in D3D8. We were assuming DX9. However, multisample type "None" equals to quality 0 (no AA whatsoever) in DX8.

My example code works somewhat similarly in DX8 than in 9, just call pDev->SetTextureState instead of SetSamplerState, and use D3DTSS_ADDRESSU and D3DTSS_ADDRESSV as the state arguments.

-Nik

Niko Suni

What are you using to create your images? If your art program does anti-aliasing, then your images will do strange things like you described when you render them.

This topic is closed to new replies.

Advertisement