Tile Shading System - Help please...
BlitzMax Forums/BlitzMax Programming/Tile Shading System - Help please...
| ||
![]() I have this system set up where each tile in my game has its own individual rgb value and that value allows me to apply shading on each of those tiles (and it effects any active object that might be overlapping that tile. The system works perfectly but now I want to apply larger images as background objects (these images are larger than the 16 x 16 tile image. Example: houses, trees, wagons, large statues, etc) and I'd like to apply this shading system to those objects. So I'm going to assume that in order to successfully do this I would have to take these larger images and somehow apply 16 x 16 sections and apply the shading system accordingly. I dont want to have to throw these larger images into the tile image (that would take up some much needed room). so is there a way I can do this actively without risking massive memory abuse? |
| ||
Going on this screen shot by Armitage 1982 for his MetaGolf game I would guess you could try the MOD2XBLEND mode:![]() Its pretty easy to add: In mod\brl.mod\max2d.mod\driver.bmx add this line under SHADEBLEND: Const MOD2XBLEND:Int=6 In mod\brl.mod\d3d7max2d.mod\d3d7max2d.bmx add this: Case MOD2XBLEND device.SetRenderState D3DRS_ALPHATESTENABLE,False device.SetRenderState D3DRS_ALPHABLENDENABLE,True device.SetRenderState D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR device.SetRenderState D3DRS_DESTBLEND,D3DBLEND_SRCCOLOR in the Select statement under the SetBlend Method. In mod\brl.mod\d3d9max2d.mod\d3d9max2d.bmx Case MOD2XBLEND _d3dDev.SetRenderState D3DRS_ALPHATESTENABLE,False _d3dDev.SetRenderState D3DRS_ALPHABLENDENABLE,True _d3dDev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR _d3dDev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_SRCCOLOR In mod\brl.mod\glmax2d.mod add: Case MOD2XBLEND glEnable GL_BLEND glBlendFunc GL_DST_COLOR,GL_SRC_COLOR glDisable GL_ALPHA_TEST Then Build Modules... In your own code, you can now call the blend by: SetBlend MOD2XBLEND Any colour which is less than 128,128,128 will go darker, any colour higher will go brighter and if the colour is 128,128,128 it will be transparent... |
| ||
that looks pretty cool actually. but it also looks like it would effect everything on the screen. I'd like to apply shading to the foreground objects and not have it effect the background parallax gfx. is there a way I can do that with this system? Last edited 2012 |
| ||
Hiya, I'd think the 'easiest' way would be to cut up the larger images into the smaller 16x16 sections. I'd also imagine there is a more complicated approach that would mean using a large 'light image' blended over the tiles. TBH I think this would be even more wasteful. As far as abusing memory goes, chopping up the larger images into smaller tiles probably won't waste much more than if you just use the larger image, I'd be more concerned with the cpu overhead ( speed, and memory usage if object oriented ), but I doubt that be noticeable unless its a real old system. |
| ||
I like your approach of having the tile as an RGB color instead of using a smooth light though :) |
| ||
@col thanks :) took me a while to even come up with that system. Actually I think it was suggested to me months ago when I had created a topic about tile shading. If I could recall the person who suggested it I would credit him for it ;) Anyway, I think I've got something figured out. for each new image (and by that I mean the large background image) I would have the program read the images width and height and then divide it into 16x16 segments. and for each 16x16 segment it would create a new special tile with the image frame set to match that location and all I'd have to do is set the rgb value of those special tiles. I think that'll be my system of choice :) but I'm willing to hear other ideas on shading if anybody wants to contribute to the topic. thanks! oh lawdy, I just realized how much more work I just gave myself xD |