Dimev / Realistic-Atmosphere-Godot-and-UE4

A realistic atmosphere material for both the Godot game engine and Unreal Engine 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Known issues: very big atmosphere. [FIX]

FECU opened this issue · comments

commented

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.

commented

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?

commented

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

commented

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.

commented

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.

commented

Can you check if it works in godot 4 now?

They migh have fixed it in the engine.