For perspective camera, specifying zfar is not required #4

Open
opened 2020-04-01 19:43:06 +00:00 by michaliskambi · 0 comments
michaliskambi commented 2020-04-01 19:43:06 +00:00 (Migrated from github.com)

Loading a model from https://poly.google.com/view/9Vq_-HEtIHA (downloaded version using "Updated GLTF file") raises an error

Invalid GLTF document, missing "zfar" field

Indeed, glTF file doesn't specify zfar:

   "cameras" : [
      {
         "perspective" : {
            "yfov" : 0.7853981633974483,
            "znear" : 0.1000000014901161
         },
         "type" : "perspective"
      }
   ],

Looking at glTF 2.0 specification, zfar is not required for perspective cameras: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-perspective . It says "Required: No" and "If zfar is undefined, runtime must use infinite projection matrix." . But PasGLTF requires it, by reading it through Required function,

result.fPerspective.fZFar:=TPasJSON.GetNumber(Required(....

on https://github.com/BeRo1985/pasgltf/blob/master/src/PasGLTF.pas#L4050 .

Also aspectRatio is not required, according to the glTF 2.0 specification, but PasGLTF code makes it required.

Note that zfar is still required for orthographic cameras, which may explain why this bug appeared :)

Loading a model from https://poly.google.com/view/9Vq_-HEtIHA (downloaded version using "Updated GLTF file") raises an error ``` Invalid GLTF document, missing "zfar" field ``` Indeed, glTF file doesn't specify zfar: ``` "cameras" : [ { "perspective" : { "yfov" : 0.7853981633974483, "znear" : 0.1000000014901161 }, "type" : "perspective" } ], ``` Looking at glTF 2.0 specification, zfar is not required for perspective cameras: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-perspective . It says "Required: No" and "If zfar is undefined, runtime must use infinite projection matrix." . But PasGLTF requires it, by reading it through `Required` function, ``` result.fPerspective.fZFar:=TPasJSON.GetNumber(Required(.... ``` on https://github.com/BeRo1985/pasgltf/blob/master/src/PasGLTF.pas#L4050 . Also `aspectRatio` is not required, according to the glTF 2.0 specification, but PasGLTF code makes it required. Note that `zfar` is still required for orthographic cameras, which may explain why this bug appeared :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BeRo1985/pasgltf#4
No description provided.