   Direct3D Texture Rendering
  I'm making a 2D engine tile based game using DirectX 9 in VB.net. I'm using a texture (loaded bmp) to simulate light when blended with the game sprites. The problem is that I only want the tiles to blend with the lightmap texture, but the tiles blend with the lightmap texture and ALSO blend with every other sprite (some tiles are overlapped). I tried using lighting with Direct3D but I couldn't get it working right. I'm using Direct3D.Sprite.Draw to render each texture.How would I get lighting effect working correctly? What if I were to somehow 'combine' all the tile textures into 1 texture and then apply the blending effects?Thanks alot.[Edited by - ADM on December 10, 2005 7:45:09 AM]
  It sounds like you aren't changing render states to a non-blending operation when you go to render the sprites. Is that right?   ;  I need them to blend otherwise the tiles don't have the light effected added to them. I just don't want them to blend with other tiles. :P   ;  I really am not getting the gist of what you are trying to do.Quote:I'm using a texture (loaded bmp) to simulate light when blended with the game spritesHow exactly are the sprites and the lightmap interrelated here? From this I almost get the impression of some kind of dynamically created lightmap. Is that right? I don't really understand the effect you are trying to obtain just from this sentence. Be a little more descriptive of the process and the output you want. If you are simply trying to render a tile-map, some sprites and a lightmap ontop of all of that, just say so. Otherwise, give a little more detail.Sorry I'm not getting this [grin]   ;  Here is a picture to show you my problem. The grayscale image I use makes it look like my player is using a lantern light. The only problem is that using this effect makes tiles blend with one another.http://www.project52.net/mir/example4.JPG   ;  Is there a way I could draw about 400 textures to one big (screen size) texture instead of rendering directly to a sprite?   ;  How are you currently blending the lightmap with the tiles? Are you using Alpha-Blending or using Texture Stage States. You want be using the latter, and if you are, could you post that peice of code for it? If you're using Alpha-Blending, look into Texture Stage States :).Hope this helps.   ;  I first draw the lightmap texture wit these properties:   D3D.RenderState.SourceBlend = Blend.One   D3D.RenderState.DestinationBlend = Blend.OneThen I draw the tiles, players, buildings ontop of one another using:   D3D.RenderState.SourceBlend = Blend.Zero   D3D.RenderState.DestinationBlend = Blend.SourceColorHere is my lightmap texture:http://www.project52.net/mir/0.JPG   ;  Right, so you are currently drawing in 2 passes. One for the lightmap, and then another for the tiles.What happens is that alphablending blends with what's in the backbuffer when you draw, so you can't modulate with only the lightmap where the tiles overlap.What I'd recommend is using Texture Stage States to perform the operation in one pass, instead of two. Using TSS allows you to select how each pixel is textured, when it is drawn. What you need to be looking into is how to modulate your texture with the lightmap in one pass.Hope this helps.   ;  How would I use texture stages with Direct3D.Sprite?   