A very foggy earth?

Blitz3D Forums/Blitz3D Programming/A very foggy earth?

Captain Wicker (crazy hillbilly)(Posted 2012) [#1]
Hi,

Does anyone know how to make my scene as well seen HERE
foggy? Is there an example anywhere on how to create a lot of fog?

Again, I cannot post my source code as I do not want anyone to copy what I have written. Thanks for understanding.


Yasha(Posted 2012) [#2]
Is there an example anywhere on how to create a lot of fog?


What kind of fog are you after?

You can use built-in camera fog if you want everything to fade away into nothingness at a given distance from the camera. This will form an even soft sphere around your POV, and work "through" objects, indoors, etc. Completely regardless of anything else in the scene, as it works entirely on the camera (note that this may potentially break 2D drawing libraries like Draw3D that place HUD elements in the extreme distance).

If you want fog to be positioned in a specific location (e.g. close to the ground, like swirling mist; or perhaps a cloud of steam in a room with a broken pipe) you'll probably need a solution involving layered particles. These will work different depending on how you want the cloud to look. Note that large "volumetric" clouds drawn in this way will often look really bad unless you take a lot of care over their exact position and how they overlap other scene objects (if you ever played Morrowind... that had great examples of how not to do ash clouds!), as you may be able to see the "gaps" between the panels that make up the cloud. Particles can also result in sudden massive leaps in the rendering requirements.

You could also potentially go for a depth-based method, but without shader support this would be sketchy at best... would not recommend unless you know what you're doing. This would probably only work well for static clouds of fog rather than anything that has to move.


I cannot post my source code as I do not want anyone to copy what I have written


...grow up. If you're asking for help, your code isn't going to be stolen by anyone. Insistence on total code privacy is a big faux pas in the computing world.


Guy Fawkes(Posted 2012) [#3]
I suggest u create an EXAMPLE code then, that mimics ur game's world. So the coder's can take a look at it. :) We don't want to steal. We only want to help :)


Captain Wicker (crazy hillbilly)(Posted 2012) [#4]
We don't want to steal.

Alright, I'll see what I can do and that is to direct you to the blitz user gallery. I have a pic there and that's pretty much all I have for now. What I'm trying to do is insert a fairly large fog thick enough to hide some of the low detailed textures. A smokescreen is a good example of what I had in mind.


Yasha(Posted 2012) [#5]
Sounds like you want camera fog (CameraFogMode, CameraFogRange, CameraFogColor), possibly combined with some object fade to hide unnecessary objects at log distances (EntityAutoFade).

Camera fog is set on a per-camera basis, so don't be put off by my comment about HUDs above: if you are using Draw3D or an equivalent, you can always have a second HUD camera with fog disabled, for rendering 2D elements.

Last edited 2012


Guy Fawkes(Posted 2012) [#6]
I'll make you a WIP, but it'll be a few minutes :) I have my own coding problems too, ya know :P ;)


Guy Fawkes(Posted 2012) [#7]
Here ya go, bud.... Sorry it took so long. as I said, I have my own code problems to take care of... :)


Advanced coders, PLEASE improve upon this example :)



Also, the collision and gravity are NOT my best codes.... I just did a quick hack job of it to show how it works :)


This basically shows how to use camera fog, fog the whole place up, and auto fade out each entity u want! :)


It also records a couple of distances of the entire whole of the objects currently created by blitz :)


Here's the project:


http://www.mediafire.com/?zvw7dt3j0v6o85b


As I asked, coders, PLEASE improve upon this if u feel the need :)


Thanks!


Good luck with ur project! :)


~Thundros

Last edited 2012


Captain Wicker (crazy hillbilly)(Posted 2012) [#8]
Thanks Thundros and good luck on your projects as well. :)


Guy Fawkes(Posted 2012) [#9]
Ur welcome! :)


Is this what u wanted? :D


Captain Wicker (crazy hillbilly)(Posted 2012) [#10]
very much so. :D


Midimaster(Posted 2012) [#11]
here is a CameraFog() sample:

Graphics3D 800,600
SetBuffer BackBuffer() 
fps =CreateTimer(30)
Global fog%=300
;die Kamera
	Global Cam1=CreateCamera()
		MoveEntity Cam1,0,5,-15
		CameraFogMode cam1,1
		CameraFogColor Cam1,255,255,255
		CameraFogRange Cam1,1,300
	


;Zufalls_Landschaft:
	SeedRnd 12345 ; MilliSecs()
	SeedRnd  MilliSecs()
	
	Boden=CreatePlane()
		EntityColor boden,115,115,115
	Himmel=CreateSphere(32)
		FlipMesh himmel
		ScaleEntity Himmel,800,99,800
		EntityColor himmel,0,0,255
		MoveEntity himmel,0,0,0
	;Häuser
		For i=0 To 144
			b=CreateCube()
			ScaleEntity b, Rand(10),Rand(30),Rand(10)
			EntityColor b,Rand(255),Rand(255),Rand(255)
			MoveEntity b,350-Rand(700),0,350-Rand(700)
			TurnEntity b, 0,Rand(360),0
		Next
	
;das Licht:
	Licht=CreateLight()
		TurnEntity licht, 0,90,0
		MoveEntity licht,-30,30,30



While Not KeyHit (1) 
	Weg=Weg + .1
	Kamera ()
	;UpdateWorld
	RenderWorld
	Text 10,500," Press <1> or <2> to change fog range. Press Mouse() to turn around. FogRange="+fog
	Flip 0
	WaitTimer fps
	;WaitKey
Wend 

End




Function Kamera()
;Kamera drehen
	If MouseDown (2)
		TurnEntity cam1,0,1,0
	EndIf
	If MouseDown(1)
		TurnEntity cam1,0,-1,0
	EndIf
	If KeyDown(2)
		fog=fog*1.01
		DebugLog fog
	ElseIf KeyDown(3)
		fog=fog/1.01
		DebugLog fog
	EndIf	
			CameraFogRange Cam1,1,fog

End Function


Hope, I can help you. By the way: Running this sample on my computer there is a "break" in continuity of "fog growing". At FogRange of 255 the fog changes to strong. Is this a bug of B3D or only a problem in my graphic card?

Last edited 2012


Guy Fawkes(Posted 2012) [#12]
No problem, Austin! :)