Advertisement

04.10.2008 at 07:02AM PDT, ID: 23311729
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

How to remove antialiasing for sprites?

Tags: DirectX C++
My sprites are being drawing antialiased. I don't what this, I what the sprite to be a pixel for pixel match of the texture. What do I need to do?

Thanks,
Matthew
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: mattososky
Solution Provided By: JoseParrot
Participating Experts: 1
Solution Grade: B
Views: 72
Translate:
Loading Advertisement...
04.12.2008 at 10:22AM PDT, ID: 21341843

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.12.2008 at 11:13AM PDT, ID: 21341989

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.13.2008 at 11:57AM PDT, ID: 21345778

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.13.2008 at 04:46PM PDT, ID: 21346737

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.14.2008 at 06:49AM PDT, ID: 21349949

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
04.12.2008 at 10:22AM PDT, ID: 21341843

Rank: Master

When we create an antialized sprite, we actually mix the sprite color with the background color at sprite boundaries. Say, if the sprite is red and background is white, there are some pixels with colors between red and white in the sprite boundaries.

If we apply another backgrond color, say, by painting it blue, the painting process stops at non-white pixels, thus resulting in bad contour and bad integration of the sprite to the background, and pre-antialized pixels works inverse...

The better solution is to create the sprites with transparent background so that you program knows how to treat transparency values (alpha channel).

If it is not possible, then make your sprites not anti-alized, only with horizontal, verrtical and 45 degrees inclined lines, to minimize the non-antialized sprite.

As an option, if anti-aliazing is mandatory, repeat your original sprites and create a number of different versions of it, each one with a different background color, such that you chose, at a given situation, the most appropriate version. Say, for a almost green scenario you use the sprite that was mixed with a green background, and so on.

This trick is easy to implement and as sprites are typicaly small, there is no problem if your program spend a liitle bit more memory.

Jose
 
04.12.2008 at 11:13AM PDT, ID: 21341989
It's not just that the sprite is being antialiases, against the backgroud, it's perforing some kinda of smoothing or blending itself when it is drawn. I created a texture with some pretty high contrast textels next to eachother, and it's the like entire sprite is antialiasing all textels/pixels.

I was getting very frustrated with this, not so much as it was a roadblock, but on pricipal. I should be able to use directx to transfer a bitmap file onto the screen as it is, not being antialiased.

Currently I am trying textured quads. I actually got an interesting result. I notice that the texture was still being antialiases on the quad, but then I went full screen instead of windowed mode. The texture appeared seemingly corrent with no antialias!

Any comment on that? why should windowed / fullscreen mode effect texture antialiasing? One of my thoughts was that even though i specified a device of 800/600, and put it on a window of same size, the actual rendering size was smaller giving the windows border in windowed mode. I ran into that phenonmenon in C# alot. I'm thinking thing images are being rasterize, not antialiased, into a screen dimension that is perhaps a few pixels short of the 800x600, because of the windows border. That's just a guess cause I still need to check.
 
04.13.2008 at 11:57AM PDT, ID: 21345778

Rank: Master

If you want transfer bitmaps and sprites in their exact resolution to the screen, such that each individual pixel in the bitmap is projected in individual elements in the display, then DirectX isn't the right development SDK. You should use GDI or GDI+.

If yours is a 2D game, you can use DirectX, for example, making Z=0 for everything. But the environment is still a 3D world.

If yours is a 3D game, then DirectX is OK.
In this case, sprite isn't adequated to a 3D environment.
By conception, sprite is a small bitmap for fast local animation. It was widely used in the DOS era, when graphic capabilities were strongly limited. Instead of refreshing the entire screen, on could refresh just the sprite.
Sprite is a 2D entity.

When using DirectX, the program has a 3D space where a 2D entity is actually a 3D entity reduced to a simple surface. Assuming the projection plane as the screen, if a 2D entity is projected in the screen, then a pixel of a bitmap to appear as an exact pixel in the screen is matter of pure coincidence.

