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

Known issues: very big atmosphere. [FIX] #4

Open
FECU opened this issue Sep 21, 2020 · 5 comments
Open

Known issues: very big atmosphere. [FIX] #4

FECU opened this issue Sep 21, 2020 · 5 comments

Comments

@FECU
Copy link

FECU commented Sep 21, 2020

The docs make reference to an issue in Godot with large meshes where the centre of the bounding box isn't rendered. This limit on draw distance is implemented by Godot because, without it, there would be floating point rounding errors close up.

A solution is to manually override the draw distance with:

render_mode skip_vertex_transform;

and within the vertex shader set the z axis max draw equal to the max w distance minus some small amount:

	VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
	NORMAL = (MODELVIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;

	POSITION = (PROJECTION_MATRIX * vec4(VERTEX, 1.0));
	POSITION.z = POSITION.w * 0.999999;

Credit to Bastian Olij.

@Dimev
Copy link
Owner

Dimev commented Sep 22, 2020

Thanks, I'll look into it, although from what I know the issue comes from depth buffer precision issues. Where in the docs is this issue specified?

@Dimev
Copy link
Owner

Dimev commented Jan 2, 2021

I tried this, but it doesn't actually solve the issue, the z-fighting still occurs

@FECU
Copy link
Author

FECU commented Jan 3, 2021

To be clear, this solution solves the "black box" effect at distance. Pure z-fighting over large distances is another matter. Vec3 contains 32 bit single precision floats. One is for pos/neg, half a dozen or so are for the exponent leaving you with twenty odd for decimal resolution. More definition than that cannot be stored. This comes down to GPU architecture favouring a fast and wide computational wavefront rather than depth so they don't do 64 bit double floats (because 32bit gives more than enough colours). This is fundamental to the equipment we're working with and there's no coding round it. But you can do things like swap to a billboard over a certain distance, which would be much cheaper too. That's best handled that CPU side.

@Dimev
Copy link
Owner

Dimev commented Jan 3, 2021

Hmm, I haven't heard of the black box thing
The issue here is that the godot version has issues at larger distance, but the ue4 version doesn't, for some reason.

@Dimev
Copy link
Owner

Dimev commented Mar 11, 2023

Can you check if it works in godot 4 now?

They migh have fixed it in the engine.

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

2 participants