• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Need help d3d_set_fog

E

ezravitto

Guest
I have a question...

does d3d_set_fog on gamemaker 8 same as gms1 and gms2?

i was trying to use it to create depth on my 2d game. I started coding my game on gm8 but when I imported it on gms, its all black...

the code is something like this..
GML:
_fog = distance_to_object(oPlayer)
d3d_set_fog(true, c_black, -power(_fog,1.5), 2000);

//draw tree sprite

d3d_set_fog(false, c_black, -power(_fog,1.5), 2000);

could anyone help me with this one?? thanks!!
 

Attachments

Last edited by a moderator:
E

ezravitto

Guest
more screenshot

1590336117514.png

ps : its not set in 3d. its just like sprite stacking(fake 3d).
 
E

ezravitto

Guest
My guess is that the camera is closer to 0 on the z axis in gms8 than it is in gms1.4. Camera is located at -16000 in gms1.4.
is there any way i can change that so it will look the same sa gm8? I tried subtracting it on any of start and end of the function but nothing. i also tried multiplying the end to a large number and something strange happen.
 
If that is indeed the issue, there are three ways you can fix it. Move the instances so they are within the range you specified in the d3d_fog function. Change the distance arguments you supplied to the d3d_fog_function. Or change the position of the camera (you'd need to use matrix functions).
 
E

ezravitto

Guest
If that is indeed the issue, there are three ways you can fix it. Move the instances so they are within the range you specified in the d3d_fog function. Change the distance arguments you supplied to the d3d_fog_function. Or change the position of the camera (you'd need to use matrix functions).
Im trying to do the 2nd option, just changing the arguments in d3d fog function. changing the start to objectPlayer, and the end to 2000. It seems to work on gm8, should I subtract 16000 to the start argument of d3d_set_fog?
 
Distance to your player is probably 16000 + player's depth. If you want the fog to start at the player, use that as the "start" argument. The "end" argument should be "start" + some amount.
 
E

ezravitto

Guest
Distance to your player is probably 16000 + player's depth. If you want the fog to start at the player, use that as the "start" argument. The "end" argument should be "start" + some amount.
you mean something like this?

_dist = point_distance(x,y,player.x,player.y);
d3d_set_fog(true,c_white,16000,16000+_dist);

im writing this inside the draw event of object tree
 
Wait a second. I forgot something really important.

By default, gamemaker does not use the "depth" of an instance as it's z position. You'd have to enable d3d_start for that. Which means you'd have to then switch to an orthographic projection before drawing.
 
Ok, this isn't going to work correctly. Hang on a moment, I'm going to try something.

Actually, enabling d3d_start and then setting an orthographic projection does seem to work.

EDIT: Are you using GM8 or GMS1?
 
Last edited:
E

ezravitto

Guest
ohh its working now.. thankyou @flyingsaucerinvasion ! for telling me that the camera is 16000 further in gms :D


it goes like this...

_dist = point_distance(x,y,player.x,player.y);
d3d_set_fog(true,c_white,16000-(_dist/80), 16001);


1590371193820.png
 
E

ezravitto

Guest
Which version of GM are you using?
I use this code in gm8:
_dist = point_distance(x,y,player.x,player.y);
d3d_set_fog(true,c_white,-power(_dist,1.5),2000); // i was using power function to control the gradient of the fog distance



and this code in gmstudio 1.4:
_dist = point_distance(x,y,player.x,player.y);
d3d_set_fog(true,c_white,16000-(_dist/80), 16001);
 
Top