View previous topic :: View next topic |
Author |
Message |
goldenboy

Joined: 05 Sep 2008 Posts: 310 Location: Kiel
|
Posted: Fri Jun 11, 2010 11:45 am Post subject: Adding volumetric fog to a Quake engine |
|
|
how insane is it, on a scale from 1 - 10? _________________ ReMakeQuake
The Realm of Blog Magic |
|
Back to top |
|
 |
leileilol

Joined: 15 Oct 2004 Posts: 1321
|
Posted: Fri Jun 11, 2010 11:53 am Post subject: |
|
|
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 |
|
 |
goldenboy

Joined: 05 Sep 2008 Posts: 310 Location: Kiel
|
Posted: Fri Jun 11, 2010 11:58 am Post subject: |
|
|
content type?
*fog
or func_fog, similar to func_illusionary / func_water? _________________ ReMakeQuake
The Realm of Blog Magic |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Fri Jun 11, 2010 1:25 pm Post subject: |
|
|
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 |
|
 |
metlslime
Joined: 05 Feb 2008 Posts: 177
|
Posted: Fri Jun 11, 2010 6:17 pm Post subject: |
|
|
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 |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Fri Jun 11, 2010 6:32 pm Post subject: |
|
|
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 |
|
 |
|