How Do I fix the default renderer not working

I am receiving the error

ERROR:SCRIPT: builtins/render/default.render_script:176: argument #1 contains one or more values which are not numbers: vmath.matrix4(nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, 0, 0, 0, 1)
stack traceback:
[C]:-1: in function set_view
builtins/render/default.render_script:176: in function <builtins/render/default.render_script:156>

and I am calling the script with

msg.post(“operator#camera”, “acquire_camera_focus”)

in the init function, when I don’t have the camera o the operator object, I do not receive an error but I also do not receive any image

1 Like

What are the properties of your camera component?

image

Are you getting this error every frame or just once? Are you using the default render script? When are you calling “acquire_camera_focus”?

I am getting the error every frame. I am using the default render script. I am calling “acquire_camera_focus” in the init func.

Odd. The error seems to indicate that something isn’t configured properly. Can you share the project here?

You’ve set a very small scale value on the z-component of your player, and since you also have the camera as a child of the player the scale will be inherited and it will cause problems when calculating the view projection since the z-value is involved in the calculation:

I assume this value is set by mistake, or is there a reason why it is so small?

Also, you have a scale on the operator game object which holds the camera. These values are reasonable, but again I wonder about their purpose?

1 Like

why does the z being very small cause problems with the calculations

what would the appropriate value be to fix the problem then?

The camera view and projection is calculated based on the camera properties such as near and far z planes, fov and so on. The camera transform (ie position, rotation and scale) are also used in the calculation of the view and projection. A z value of 0.000001 is very small and the final calculation of the projection matrix will not give you valid values. I can’t give you the exact reason but it’s bound to be rounding and math precision issues of some kind.

Set the z value of your camera game object to 1. Does it have to be 0.000001? If so, why?

1 Like

no it doesn’t, and that fixed the problem thank you

It’s a common thing with computers and floating point values.
They don’t have infinite precision, and sooner or later they may very well be something other than what is expected, due to rounding errors.
And once those rounding errors accumulate, there’s even more risk that the value may get rounded to something you didn’t expect, or the calculations didn’t accept.

In this case, it’s likely it (eventually) got rounded to something close to zero, which was invalid for a calculation. In those cases, you get a NaN which stands for Not A Number. At that point, any further calculations won’t work, and will just produce more NaN’s.

Here’s a video of how it may appear in other scenarios, when the NaN spreads through calculations.

2 Likes

Thanks @britzl