Archived

This topic is now archived and is closed to further replies.

dr_slash_uh

Anti-aliasing

Recommended Posts

dr_slash_uh    122
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.

Share this post


Link to post
Share on other sites
Nik02    4348
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]

Share this post


Link to post
Share on other sites
dr_slash_uh    122
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.

Share this post


Link to post
Share on other sites
J_Vitel    126
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);

Share this post


Link to post
Share on other sites
Nik02    4348
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

Share this post


Link to post
Share on other sites
dr_slash_uh    122
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));

Share this post


Link to post
Share on other sites
constans    122
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]

Share this post


Link to post
Share on other sites
dr_slash_uh    122
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

Share this post


Link to post
Share on other sites
Nik02    4348
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

Share this post


Link to post
Share on other sites
Dave Hunt    4872
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.

Share this post


Link to post
Share on other sites