Need something clarified about using the lumiere shaders

specifically about this line, when It says add to Lumiere, does it mean the Lumiere. Lua file becuase theres already a Lumiere variable inside of it

I am also getting this error, and I can’t find suitable documentation on how to fix it, I tried to add the code into Lumiere.Lua

java.lang.AssertionError: Assert failed: Cycle detected on node type editor.code.script/ScriptNode and output :build-targets
(not (contains? (:in-production evaluation-context) [node-id label]))

It means the line where you call lumiere.use_effect(my_effect).

Do this from some script in your project.

thanks that got it to work, however I am now getting my entire level overlayed over my game instead of a glow effect???

Which effect are you using? One of the existing ones or have you created one of your own?

The lights effect

Ok, have you looked at the example that comes shipped with Lumiere? (I realise that I need to improve on the documentation, but the project is a work in progress). You need to do:

  1. Integrate lumiere in your render script
  2. Add lights.go to your project
  3. Add/use the lights effect in lumiere using
local lights = require "lumiere.effects.lights.lights"
lumiere.use_effect(lights)
  1. Add some light sources. Add sprites with some light masks (example: https://github.com/britzl/lumiere/blob/master/examples/assets/images/lights/light_mask_yellow_64.png) and assign the lightsource.material

What you see in your example is the ambient light being applied, but no light sources.

I tried to implement the lumiere however I’m having an issue with

		local frustum = self.projection * self.view
		render.draw(self.tile_pred, { frustum = frustum })
		render.draw(self.particle_pred, { frustum = frustum })
	end)

the error is:
bad argument #1 to ‘__mul’ (matrix4 expected, got function)
in response to self.projection

Since you mention it, what is the self.projection? Is it a matrix?

I honestly have no idea, It isn’t declared anywhere, I’ve checked the render learn page and its seen in one of the examples (without context of how to add it), and It doesn’t show up in the api doc

If you take a look at your render script there is for sure a reference to a projection. I assume you are modifying the default render script?

You can also use the render script that is included with Lumiere:

The most possible scenario is that you are assigning function directly to self.projection, instead of the result of the function (so you probably missed call operator - two brackets: ()?)

I suspect it, because there are functions calculating those projections and it’s common in render scripts to use them in update()

Something like:

 self.projection = fixed_fit_projection() -- assign vmath.matrix4 RETURNED from fixed_fit_projection function

(I didn’t checked if fixed_fit_projection takes any arguments, it’s only to show possible problem)

I have copied the code directly from the example, however I am getting the error

main/scripts/pc/loader.script:35: attempt to call field 'use_effect' (a nil value)

for reference I have

local lumiere = require("lumiere.lumiere")
	local lights = require("lumiere.effects.lights.lights")
	lumiere.use_effect({lights})

for the call

and

function M.use_effects(effects)
	assert(effects)

	lumiere.new_effects = effects
end

in the lumiere.lua file

The function says use_effects and not use_effect

2 Likes

oh yeah

sorry In parts of the github its spelt light

example: the readme

local lights = require "lumiere.effects.lights.lights"
lumiere.use_effect(lights)

I’m having issues, now I have ‘fixed’ applying the render script, I applied lights.go to my collection and I now have this


as you can see, I have the same issue, however Its more faint

what I really need help with is adding a lightsource object, I have an object that has a lightsource material applied to it in the same collection, however not only is the glow invisible, the object is also fully invisible in the faint layer? am I missing somthing

1 Like

Could you copy/paste the render script? Maybe we’ll find something :wink:

here

local lumiere = require("lumiere.lumiere")
-- projection that centers content with maintained aspect ratio and optional zoom
local function fixed_projection(near, far, zoom)
	local projected_width = render.get_window_width() / (zoom or 1)
	local projected_height = render.get_window_height() / (zoom or 1)
	local xoffset = -(projected_width - render.get_width()) / 2
	local yoffset = -(projected_height - render.get_height()) / 2
	return vmath.matrix4_orthographic(xoffset, xoffset + projected_width, yoffset, yoffset + projected_height, near, far)
end
--
-- projection that centers and fits content with maintained aspect ratio
--
local function fixed_fit_projection(near, far)
	local width = render.get_width()
	local height = render.get_height()
	local window_width = render.get_window_width()
	local window_height = render.get_window_height()
	local zoom = math.min(window_width / width, window_height / height)
	return fixed_projection(near, far, zoom)
end
--
-- projection that stretches content
--
local function stretch_projection(near, far)
	return vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), near, far)
end

local function get_projection(self)
	return self.projection_fn(self.near, self.far, self.zoom)
end

function init(self)
	lumiere.init()
	self.tile_pred = render.predicate({"tile"})
	self.gui_pred = render.predicate({"gui"})
	self.text_pred = render.predicate({"text"})
	self.particle_pred = render.predicate({"particle"})
	self.clear_color = vmath.vector4(0, 0, 0, 0)
	self.clear_color.x = sys.get_config("render.clear_color_red", 0)
	self.clear_color.y = sys.get_config("render.clear_color_green", 0)
	self.clear_color.z = sys.get_config("render.clear_color_blue", 0)
	self.clear_color.w = sys.get_config("render.clear_color_alpha", 0)
	-- default is stretch projection. copy from builtins and change for different projection
	-- or send a message to the render script to change projection:
	-- msg.post("@render:", "use_stretch_projection", { near = 3, far = 3 })
	msg.post("@render:", "use_fixed_projection", { near = -1, far = 1, zoom = 3 })
	-- msg.post("@render:", "use_fixed_fit_projection", { near = -10, far = 10 })
	self.near = -10
	self.far = 10
	self.projection_fn = fixed_fit_projection
	self.projection = vmath.matrix4()
	self.view = vmath.matrix4()
end

function update(self,dt)
	lumiere.update(dt)
	render.set_depth_mask(true)
	render.set_stencil_mask(0xff)
	render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0})
	render.set_viewport(0, 0, render.get_window_width(), render.get_window_height())
	render.set_view(self.view)
	render.set_depth_mask(false)
	render.disable_state(render.STATE_DEPTH_TEST)
	render.disable_state(render.STATE_STENCIL_TEST)
	render.enable_state(render.STATE_BLEND)
	render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)
	render.disable_state(render.STATE_CULL_FACE)
	render.set_projection(get_projection(self))
	render.draw(self.tile_pred)
	render.draw(self.particle_pred)
	render.draw_debug3d()
	-- render GUI
	render.set_view(vmath.matrix4())
	render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))
	render.enable_state(render.STATE_STENCIL_TEST)
	render.draw(self.gui_pred)
	render.draw(self.text_pred)
	render.disable_state(render.STATE_STENCIL_TEST)
	lumiere.draw(function()
		local frustum = self.projection * self.view
		render.draw(self.tile_pred, { frustum = frustum })
		render.draw(self.particle_pred, { frustum = frustum })
	end)
end

function on_message(self, message_id, message)
	lumiere.on_message(message_id, message, sender)
	if message_id == hash("clear_color") then
		self.clear_color = message.color
	elseif message_id == hash("set_view_projection") then
		self.view = message.view
		self.projection = message.projection
	elseif message_id == hash("use_camera_projection") then
		self.projection_fn = function() return self.projection or vmath.matrix4() end
	elseif message_id == hash("use_stretch_projection") then
		self.near = message.near or -1
		self.far = message.far or 1
		self.projection_fn = stretch_projection
	elseif message_id == hash("use_fixed_projection") then
		self.near = message.near or -1
		self.far = message.far or 1
		self.zoom = message.zoom or 1
		self.projection_fn = fixed_projection
	elseif message_id == hash("use_fixed_fit_projection") then
		self.near = message.near or -1
		self.far = message.far or 1
		self.projection_fn = fixed_fit_projection
	end
end

You’ve added the Lumiere code last, after you draw the GUI. The gui sets up a different state than when drawing your game world. Try moving the Lumiere code to before drawing the GUI.

1 Like

this happens (I put it before --render GUI)

Hard to tell what’s going on. If you zip up your project and share it here then I can take a look.

The other option is to compare it with the working example project and figure out what’s different.