Jump to content

Floating Point Fix Questions


Thomas123

Recommended Posts

Hi everyone. I have another question. This time about the floating point fix. Even after digging through the forums and the script code, I have no idea how these scripts work. Theoretically it's clear. But the way the scripts work seems to be different depending on the terrain chunk.

  • I have two world chunks (3_6 and 4_6)
    • 3_6 has the world position -1024, 0, 2048
    • 4_6 has a world position of 0, 0, 2048
  • I sort all spawns and vegetation under the terrain.
  • I have a "world" scene, the Gaia terrains are loaded by Gaia as additional scenes.
  • The main camera and (currently) most of the managers (like gaia runetime) are in the world scene.
  • I have attached the Gaia Floating Point Fix to the main camera.

Now on both terrains the coordinates act differently.

  • while on 4_6 (left chunk) the transform positions are relative to the terrain
    • that means 0,0,0 on the terrain will be the lower left corner of the chunk
    • so 512,50,512 is the center of the chunk
    • the chunk has no floating point fix member
  • while on 3_6 the transform positions are ... no idea what they are. At least weird ;-)
    • when I use "normal" positions and measures on this terrain (e.g. 512,50,512), I get a unity warning (Due to floating-point precision limitations...)
    • So I use percentates (like 0.5 for 50%) to define the position and size of an object (512,50,512 -> 0.5, 0.5, 0.5). This partially works. But the resulting size will not match the terrain. Nor the height will fit.
    • adding floating point fix member to terrain or objects will not help or change this behavior. Nor the unity warning will be gone
  • the same behavior is true for other terrain chunks (in Editor Mode)
  • I used a TVE element to demonstrate this (blue color)

 

So my questions:

  • Where do I attach the floating point fix member scripts? To each terrain chunk? Or every object in it? What are they for and how do they work (roughly)?
  • Why does 4_6 work "normally" in terms of positions, while all the other terrains are messed up with their positions?
  • Is it possible to use the same coordinate system on every terrain? And how would I do this?
  • How do I match a plane of size 1024x1024 on both terrains if the measures are not the same? I would have to try out lots of floating point values 

 

Bildschirmfoto-2023-06-25-um-10-43-34.pn

Link to comment
Share on other sites

@BryanThank you. That link already helped a lot.

Quote

 

So my questions:

1. Where do I attach the floating point fix member scripts? To each terrain chunk? Or every object in it? What are they for and how do they work (roughly)?

2. Why does 4_6 work "normally" in terms of positions, while all the other terrains are messed up with their positions?

3. Is it possible to use the same coordinate system on every terrain? And how would I do this?

4. How do I match a plane of size 1024x1024 on both terrains if the measures are not the same? I would have to try out lots of floating point values 

 

Regarding 1: The script has to be attached to the main camera. Nothing else seems to be neccessary
Regarding 2: It's seems to be explained by the offset (FloatingPointFix.Instance.totalOffset)
Regarding 3: That seems to be possible by FloatingPointFix.Instance.ConvertToOriginalSpace
 

But I still don't understand why this is an issue within edit mode? I just type in coords into the transform of an object (plane in my case). Shouldn't this just work as the plane is relative to the terrain (which is shifted by the floating point fix)?

Link to comment
Share on other sites

Hi @Thomas123, I re-read your original post and I agree with this statement:
 

10 hours ago, Thomas123 said:

. Shouldn't this just work as the plane is relative to the terrain (which is shifted by the floating point fix)?

I don't think the floating point fix should influence your issue at all - when you enter a position into the transform, this position should be relative to the pivot point of the parent object. If you enter 0.5 0.5 0.5 for the "TVE Element" in your screenshot, this should place the pivot point of the TVE element at a distance of 0.5 on the X Y Z axis to the pivot point of the "Vegetation" object.
The floating point fix may or may not have shifted the parent terrain, but this should not change the way objects are positioned through the transform component in relation to the parent object.

Some additional pointers that might influence this:

  • If any parent object has a scale other than 1,1,1 applied to it, this might mess with your positioning, as it will influence the distances in the child object.
  • Please note that the positioning is based on the object PIVOT, not on the CENTER. It is possible to place the object handles either at the pivot  or the center of an object, this can then add to the confusion when looking at objects
    image.png
  • Please note that unity terrains have the pivot on the "lower XZ corner" and not at the center (which then requires child objects to have positions relative to that corner rather than the center of the terrain)
  • You can double check if floating point fix / shifted origin is at play by checking in the Gaia panel on top of the scene view, if the current world origin was shifted, you could see it here:
    image.png

My guess is that there is either a scaling or an offset at play here, e.g. in the parent "Vegetation" object.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...