Page 12 of 15

Re: Löve "Light vs. Shadow" Engine v2

Posted: Sat Feb 28, 2015 10:10 pm
by Relazy
drunken_thor wrote:
Relazy wrote:I am having trouble with rotation.. First of all if I have a "rectangle" type shadow, I get an error as "self.unit_data" is nil in body.lua 126. However when I swap the type to Image, the issue I described before shows up again. Heres a screen shot(Note: it's rotated by 180 degrees):
Do you have any code I can see? unit_data is set when you create a rectangle and should never change after that so if it is nil you might be doing something I did not predict.
Its a little difficult to pin down the point by which self.unit_data becomes nil but my closest guess would be body:setShadowType(). I'm getting some glitches when using it. Sry I can't post the code but it looks something like this:

Code: Select all

 sBody = lightworld:newImage(image)
 sBody:setShadowType("rectangle",x,y,image:getWidth(),image:getHeight())
However I am more concerned regarding the issue in the pic I posted.

Also regarding glow maps, is there a way I can control the consistency of the glow? It's gradual for me and I want to be able to specify weather that should be the case.

Apologies for the late reply.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Sun Mar 01, 2015 1:55 pm
by Magicked
drunken_thor wrote:This library works by blending the background with the lighting you need to draw a background of some sort (not just set the background color)
That was it! Thanks! Like said, noob mistake. :)

Re: Löve "Light vs. Shadow" Engine v2

Posted: Mon Mar 02, 2015 2:31 pm
by drunken_thor
Relazy wrote:
drunken_thor wrote:
Relazy wrote:I am having trouble with rotation.. First of all if I have a "rectangle" type shadow, I get an error as "self.unit_data" is nil in body.lua 126. However when I swap the type to Image, the issue I described before shows up again. Heres a screen shot(Note: it's rotated by 180 degrees):
Do you have any code I can see? unit_data is set when you create a rectangle and should never change after that so if it is nil you might be doing something I did not predict.
Its a little difficult to pin down the point by which self.unit_data becomes nil but my closest guess would be body:setShadowType(). I'm getting some glitches when using it. Sry I can't post the code but it looks something like this:

Code: Select all

 sBody = lightworld:newImage(image)
 sBody:setShadowType("rectangle",x,y,image:getWidth(),image:getHeight())
However I am more concerned regarding the issue in the pic I posted.

Also regarding glow maps, is there a way I can control the consistency of the glow? It's gradual for me and I want to be able to specify weather that should be the case.

Apologies for the late reply.

That is interesting, I think it is because you are setting the imagetype. Did you do that with the rectangle as well? because for that image example you really didnt need to do that because that is what gets done by default.

The problem probably lies in setting the shadow type so I will check there and get back to you.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Thu Mar 12, 2015 1:19 am
by drunken_thor
Relazy wrote:
drunken_thor wrote:
Relazy wrote:I am having trouble with rotation.. First of all if I have a "rectangle" type shadow, I get an error as "self.unit_data" is nil in body.lua 126. However when I swap the type to Image, the issue I described before shows up again. Heres a screen shot(Note: it's rotated by 180 degrees):
Do you have any code I can see? unit_data is set when you create a rectangle and should never change after that so if it is nil you might be doing something I did not predict.
Its a little difficult to pin down the point by which self.unit_data becomes nil but my closest guess would be body:setShadowType(). I'm getting some glitches when using it. Sry I can't post the code but it looks something like this:

Code: Select all

 sBody = lightworld:newImage(image)
 sBody:setShadowType("rectangle",x,y,image:getWidth(),image:getHeight())
However I am more concerned regarding the issue in the pic I posted.

Also regarding glow maps, is there a way I can control the consistency of the glow? It's gradual for me and I want to be able to specify weather that should be the case.

Apologies for the late reply.
Hey Relazy, sorry it took me so long to get to this I have been pretty busy lately. I believe I have fixed this issue now in the most recent commit. Please try it out.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Sun Mar 22, 2015 3:45 pm
by Relazy
My issue is fixed but..
I am having a few problems /w the new build. Glow maps appear to be broken or something else along the line, test the complex example and see for yourself.

thanks for your work so far I really appreciate it.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Sun Mar 22, 2015 10:13 pm
by drunken_thor
wow that is a big problem I do not know how I missed that. I guess I was kind of rushing the last fix. brb bashing head against a wall

Re: Löve "Light vs. Shadow" Engine v2

Posted: Mon Mar 23, 2015 2:01 pm
by drunken_thor
Relazy wrote:My issue is fixed but..
I am having a few problems /w the new build. Glow maps appear to be broken or something else along the line, test the complex example and see for yourself.

thanks for your work so far I really appreciate it.
Hey Relazy, I have fixed that problem now. Sorry about that I should have properly tested everything before making it available. For images that get their shadow type changed, it would overwrite the image data which is what you were seeing.

Let me know how it's going and hopefully if this build is working give me a screenshot of what you are working on. the best payback for this kind of work is seeing what people do with it.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Tue Mar 24, 2015 6:38 pm
by Relazy
Thanks for the quick reply, its fixed now. Although I have a question. Why do you support animations, but no quads? Wouldn't it be easier to allow the user to make quads and then introduce his own preferred animation plugin/own instead of forcing the use of anim8 for animations?
Besides quads can be used for other things too including image wrap.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Wed Mar 25, 2015 2:30 pm
by drunken_thor
Relazy wrote:Thanks for the quick reply, its fixed now. Although I have a question. Why do you support animations, but no quads? Wouldn't it be easier to allow the user to make quads and then introduce his own preferred animation plugin/own instead of forcing the use of anim8 for animations?
Besides quads can be used for other things too including image wrap.
Honestly because I just never thought of that, and currently do not really know how I would support that sort of general case at the moment. I used anim8 because when drawing I would need to calculate the normal/glowmap/material all at once for the draw call and right now I do not know how I could do that while keeping the API relatively simple and not prone to user error.

I would love to see a proposal if you have ideas.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Wed Mar 25, 2015 6:07 pm
by Relazy
drunken_thor wrote:I would need to calculate the normal/glowmap/material all at once for the draw call and right now I do not know how I could do that while keeping the API relatively simple and not prone to user error.

I would love to see a proposal
Huh? why would you need to calculate normal/glow/mat? When you use anim8 you are applying transformations to normal maps.
So for example you are writing this:
@light world segment from body class

Code: Select all

self.animation:draw(self.img, self.x, self.y, self.rotation, self.scalex, self.scaley, self.ix, self.iy)
@anim8;

Code: Select all

function Animation:draw(image, x, y, r, sx, sy, ox, oy, ...)
local frame = self.frames[self.position]
love.graphics.draw(image, frame, x, y, r, sx, sy, ox, oy, ...)
So what you are actually doing is this:

Code: Select all

love.graphics.draw(self.normal,frame, self.x, self.y, self.rotation, self.scalex, self.scaley, self.ix, self.iy)
And guess what the frame is, Its a quad.

and all of those :flipH and etc are simply uneccesary! All you could do is, body:setParentAnimation(animation) and then the user could specifiy the animation, from which on the update call will set the quad as animation.frames[frame]
so the animation movement would follow that of the parent. All that anim8 does is make quads and then it will apply transformations to them as-well as other stuff such as filpH and so on.

Besides, you apply shaders to the canvas meaning that anything in the canvas will be rendered using the GLSL therefore you won't have to do any calculations on draw calls but instead the GLSL will have more work to do in regards of the tiled images which ideally it should be able to cope with. You can simply use the work you have already done to implement the rest, you already get the width and height of the quad during the update, therefore a set quad function would look something like this

Code: Select all

function body:setQuad(quad)
    _,_,self.width, self.height = quad:getViewport()
    self.imgWidth, self.imgHeight = self.width, self.height
    self.normalWidth, self.normalHeight = self.width, self.height 
    self.ix, self.iy = self.imgWidth * 0.5,self.imgHeight * 0.5
    self.nx, self.ny = self.ix, self.iy
	self.quad = quad
end
However there is a more concerning issue at hand. What about shadows? That I cannot yet answer with my insufficient knowledge of how the plugin works, But I am rather interested if you can apply quads to a shadow mesh. I am not sure if I am correct but isn't a mesh an advanced form of a quad?

Please do inform me if any of this is wrong. Mind you I recently started graphical programming and things like GLSL is still quite mysterious for me, so if I am wrong then please do correct me. Thank you!
PS
You might also want to include assert statements so for example under :setQuad(quad) you'd do;

Code: Select all

:setQuad(quad)
assert(quad,"Please specify a quad")
if type ~= quad then
	error("Expected quad, got: "..quad)
end
This will avoid most of the user-based errors. The best thing you could do is add enough use ability so new functions could be added and so on.