Page 1 of 2

Menori - LÖVE library for simple 3D and 2D rendering

Posted: Tue Jun 01, 2021 6:15 pm
by rozenmad
Some time ago I've made a library for 2D and 3D rendering based on the idea of a scene graph for my projects. It's still not perfect, but I'm working on improving it.
Loading of 3D models in .gltf format is also supported.
On the github you can find documentation and simple example. I'll add more complex examples in the future.
I hope you find the library useful.

Documentation
Menori on Github

Image

Usage example:

Code: Select all

local menori = require 'menori'
local application = menori.Application

local ml = menori.ml
local vec3 = ml.vec3
local quat = ml.quat

local NewScene = menori.Scene:extend('NewScene')

function NewScene:init()
	NewScene.super.init(self)

	local aspect = menori.Application.w/menori.Application.h
	self.camera = menori.PerspectiveCamera(60, aspect, 0.5, 1024)
	self.environment = menori.Environment(self.camera)

	local gltf = menori.glTFLoader.load('example_assets/players_room_model/scene.gltf')
	local model_node_tree = menori.ModelNodeTree(gltf)

	self.root_node = menori.Node()
	self.root_node:attach(model_node_tree)

	self.y_angle = 0
end

local rstate = {clear = true, colors = {{0.2, 0.15, 0.1, 1}}}
function NewScene:render()
	self:render_nodes(self.root_node, self.environment, rstate)
end

function NewScene:update_camera()
	self.y_angle = self.y_angle + 0.5
	local q = quat.from_euler_angles(0, math.rad(self.y_angle), math.rad(-45))
	local v = vec3(0, 0, 8)
	self.camera.eye = q * v
	self.camera:update_view_matrix()
end

function NewScene:update()
	self:update_camera()
	self:update_nodes(self.root_node, self.environment)
end

function love.load()
	local w, h = 960, 480
	application:resize_viewport(w, h)

	application:add_scene('new_scene', NewScene())
	application:set_scene('new_scene')
end

function love.draw()
	application:render()
end

function love.update(dt)
	application:update(dt)
end
See main.lua for a more complete example.

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Tue Jun 01, 2021 7:20 pm
by Gunroar:Cannon()
Oh my purple smacked butter glob! That looks really good. And am I wrong thinking that's the room of a classic Pokémon game made 3d? Gold maybe? :ultrahappy:

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Wed Jun 02, 2021 11:38 am
by uriid1
Wow! That's really cool :)

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Wed Jun 02, 2021 12:22 pm
by togFox
It is cool. I like.

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Sat Jun 05, 2021 1:33 am
by rozenmad
Thank you all. :)
Gunroar:Cannon() wrote: Tue Jun 01, 2021 7:20 pm Oh my purple smacked butter glob! That looks really good. And am I wrong thinking that's the room of a classic Pokémon game made 3d? Gold maybe? :ultrahappy:
It's from Pokemon FireRed.

By the way, I added a simple demo with this scene on my website using love.js:

DEMO

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Thu Nov 25, 2021 4:33 am
by siberian
There is a comment in file lighting.glsl

Code: Select all

// love2d use row major matrices by default, we have column major and need transpose it.
// 11.3 love has bug with matrix layout in shader:send().
vec4 position(mat4 transform_projection, vec4 vertex_position) {
      ...
}
What kind of bug?

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Thu Nov 25, 2021 7:56 pm
by rozenmad
siberian wrote: Thu Nov 25, 2021 4:33 am There is a comment in file lighting.glsl

Code: Select all

// love2d use row major matrices by default, we have column major and need transpose it.
// 11.3 love has bug with matrix layout in shader:send().
vec4 position(mat4 transform_projection, vec4 vertex_position) {
      ...
}
What kind of bug?

Code: Select all

Shader:send( name, data, matrixlayout, offset, size )
does not work properly in 11.3, it has been fixed, but in version 11.3 it will not work as it should.

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Mon May 09, 2022 8:58 pm
by rozenmad
A new version of the library has been released.
- revised documentation.
- the Material class has been added, as well as new methods to the Node class.
! If you use menori in your projects, be careful when updating the library, as there is no compatibility between different versions.

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Fri May 27, 2022 12:03 am
by ashifolfi
How exactly did you make that gltf file used in the demo? I tried both direct exporting a cube from blender using a plugin and using an fbx to gltf converter and both of them caused a crash in Menori and I cannot figure out why.

Re: Menori - LÖVE library for simple 3D and 2D rendering

Posted: Sun Jul 24, 2022 5:53 am
by Raph
Never mind! I was looking in the wrong place in the documentation.