Godot: Light2D with Viewport Texture - Error: Condition ' det == 0 ' is true

Created on 27 Feb 2018  路  12Comments  路  Source: godotengine/godot

Godot version:
3.0.1 stable x64

OS/device including version:
Windows 7 x64

Issue description:
When I try and use a Viewport Texture with a Light2D I get the following error on repeat:

0:00:07:0589 - Condition ' det == 0 ' is true.

Type:Error
Description:
Time: 0:00:07:0589
C Error: Condition ' det == 0 ' is true.
C Source: coremathmath_2d.cpp:326
C Function: Transform2D::affine_invert

I tried creating the same project in Godot v2 and it works fine. Am I doing something wrong in Godot v3?

Steps to reproduce:
Import and run the attached viewportlight2Dv3 project. I have attached viewportlight2Dv2 for reference.

Minimal reproduction project:

viewportlight2Dv3.zip

viewportlight2Dv2.zip

bug rendering

Most helpful comment

This is indeed still reproducible with the project attached in the OP, on 414097e.

All 12 comments

Just ran into this same problem myself using 3.0.3 stable, with the same error message. Hope that it receives some attention! I am trying to get a shader to distort a texture used for a light2d, but using a material shader on the light2d doesn't work. Was then going to try it by using the texture in a separate scene with a shader and then piping it in to the light2d via a viewport texture. Alas this also doesn't work...out of options at this stage :)

Thank you for adding this to the 3.1 milestone!

@fracteed I think I went down a similar road trying to find a workaround but no such luck :)
I was trying to create a nicer torch beam 2D spotlight for use with normal maps, but since you can't rotate a light2D node when normal maps are involved you have to rotate the light sprite inside a viewport instead.

@yanorax I found a workaround for this issue that works for me at least. I am using a standard sprite with the viewport as a texture. Then I add a Canvas Item Material to this sprite with blendmode set to mult and light only mode. This works great for the caustics in my underwater game, but may not be suitable for a standard light.

Light2D still produces the "Condition ' det == 0 ' is true." error. when the texture is assigned via code
It does not seem to be fixed.

Godot Version: 3.1.alpha.custom_build.a3501c0
OS: Win10x64

This is indeed still reproducible with the project attached in the OP, on 414097e.

I still see this issue in latest godot 3.0

After some debug, I found the ViewportTexture is workable for nodes that keep do drawing, like TextureRect, and not workable for Light2D.

Because, Light2D only draw once. In the moment of Light2D calling draw, ViewportTexture is not ready, if you save the texture to png, it would show some random pixels.

And for nodes like TextureRect, in the first draw call, it also get the random pixel, but after that, ViewportTexture would be ready(drawed), and the following draw call would use the ready ViewportTexture and show correctly.

So basically, the issue is about the drawing order between render-to-target-viewport(ViewportTexture) and nodes that depend on it.

So is it possible to let that godotenine draw the render-to-target-viewport prior to all other nodes, or all nodes that reside below of it.
@akien-mga

I do not see the option to add ViewportTexture to Light2D anymore, only StreamTexture and ImageTexture are available.

:+1

I can still reproduce this error in 3.1 beta 4.

I'm using this to workaround Light2D not accepting custom shaders.

In 3.2.2, I had to set the viewport Render Target / Update Mode to "always", which seems to avoid the error. I guess I'll add a mechanism to avoid updating the texture when it's far from the camera.

Was this page helpful?
0 / 5 - 0 ratings