Dynamic lighting camera system

The fragment error is solved and it works well now on my iphone (although with no movement possible but it does non matter, the shading is great!)
I’m really impressed!

Engine has been fit into the editor, many adjustments and improvements were made to the camera library in the process. I still have to handle system events like suspend (texture memory handling), do some real device testing and some benchmarking as well.

Anyway, here’s a screenshot of the editor using the most recent dynacam library:

Next task will be to add the engine to one of the games i’m making, to do real device Android & iOS testing.

EDIT: Engine working in-game. Super easy to convert. I will test builds another day. I’ll be busy all next week doing other stuff so updates might be a bit scarce, but i do estimate that it will be done soon. About the marketplace plugin I will have to talk to someone at Corona first as it uses an undocumented feature.

New update, Everything works. Emitters can be placed on a default object view and they look great. Have been testing on an iPhone X and it performs smooth;

Except for the crash that sends everything to hell on IOS. Randomly, sometimes not so randomly, always without stack trace. Just crashes directly to the app screen. After some time of research, logging, tons of debugging and a lot of builds, I’ve managed to identify the cause of the crash and will implement and test a definitive fix next week. 

For anyone interested on how the engine works and how it is being developed, it basically wraps all display object creation APIs to create two display objects instead of one, and finally rendered together in a canvas merging 3 frame buffers (Diffuse, Normal and Light). So basically the whole scene is constructed two times behind the scenes: All diffuse and normal objects are “entangled” or paired with each other. This means that all transformation changes made in the diffuse object are replicated to the normal object, and this is true also for function calls, like sprite:setSequence() will set the sequence for both objects. 

Touch, tap, and mouse listener objects have a third entangled/clone dynamic object hierarchy that lives in front of the canvas that forward these events, as objects being drawn in a canvas texture loose their ability to receive tap, touch and mouse events by normal means. 

Fill and effect proxy tables forward respective changes to both worlds as well. Normal objects always have a default effect that fixes normal vector map individually based on local camera rotation, (Which essentially is like a “content rotation”) and setting a new effect to an object will stack the rotation fix shader on the normal version of the object, essentially having two effects in the normal object.

Ambient occlusion is pre baked in the editor, as realtime AO was developed and tested but there were significant frame drops, probably can be optimized more, but will leave the realtime part of it disabled for now. Ambient occlusion adds more depth to the world:

In editor:

In game (Ambient light was adjusted):

As you can read, the engine contains a lot of moving parts which i need to carefully review so that i can deliver a bug-free release. Can’t wait to release it for others to try it out!

Slick!

Beautiful, sign me up for beta testing!

Hey, what are you using as a level editor?

Great work.

What approach did you settle on for watching and propagating state changes?

I’ve been pondering some kind of function, maybe a clone() method for non-group display objects, that would make a new object with all its current Corona-side state replicated. The use cases I had in mind were motion-blur images, mirrors and other reflections, maybe shadows. Of course one can make multiple objects at creation time, but taking an existing object and incorporating it into an effect on demand is another matter. I think I know some of what needs changing in the source but it would touch a lot of objects, so haven’t been brave enough to attempt it yet.  :slight_smile:

Vlad mentioned a while ago, on Slack I believe, that uniforms are pretty much set at this point, so should be fine to use.

@sporkfin, Sure! I developed the editor myself! The project started out years ago and was used for other games, but i decided to polish it until it was more comfortable to work with. Made with Corona too!

@StarCrunch for transforms, some sort of monitoring: intercept x, y, etc. property changes on a new metatable, update the clone object values, and then pass it to the default metatable, effectively updating itself and its clone part. For physics bodies, the only way was to add them to the camera for manual update in an enterFrame, as the physics engine skips the metatable completely. 

This can also be done with functions, so you can intercept insert and removeSelf for example, and return a new insert/removeSelf function that inside calls the default one, like extending the default function implementation with some sort of function inheritance. This can be done without metatables even (Just saving a reference to default insert, and replace .insert) then use the inserted object’s .path property to recreate a new untextured object, for example. Just try it and see what happens! Git is your friend hehe.

Regarding the uniforms, that’s awesome! 

New progress, and some cool features!

Fixed the iOS crash problem faster than anticipated!

Optimized light drawing, added light culling, which greatly improves performance on heavy levels, next improvement to try is some sort of pooling, but will leave it as it is as performance is good, still have to test on low end devices.

Was getting an error 256 trying to build for android but fixed it today as well. All i had to do was remove the corona and corona simulator directories in the ~/Library/ folder. So next week there will be android testing.

Since touch listener objects now have a forwarder object, this object can be manipulated directly, for example to create a bigger touch area than the object itself, without resorting to bigger alpha or tricks:

The alpha circle area is the touch area, debug is set to true, so we can view it. This effectively forwards all events from the larger circle to the smaller one. This is all i had to do achieve the above result (touch related result):

playerMarble:addEventListener("touch", touchMarble) display.newCircle(playerMarble.touchArea, 0, 0, MARBLE\_TOUCH\_RADIUS)

Where playerMarble is the smaller circle, the .touchArea group is added automatically after adding the event listener, by the light engine.

Wow!

Tiny update, i’ve been busy with other stuff, but decided to do a small update to the plugin. Added more error handling and testing to make sure nothing breaks, and something extra that can be done with the plugin:

Split screen capability

Right now framerate is divided between cameras which means that in the video each camera gets 30 frames per second. This is by design as Corona only lets me get so far while trading performance for some features. uncapped/higher FPS possible in the future? As a note, camera canvases can have any shape:

Diagonal split screen

More Android testing needs to be done in regards to texture handling.

Looks great!

Hi guys, long time no see. Happy new year and all that. Got distracted with real life for a bit of time, but it is now time for the newest update: The plugin has been submitted to the marketplace. There are still things to iron out, but if i don’t release it now i never will!

Great!  Shoots us a link when it gets approval.

Hi everyone, it has been a while. I already had everything up and running to distribute this as a plugin a while ago, but i’ve changed my mind. I will be releasing this as open source , but i only need one piece of advice, what license should i use? I want to keep it simple, so my guess is to use the MIT license. Anything else i might be missing?

Yeah, that’s what I would use.

Thanks!  That is very generous of you to share.  Did you finish your project?

MIT is the safest for you, as it frees you from all responsibilities, and it is one of the most common software licenses so potential users will likely know what it is they are agreeing to without having to read the license and understand some weird legalese.

What made you decide to change to open source?

@sporkfin The level editor and the game, not yet. I had to pause them to focus on other stuff. These i work on my “free time” even though its more of a “now and then” thing.

@XeduR This way i can sort of add features based on what you guys need, and you can also see how it works under the hood. I also want to share some other libraries and ways of organizing projects so i’ll be sharing that too, soon. 

As to what made me change my mind, well… i’ve been sitting on this project for a while now, you might as well start using it even if i’m not. Make it for all of us and not just me  :D will add the MIT license and release the repo links tomorrow 

Alright, here are the links, which should be pretty self-explanatory

https://github.com/Zetosoft/dynacam-demo

https://github.com/Zetosoft/dynacam

Please note that this structure uses my way of using dependencies with a command line tool, which was not intended for LUA or Corona in any way. The project also showcases my other library

https://github.com/cetobasilius/index

Which is like a require shortener, useful for tons of dependencies on a single folder and cross library referencing, using pure LUA, i’m sure it will come in handy.

Please read the instructions carefully, if anything comes up i’ll be around, send me a message or post here? Anyway, test it out and tell me what you think of it. Enjoy, and happy coding!  :slight_smile:

I’m using Corona Version 2019.3542 (2019.10.24) so it must work with that and up

1 Like

Wow, I feel like I just found the buried treasure!  Thanks for sharing, like I said before, that is quite generous!