Jump to content
  • Advertisement


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


lightning speed problems!

This topic is 6207 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have made this 2d square tile engine, really simply. Okay.. I wanted to add lightning based on lightmaps. It is really simply, my light maps are byte maps like this BYTE *LightMapForTreeObject = (BYTE *) malloc(80*80) I have of course implemented it diffent to support multiple lightmaps etc.. Okay.. in my engine I declare this one big lightmap for the engine, the same size of the screen but in bytes. This is how it works.. first I hardware blit all the tiles to one big surface same size as the screen (both the tile surface and the screen surface is in vidmem). I do this to make use of the hardware blitting for the regular tileblitting. Doing all this in sysmem would be way too slow. Okay, i then transfer this screenbuffer to a surface of the same size in sysmem (because noone in their right mind would read from vidmem).. I just directdraws Blt function for this (Bltfast doesn''t work well with sysmem).. Okay I initialize my big lightmap (the one which covers the whole screen), with an ambient light values.. then i copy the smaller lightmaps (for the objects and stuff) to the big lightmap at the correct positions.. using homemade blit functions. (all the lightmaps are byte maps). then finally i take my system memory surface containing the whole screen and apply the big lightmap to it by looping trough all the pixels in the surface, using them as an index into a giant lookup table: WORD CLUT[65535][15] // 16 precalculated lightlevels like this Dest_Pixel = CLUT[Dest_Pixel][Lightmap_Pixel] The bytes in the lightmap are used to define the shade of the pixel in the surface.. all this works well.. my problem is that is it too slow.. even with no lightmaps on the screen (just clearing the screen lightmap to the ambientlight level, say eg 7 for half intensity) I get 20 fps. and with 10 or more lightmaps of 192x192 size i get only 12 fps.. sometimes as low as 9,, this sucks!.. I test this on a 300mhz AMD K6-2, with 64 megs of ram and a Geforce MX 2 32mb videocard... any suggestions to how I could optimize this? I know others have implemented a system much like which ran fluid on a 120 Pentium with a 2 meg vidcard.. please excuse my bad english, this was written in a hurry and english isn''t my native language.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!