RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
990 stars 175 forks source link

Fog distance cuts off clouds far #3135

Open cryham opened 4 months ago

cryham commented 4 months ago

Another bug I notice, since I added fog and clouds in SR based tracks.

I think I found it to be here: Could you just remove this line and check? Or set it to that from Gui setting App::gfx_sight_range.

            // setting farclip (hacky)
            App::GetCameraManager()->GetCamera()->setFarClipDistance(fogEnd / 0.8);

Also BTW, I think 5000 m isn't much for max far distance. And it's not really a key setting nowadays IMO. DrawGIntSlider(App::gfx_sight_range, _LC("GameSettings", "Sight range (meters)"), 100, 5000);

To test add in .terrn2:

CaelumFogStart = 0
CaelumFogEnd = 90.0

and in .os file at end e.g.


    cloud_system
    {
        cloud_layer low
        {
            height 500
            coverage 0.2
        }
        cloud_layer mid
        {
            height 700
            coverage 0.6
        }
        cloud_layer high
        {
            height 1000
            coverage 0.8
        }
    }
}

1657 1704e`

CuriousMike56 commented 4 months ago

It appears App::GetCameraManager()->GetCamera()->setFarClipDistance(fogEnd / 0.8); culls far away objects. This is latest master: screenshot_2024-03-04_14-05-06_1 And here's with the above line removed: screenshot_2024-03-04_14-05-26_1 Clouds are fully visible now, but notice the much higher triangle/batch count and subsequently lower FPS. image

Also BTW, I think 5000 m isn't much for max far distance. And it's not really a key setting nowadays IMO.

Pretty sure 5000 is actually unlimited, on extremely large maps such as Grenoble the entire heightmap is visible: screenshot_2024-03-01_14-24-59_1

cryham commented 4 months ago

Okay. Well right now it's either fog or clouds, can't have both. So I think this should be fixed. Can't have far flat plane clouds with near camera distance. As for more batches, I think it'd be up to user or graphics presets to set this if it drops Fps. Anyway 140 Fps sounds pretty high already, and over 2000 batches like way too high regardless.

CuriousMike56 commented 3 months ago

Yeah the FPS is only because I'm on a high end PC (13700k, 4070ti), the difference will be much more drastic on the average player's lower end CPU with integrated graphics. High batch count is another pain point in RoR, Petr is aiming to fix it with his TerrnBatcher project (#3030)

I'm sure there's a proper way to fix the clouds, maybe with a patch to Caelum sources?

CuriousMike56 commented 3 months ago

Looking at Caelum source, the cloud entity is named Caelum/FlatCloudLayer/Entity/ + random ID. Would it be possible to apply the culling to all objects except the cloud entity?

cryham commented 3 months ago

I don't think it's possible. This is camera far plane, it works for all.

ohlidalp commented 3 months ago

@paroj Can you advise please? Intuitively I'd expect some option to override the near/far clipping per render queue or maybe even per entity.

paroj commented 3 months ago

Intuitively I'd expect some option to override the near/far clipping per render queue or maybe even per entity.

yes, you can set the max rendering distance per entity: https://ogrecave.github.io/ogre/api/latest/class_ogre_1_1_movable_object.html#afe1f2a1009e3f14f36e1bcc9b1b9557e

note that using the far plane for this was wrong all along, as not rendering the objects is merely a side effect. The main purpose of the far plane is controlling the depth precision. The visibility system in Ogre is the intended tool for this.

cryham commented 3 months ago

I don't think we're on the same page, or maybe I don't get it, I didn't look much inside code. Am I right here ?:

paroj commented 3 months ago

all above statements are correct. you want different CPU culling distances for different objects (cloud/ terrain - the rest). FarClipDistance can only be set globally and influences HW and CPU culling. Therefore you need to use rendering distance.

All triangles are culled by HW on GPU (during rasterization?). From camera far parameters also?

yes, see: https://paroj.github.io/gltut/Positioning/Tut04%20Perspective%20Projection.html#idp2563

cryham commented 3 months ago

Okay. So I think the solution is still like like wrote in 1st post. To have far visibility of clouds. But also to have less trees, adding maybe own distance to Gui or some other way to have them visible less far. From what I know trees etc are in paged-geom and controlled by track file in .tobj like so: trees 0, 360, 1.30169, 1.57545, 1.0, 300, 1000, treeD-22desMed.mesh none Des17-NileCity-veget4.png here 300, 1000, is distance1, distance2, so it should rather be controlled by user from Gui for all tracks rather than by each track itself. I'd also BTW add a multiplier (for that 1.0 before or a new thing) for trees multiplier to reduce (or get more) trees by user, from Gui too. We have such multipliers for trees, grass and their distance in StuntRally since a long time.