Dynamic Shader - in the Marketplace now!

Hey Jeff, 

I’m glad you are putting the Dynamic Shader to use.  The DS works by using composite images (one of your art and the other the normal map) so when you stop the DS the composite image (in this case the shaded image) “freezes” where it is.  With the DS stopped, the image will not be updated to reflect changes in positioning, rotation or lighting, however it will keep the shading effect from the moment the DS was stopped.  

To return to a non-shaded object you have to remove the object from the DS via removeObject( )

[lua]

shader.removeObject( object ) – remove object to the Dynamic Shader

[/lua]

You then have to use addObject( ) to return the object to the DS after adding the object.shadeInfo again.

[lua]

-----add shaderInfo table to object------

object.shaderInfo = { – create the object.shaderInfo table

name = “object”, – optional parameter - gives the object a name or the shader will assign one

map1 = “art/object.png”, – reference the image file

map2 = “art/object_n.png” – refernece the normal map file

}


shader.addObject( object ) – add object to the Dynamic Shader

[/lua]

I’ve been thinking of adding an “object pause” or something like

[lua]

object.shaderInfo.pause = true

[/lua]

which would preserve the object.shaderInfo table but otherwise remove the object from the DS until object.shaderInfo.pause = false.

Would something like that be useful?

As for the slowdown in older devices, were you using physics objects?  I’m thinking physics objects or old OpenGL processors could account for the slowdown.  It could also be that there is a lot of number crunching going on every frame, I was just surprised to hear that a 5s had slowdown trouble.  Keep on playing with the plugin and let me know how it goes, thanks Jeff!

Jonathan

Yeah you’re right. I didn’t realize my own work around I wasn’t actually moving any of my gems. LOL. I have a shader object for every gem at every position on the board. It appears like it’s moving. I show or hide the gem. When it drops I show the sprite image when it stops I hide the sprite object and show the shader object.
Yeah, it’s not the physics engine that slows down the iPhone 5s. But stopping the DS I made the game as fast as on the iPhone 6plus. I just can’t move the light back and forth.

----- 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)

@toril.swift - Hi , there a question to accompany the code?

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