Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > DirectX > Fog?


Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2004, 12:41 PM
HellBlazer13 HellBlazer13 is offline
Regular
 
Join Date: Feb 2003
Posts: 77
Default Fog?


How would I go about implementing fog in a Direct X 8 2D engine? I've attempted this twice now, but my textures just become the same color as the fog color, so you can't see the actual image.
Reply With Quote
  #2  
Old 04-16-2004, 04:49 PM
mark113 mark113 is offline
Freshman
 
Join Date: Aug 2002
Posts: 28
Default

I have used this for spellcasting effects. It is easy to implement and draws really fast. Try something like this in your RenderScene function.

vObjD3DDevNC.SetRenderState D3DRS_ALPHABLENDENABLE, 1

for i = 1 to SpriteCount
If SpriteArray(i).Transparent = 0 Then
vObjD3DDevNC.SetRenderState D3DRS_SRCBLEND, 5
vObjD3DDevNC.SetRenderState D3DRS_DESTBLEND, 6
ElseIf SpriteArray(i).Transparent = 1 Then
vObjD3DDevNC.SetRenderState D3DRS_SRCBLEND, 5
vObjD3DDevNC.SetRenderState D3DRS_DESTBLEND, 7
End If
vObjD3DDevNC.SetTexture 0, TextureArray.fGetTextureArray(x).Texture
next i

vObjD3DDevNC.SetRenderState D3DRS_ALPHABLENDENABLE, 0
vObjD3DDevNC.EndScene
vObjD3DDevNC.Present ByVal 0, ByVal 0, 0, ByVal 0

As I go through my sprite array I read if I want the sprite tobe rendered solid or transparent and change the renderstate back and forth within he Renderscene function. You will need to order the solid, ground level sprites first. Then the transparent fog sprites should be at the end of the array. This just sort of blends the two colors.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->