To guarantee what you are looking for, the only way is:
1) The game is 2D (or at most, 2.5D)
2) Z=constant for everything (can be any value)
3) Your space is absolutely equal to the window (or full screen)
    Please note: You cannot change neither screen size nor make it full screen.
    Ex.: Your game 2D space is 320x200, then the window is 320x200 or
    your space is 800x600 then Windows resolution is 800x600 full screen
    You can chose window or full screen, but not allowed to modify it.
4) Projection mode must be orthogonal: no perspective
5) The camera (or observer) is in the Z axis

If the bitmap is viewed in perspective, which modifies the projection depending on angles and distances, then DirectX will render such bitmap, causing the effects you want avoid to.

Conclusion: To achieve what you want with DirectX, your program should comply to the 5 conditions above. Anyway, it will be a 2D game.

Jose
Assisted Solution
 
04.13.2008 at 04:46PM PDT, ID: 21346737

Rank: Master

In reviewing my comment, I found two more things to add.

First, we was reffering to DirectX, but it would better to say Direct3D, which is part of DirectX. To complement the subject, it would be useful a look at a tutorial on textures applied to quads at
http://www.gamedev.net/reference/articles/article1972.asp, although your question is target to the rendering effects.
Also a visit to http://www.gamasutra.com/features/20010629/geczy_01.htm would be good for understanding of 2D programming in 3D worlds and hints on the ID3DXSprite class.

Second, may be confuse my explanation on perspective and orthogonal projection.

PERSPECTIVE
Also known as conic projection or conic perspective.
Let's square S located in the XY plane (thus z=0), with 1.0 side, with its center in the orign.; and the camera at Z axis, at Z=-10.0. This square is faced to the camera and will appear as a square in the projection plane (and in the screen). If the same square moves to z=10, it will appear as a smaller square. Then texture rendering will be also smaller, because the object is farther. Now, if the square rotates 90 degrees on X axis, it will be in the XZ plane and appears as a trapeze. DirectX will apply correspondent "distortion" to the texture as well. What DX is actually doing in theses cases isn't exactly antialiazing, it is rendering.

ORTHOGONAL
Also known as parallel projection or parallel perspective.
Let the same components: the square at XY plane, etc.
Your program should call D3DXMatrixPerspectiveOffCenterRH or D3DXMatrixPerspectiveOffCenterLH as per your choice for right or left hand model. D3DXMatrixOrthoRH or D3DXMatrixOrthoLH to build an ortho projection matrix. Declare width and height values equal to window size (or full screen resoltion).

Jose
Accepted Solution
 
04.14.2008 at 06:49AM PDT, ID: 21349949
I don't agree with your comments concerning using GDI. I've been using GDI for some years and it is not an acceptable replacement for what directX is providing. First oft, utilizing directX gives you direct access to hardward, allowing hardward accellerated functions. Have you every tried to alphablend, or rapidly switch between big images (any over 640x480) using GDI? I have also come accross bugs in the GDI API, when pushing things to extreams. (Try scaling an image, a small one, 6-5 times). DirectX is a totally appropriate API for developing 2D applications. Yes, even Direct3D.

Now, back to the question at hand, I have implemented the textured quads and gotten excellent results. The bitmaps are coming through 100% accurate. I'm not sure what the deal is with sprites, I saw one post which seemingly had the same problem, but their solution was not working for me.

Anyway, appriciate the input.
Thanks,
Matt
 
 
04.14.2008 at 12:04PM PDT, ID: 21352767
I agree entirely with your points about GDI. DX is by far superior to that API, merely an API to the graphics windows interface, in contrast to rich DX, a true graphics engine.
But making pixel by pixel translation from a bitmap to the screen is very easy with GDI and constrained in DX, forcing the programmer to limit DX richness.
I hope the comments were useful anyway.
Regards,
Jose
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628