🔒 Locked
Direct3D Texture Rendering
Advertisement
Original Post
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 really am not getting the gist of what you are trying to do.
How 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]
Quote:
I'm using a texture (loaded bmp) to simulate light when blended with the game sprites
How 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]
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.
Hope this helps.
I first draw the lightmap texture wit these properties:
D3D.RenderState.SourceBlend = Blend.One
D3D.RenderState.DestinationBlend = Blend.One
Then I draw the tiles, players, buildings ontop of one another using:
D3D.RenderState.SourceBlend = Blend.Zero
D3D.RenderState.DestinationBlend = Blend.SourceColor
Here is my lightmap texture:
http://www.project52.net/mir/0.JPG
D3D.RenderState.SourceBlend = Blend.One
D3D.RenderState.DestinationBlend = Blend.One
Then I draw the tiles, players, buildings ontop of one another using:
D3D.RenderState.SourceBlend = Blend.Zero
D3D.RenderState.DestinationBlend = Blend.SourceColor
Here 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.
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.
hrm, you actually can't use TSS with Sprites, sorry, I didn't notice you were using them. :(
What you can do, however, is switch your rendering order. First, draw all the tiles with alpha-blending disabled completely. Then, when you're done with the drawing, draw the lightmap onto the tiles, with alphablending enabled. While this isn't the best solution, it should work out okay.
Hope this helps.
What you can do, however, is switch your rendering order. First, draw all the tiles with alpha-blending disabled completely. Then, when you're done with the drawing, draw the lightmap onto the tiles, with alphablending enabled. While this isn't the best solution, it should work out okay.
Hope this helps.
It looks like you need some alpha data in those lightmaps.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement