• Advertisement

Archived

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

Lightning

This topic is 6000 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
umm i think ( and i do mean think )
your prob is the fact that your bliting to an off screen surface and not the back buffer
i am asuming your using OGL or DX,

hope that helps

-VBLimits
Sorry about the Spelling..

Share this post


Link to post
Share on other sites
Yes I know but I have to.. I use directdraw (no alpha blending).. And I know it is possible to do in software.. And I want to aim for low specs. Therefore no D3D or OGL (don''t know these apies yet either :-)

Share this post


Link to post
Share on other sites
You''re process seems to be doing vid-to-vid to fill the screen then vid-to-sys then lighting then sys to vid to display.
I believe twould actually be faster to do
sys-to-sys to get background then fill lighting then sys to vid. Sys to sys is almost as fast(sometimes equal) as vid to vid, but the vid to sys will slow you way down.
Should be realitively easy to implement and test speeds, too.
-m


mat williams
Lead Programmer, Designer
Zero Sum Software
www.zero-sum.com

Share this post


Link to post
Share on other sites
Thats right.. I tried sys to sys (with DDraw''s Blt function. The DXSDK 7 docs states that bltfast is not to be used with sys memory surfaces).. but got a huge drop in framerate.

Should I do my own blitter in software?.. use my own routines and then after everything is rendered copy my own buffer to the DDraw back buffer (by locking it and deploying my own copy routine?) and then do a DDraw flip?..

Is it possible to write a fast software blitter which operates in 640x480 16bit? one which could archieve 30 fps or more? in pure C/C++ (remember my game is tilebased.. many damned blits every frame).. Im not that good at assembler programming.

Share this post


Link to post
Share on other sites

  • Advertisement