Inside3D!
     

Adding volumetric fog to a Quake engine

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
goldenboy



Joined: 05 Sep 2008
Posts: 310
Location: Kiel

PostPosted: Fri Jun 11, 2010 11:45 am    Post subject: Adding volumetric fog to a Quake engine Reply with quote

how insane is it, on a scale from 1 - 10?
_________________
ReMakeQuake
The Realm of Blog Magic
Back to top
View user's profile Send private message
leileilol



Joined: 15 Oct 2004
Posts: 1321

PostPosted: Fri Jun 11, 2010 11:53 am    Post subject: Reply with quote

heffo did it once, so i'd put it on a 62

The big problem is how are you going to 'define' the fog in just plain Q1BSP? Q3BSP has native support for such thing in surfaceparms with shaders.
_________________
Back to top
View user's profile Send private message
goldenboy



Joined: 05 Sep 2008
Posts: 310
Location: Kiel

PostPosted: Fri Jun 11, 2010 11:58 am    Post subject: Reply with quote

content type?

*fog

or func_fog, similar to func_illusionary / func_water?
_________________
ReMakeQuake
The Realm of Blog Magic
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Jun 11, 2010 1:25 pm    Post subject: Reply with quote

you could attach volumetric fog to a func_fog entity, yeah... Then you could move it around... *cough*.

For volumetric fog to be effective, you need to define the fog using a plane. Anything one side is fogged, anything the other is not (unless the view is inside the fog in which case its all fogged relative to the distance to the plane rather than the surface in question).

Due to needing a plane, you can't just attach it to a content type without there being restrictions.
You could flow through ajacent nodes and detect the plane above it and use that for the region.
But then you can't have underwater fog!
Plus its common enough to have multiple such top surfaces.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
metlslime



Joined: 05 Feb 2008
Posts: 177

PostPosted: Fri Jun 11, 2010 6:17 pm    Post subject: Reply with quote

You basically create a brush entity and hard-code the engine to look for a specific classname (such as "fog") I tried this back when i first started fitzquake, and got it about 50% working. I started with teh assumption that fog volumes were convex, but could be placed arbitrarily (including letting you see multiple faces of them) My basic technique was:

1. using each fog front face in turn, create a portal and render all fog backfaces clipped to that portal. (If you are inside the volume, there are no front faces and you can just render the backfaces unclipped.) The alpha of each vertex is determined by the length of the vector through the volume (ray from camera clipped to front face)

2. the only remaining task is drawing the fog blend on top of entities that are inside or partially inside the fog volume. If fully inside, you can render all faces using the same "clip to a portal" technique as above. If they are partially outside, that's the part i never solved. For alias models you could set alpha to zero for any vertex outside teh volume, since alias triangles are small. For brushmodels you might need to split any polygons that cross the boundary.

---

I think there's an opengl extension to make fog easier by letting you define a front plane and it will calculate density correctly based on the distance behind the plane to the surface being drawn. So you could use that to make the above technique easier. Or you could just get really restrictive like quake3 did, and then your work gets really easy. (only one front face and no backfaces allowed to be visible.)
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Jun 11, 2010 6:32 pm    Post subject: Reply with quote

If you want to draw emulated fog, the typical way to specify intensities is with a texture coord and a 1d texture(or 2d with a height of 1), with texture clamping instead of wrapping.
The texture coord is then correctly clamped so you do not have to worry about large surfaces crossing the fog plane.
This results in each vertex being processed as just tc_s = DotProduct(vertex,planenormal)-planedist.
Preferably in a vertex program. Your foreground colour is also a constant for every vertex, and your t texture coord does not matter.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group