Page 1 of 1

3D in Love 11.0

Posted: Mon Feb 25, 2019 4:44 am
by barnyard
I heard Love 11.0 new 3D functions such as rendering were added in. I looked around for all the 3D related functions in the wiki, but couldn't find them. Is there a reference and perhaps tutorials on how to do 3D graphics within love?

Re: 3D in Love 11.0

Posted: Thu Feb 28, 2019 6:34 pm
by pgimeno
Hi barnyard, welcome to the forums.

LÖVE is a 2D engine. It can be made to work with 3D because support was added for the stuff that was missing, but it isn't much easier to use for 3D than raw OpenGL is, because 3D is not really its focus.

Rendering was not added in 11.0; it was supported from the beginning. Images are internally drawn as 3D faces with the Z coordinate set to 0, and with an orthographic projection. Meshes are supported since 0.9.0 and 3D mesh support since 0.10.0. Vertex shaders are also supported from 0.9.0, and fragment shaders since earlier.

What 11.0 added is support for some stuff that is almost essential for 3D like backface culling and depth buffers. Previously that could only be done by calling OpenGL through FFI.

All that said, there is at least one 3D engine for LÖVE, check out viewtopic.php?f=5&t=86350

Re: 3D in Love 11.0

Posted: Tue Mar 12, 2019 7:41 am
by barnyard
Is there a way that I can manipulate the images so that I can change the projection to perspective and set the Z coordinate to anything I want?

Re: 3D in Love 11.0

Posted: Tue Mar 12, 2019 10:00 am
by arampl
Sure. You have to use custom shader(s) and mesh vertex format like this:

Code: Select all

local vs = [[extern mat4 model; extern mat4 projection; extern mat4 view;
		vec4 position(mat4 transform_projection, vec4 vertex_position)
		{
			return projection * view * model * vertex_position;
		}]]

local format = {{"VertexPosition", "float", 3}, {"VertexTexCoord", "float", 2}, {"VertexColor", "byte", 4}}
mesh = lg.newMesh(format, vertices, "triangles")
Small demo (mouselook, controls: w,s,a,d - movement):