Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fog distance cuts off clouds far #3135

Open
cryham opened this issue Mar 1, 2024 · 10 comments
Open

Fog distance cuts off clouds far #3135

cryham opened this issue Mar 1, 2024 · 10 comments

Comments

@cryham
Copy link
Contributor

cryham commented Mar 1, 2024

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`

@cryham cryham mentioned this issue Mar 1, 2024
@CuriousMike56
Copy link
Collaborator

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
Copy link
Contributor Author

cryham commented Mar 4, 2024

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.

@cryham cryham closed this as completed Mar 4, 2024
@cryham cryham reopened this Mar 4, 2024
@CuriousMike56
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Contributor Author

cryham commented Mar 9, 2024

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

@ohlidalp
Copy link
Member

@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
Copy link
Contributor

paroj commented Mar 12, 2024

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
Copy link
Contributor Author

cryham commented Mar 12, 2024

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 ?:

  • One cloud layer here is done with a plane, which is basically 2 big triangles.
  • All triangles are culled by HW on GPU (during rasterization?). From camera far parameters also?
  • Setting camera FarClipDistance, does change its frustum culling, which works well (on CPU) for many single entities,
    meshes with small triangles.
  • rendering distance per entity also does the same, disable or enable rendering basing of distance.
  • even if clouds had a plane with many triangles these would also get cut off and culled in HW

@paroj
Copy link
Contributor

paroj commented Mar 12, 2024

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
Copy link
Contributor Author

cryham commented Mar 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants