Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411418 Posts in 69362 Topics- by 58416 Members - Latest Member: timothy feriandy

April 17, 2024, 04:52:43 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)(Fake) Infinite horizon plane, correctly fogged
Pages: [1]
Print
Author Topic: (Fake) Infinite horizon plane, correctly fogged  (Read 1965 times)
shrimp
Level 5
*****


View Profile WWW
« on: February 18, 2011, 02:16:47 PM »

Hi all,
In my landscape-based game, I have an island on a square heightmap mesh, surrounded by an infinite plane of water. My problem is how to render this "infinite" plane so that it blends seamlessly with the edge of the heightmap, more specifically, how to fog it correctly.

Here's an image of the problem:



Edge of the heightmap on the right, "infinite plane" on the LEFT. I'm sure the diffuse colours match, as if you tilt the camera to look straight down, they look pretty much the same. Here's an edit showing what it should look like

Things I Have Tried:
1) Massive stationary polygons around the "real" heightmap
2) One big quad oriented in front of the camera, with the far edge at the far clip plane and the near edge under the camera
3) As (2) above but split into "stripes" running across the view direction (have tried this artificially narrow in order to check that the problem isn't due to the ends of the stripes being far off the side of the screen)

So... is there something I don't understand about OGL's fogging maths?

For uber-diagnostical completeness, here's the fog setup from the start of the main render function: (C#, Tao framework binding for GL)

Code:
Gl.glFogi(Gl.GL_FOG_MODE, Gl.GL_EXP2); // Fog Mode: GL_EXP, GL_EXP2, GL_LINEAR
Gl.glFogfv(Gl.GL_FOG_COLOR, fogColor); // Set Fog Color
Gl.glFogf(Gl.GL_FOG_DENSITY, 0.0750f); // How Dense Will The Fog Be
Gl.glHint(Gl.GL_FOG_HINT, Gl.GL_NICEST); // Fog Hint Value
Gl.glFogf(Gl.GL_FOG_START, 5.0f); // Fog Start Depth
Gl.glFogf(Gl.GL_FOG_END, Tianxia.Drawing.Camera.FarDist); // Fog End Depth
Gl.glEnable(Gl.GL_FOG); // Enables GL_FOG

(fog colour is the same as the clear colour at the moment, that you can see in the "sky" in the pic above)

Most helpful reply wins a beer, if you're at GDC. If you aren't at GDC, you'll just have to make do with a :beer: Wink
« Last Edit: February 19, 2011, 12:20:47 AM by Ed » Logged

Pishtaco
Level 10
*****


View Profile WWW
« Reply #1 on: February 18, 2011, 03:40:57 PM »

Here's an image of the problem:



(Edge of the heightmap on the right, "infinite plane" on the right). I'm sure the diffuse colours match, as if you tilt the camera to look straight down, they look pretty much the same.

Do you mean heightmap on the right, infinite plane on the left? Even then, though, I don't understand the picture. Can you say what it's supposed to look like?

I had various problems with fog for Venus Patrol. I think one issue at the start was that I was using vertex fog (possibly without realizing it, because of something about hinting?), which gave weird effects when one of the vertices of my very large quad was outside the clipping distance. I quickly decided to do everything by hand in shaders, rather than mess around trying to understand crazy opengl commands.
Logged

shrimp
Level 5
*****


View Profile WWW
« Reply #2 on: February 19, 2011, 12:22:07 AM »

Oops yes, edited my post to fix that. Also added a link to a crude edit of the image to show what it should look like. Just going to try something out based on what you said there.......

Right, I tried MUCH thinner (front-to-back) slices nearer the camera, and it worked! It didn't seem to have anything to do with the left-to-right size of the slices, so going out of the view frustum seems not to make a difference at these distances.
I think the conclusion is that it is doing vertex fogging, which is annoying. I guess GL_NICEST just "requests" per-pixel fogging and my hardware doesn't support it?

Anyway, thanks! (See you at GDC or some other jam thing..!)
« Last Edit: February 19, 2011, 01:28:57 AM by Ed » Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic