Dynamic Shader - in the Marketplace now!

Hey Everyone,

I’m excited to announce my first plugin.

The Dynamic Shader plugin can be used in your Corona project to create 3D shading for your 2D artwork. This shading occurs dynamically in real time, updating every frame, allowing for vivid expressions of mood and atmosphere. The best thing about the Dynamic Shader is its ease of use. It only takes 4 steps and a few lines of code to add dynamic lighting to your app!

Video Demo

Quickstart Guide

Corona Marketplace

Very nice!

Was playing with those functions in Corona myself but never got it working to my satisfaction so am likely to grab your plugin pretty soon!

Anaqim

Creator of Radiance

https://marketplace.coronalabs.com/asset/radiance-particles-effects-creator

Thanks Anaqim,

I was developing the shader effect for one of my apps and could never get it to work 100%.  Two things coalesced into the final version.  First, Corona announce the plugin competition (great motivation), second I had a trigonometry epiphany around the same time and powered through the previous problems to finally complete the module - yay!

I was eyeing your plugin as well.  Is there a mac version in the works?  I’m currently a double mac developer and have been PC-less for 4 years now, however,  I need to get a PC soon to develop for Windows.

Thanks for the high five!

Jonathan

Hi Jonathan,

I’ve tagged your plugin for purchase once I get time to work on an actual game in corona. It looks great and i don’t envy you the higher mathematics. I can barely manage math.atan() at the moment so need to brush up on those skills at some point.

At the moment Radiance does take all my spare time, and in fact I just released v1.2 this evening.

Never thought about mac but starting to get the impression that there are more mac developers than PC using Corona SDK so I will look into it. Since Radiance is coded 100% in Corona SDK I would presume all should be easy to make mac builds.

I will look into it, and see if I can find a mac somewhere.

Have a great one!

Anaqim

Hi again,

Just want to let you know that the mac version is out.

Cheers!

Anaqim

Hi Jonathan,

The effect in the demo video looks really good :slight_smile: Quick question - does the plugin support multiple lighting sources?

Hi Sean,

Not yet, I have a working prototype of a multi-light shader but I decided to focus on one light for now.  Currently I’m experimenting with light beams and flickering light.

I don’t have plans to make major updates to the Dynamic Shader in the near future.  That could change if I end up with a large active user base but since the plugin is only one week old today, time will tell ; )

I purchased your Plugin and spriteilluminator. The demo projects works just fine. But the shader objects in my project are always black. I messed around half a day trying to get it to work in my project. Any ideas what could cause this?

Hi Burns,

The most common reason for pure black (unlit objects) is forgetting to start the shader (the last step).

dynamic_shader.start()

Could that be the issue?  Let me know.

-Jonathan

I got it to work but the problem is I’m using sprites for all my objects on my match 3 game.

 I have limited experience with sprites since I usually use physics objects but in theory sprites should work just fine.  In fact, I’ve seen examples of sprite sheets turned into normal maps with Sprite Illuminator on YouTube but I’m unsure, procedurally speaking, of how exactly to implement them into the dynamic shader on Corona.  I’ll definitely investigate this and get back to you.  Meanwhile, can you send me a sample of the code you are using to call and animate the sprites and how you are adding them to the Dynamic Shader?

Thanks,

Jonathan

I didn’t even try to use it on Sprites. I did a workaround so that it works on my game. Check it out:

https://www.dropbox.com/s/jxir0aia6zt5fj1/Screenshot%202017-02-04%2009.32.41.png?dl=0

Nice!  That’s the first time I’ve seen the shader used in someone else’s project.  Thanks for sharing, I’m glad to see the shader in use!

My objects were black because of the light radius. So I thought it wasn’t working. And I get an error if you don’t pass a table to .setLightColor.

http://dynamicshader.com/code.html

I would change your basic code to this:

----- Add a light source  to the Dynamic Shader  ----- local light = display.newCircle( 350, 200, 50 )light:setFillColor( 1, 1, 1 )local table = {1, 1, 1}dynamic\_shader.setLightColor( table )dynamic\_shader.addLight(light)dynamic\_shader.setLightRadius(1500)

Anyway, just a thought. Wonderful product. I love it. Keep up the good work :slight_smile:

Thanks!  That is an error in my coding.  I would prefer for users to not have to pass a table (easier for novice users) so I will fix that in the next update.  The light is set to 1, 1, 1 by default so I never notices this error.

Happy shading!

@burnsj002

I was just checking my api’s and noticed that it was originally a table value for setLightColor( ) so I’m going to keep it a table value and fix the sample code on the site.  Sorry for the confusion and thanks again!

Hi,

I just tried it out using a SpriteIlluminator example. Works good, see below.  I did this on a Macbook Pro, but during plugin install it had the “spinner” animating like it was still busy. I let it sit there a bit and then ‘quit’ Corona simulator and re-started and all is working fine.

I used the suggestion above from burnsj002 and it worked great!

Example:

shader-fun.gif

Great!  Thanks Paul.  I’m also still investigating sprite sheets but the composite effects fill for Corona asks specifically for image files.  There might be a way around this. . .  I’ll keep you posted.

Image sheets:

Short answer:  Unfortunately, I don’t plan on supporting image sheets for the Dynamic Shader in the near future.

Long answer:  The graphics 2.0 composite.fill.effect parameters require a “type” (like “image”) and a location of the image files.  Since image sheets are one big file, I have to break up the sprites and normal maps on those sheets and re-save them as graphics files in the Document Directory before loading them into the shader which defeats the whole purpose of image sheets.  I’m experimenting with canvases but it looks like they will also bloat the Document Directory if I have to save then and then create a path.

I’ll keep experimenting but I’m moving this challenge to the back burner.

Thanks everyone!

Jonathan

No problem. I got the Dynamic Shader to work in my project just fine.

I noticed that on 1st Gen Apple products or older devices like the iPhone 5S that the Dynamic Shader dramatically slows down the game. Almost making it unplayable with a moving light source. But I did some experimenting… I made the light source not move .I stop the Shader right after the match 3 board is visible.

The Shader still SHADES the gem pieces even while the Dynamic Shader is stopped!

Some levels I have the light source turn off and on to make the game harder. So I noticed you have to turn the Shader ON when you move the light source then I instantly turn it OFF. This is part of the code:

Match3.ShaderLightSource.x = math.random(0, device)

dynamic_shader.start()
dynamic_shader.setLightRadius( math.random(2500, 3500) )

timer.performWithDelay( 1, function() dynamic_shader.stop() end)

But the stop has to happen a millisecond later. So now the game works super fast on the 1st gen apple devices and older iPhone 5S devices.

Does this sound right to you Jonathan? Does the Shader still Shade the objects when it is stopped as long as the light source doesn’t move or the radius of the light doesn’t change? Do you only have to turn the shader ON when you move the light or change the light radius?

Thanks for a wonderful plugin :slight_smile:

Jeff