Jump to content


Photo

3D RTS Fog of War problem with surface


  • Please log in to reply
2 replies to this topic

#1 Lightarious

Lightarious

    GMC Member

  • New Member
  • 13 posts

Posted 09 June 2012 - 08:25 PM

I'm not used to using surfaces been looking them up for a couple hours, I got the fog of war working on a 2D game, exported it to my 3D game, and it just stays black.

create event for fog
global.scalefog=5

background_showcolor=false
global.fog=surface_create(room_width/global.scalefog,
room_height/global.scalefog)
surface_set_target(global.fog)
    draw_clear_alpha(c_white,1)
    draw_set_color(c_white)
    draw_set_blend_mode(bm_add)
    draw_rectangle(0,0,room_width/global.scalefog,room_height/global.scalefog,0)
    d3d_transform_set_identity()
    draw_set_blend_mode(bm_normal)
surface_reset_target()

Draw event for fog
draw_set_color(c_black)
draw_surface_ext(global.fog,0,0,global.scalefog,global.scalefog,0,c_black/*c_white makes it stay white instead.*/,1)
draw_set_color(c_white)

Draw event for units
background_showcolor=false
draw_set_color(c_white)
surface_set_target(global.fog)
draw_set_blend_mode(bm_subtract)
draw_circle(x/global.scalefog,y/global.scalefog,200/global.scalefog,0)
draw_set_blend_mode(bm_normal)
surface_reset_target()
background_showcolor=true

Does anyone know the problem? ---Thanks in advance!
  • 0

#2 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2590 posts
  • Version:GM:Studio

Posted 11 June 2012 - 09:19 PM

Your game is 3D, and I suspect you're trying to draw 2D to a surface while the 3D camera is still active. So call d3d_set_projection_ortho(0, 0, room_width/global.scalefog, room_height/global.scalefog, 0) to create a 2D projection before drawing to the surface.
  • 0

#3 Lightarious

Lightarious

    GMC Member

  • New Member
  • 13 posts

Posted 14 June 2012 - 07:36 PM

Your game is 3D, and I suspect you're trying to draw 2D to a surface while the 3D camera is still active. So call d3d_set_projection_ortho(0, 0, room_width/global.scalefog, room_height/global.scalefog, 0) to create a 2D projection before drawing to the surface.

Well now the unit isn't invisible XD but the surface is still staying black :(.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users