3-D effects with Normal Mapping

normal mapping in corona sdk
Share on Facebook0Share on Google+1Tweet about this on TwitterShare on LinkedIn0

Note: Graphics 2.0 is now in public beta for all Corona SDK Pro and Enterprise subscribers. Please see Walter’s recent blog piece on the news.


Just a quick preview of what’s coming in the next update of graphics 2.0 that we’ll be seeding out soon to alpha testers.

It’s a feature known as normal mapping and it’s a workhorse technique for simulating lighting effects in traditional 3-D graphics. We’re repurposing it so this is trivial to do in Corona.

For example, here’s how how you can achieve a point light effect:

local multitexture =
{
	type="composite",
	paint1={ type="image", filename="image.png" },
	paint2={ type="image", filename="normals.png" }
}

local object = display.newRect( 0, 0, 200, 200 )
object.fill = multitexture
object.fill.effect = "filter.normalMapWith1PointLight"

 

All effects have property knobs that you’ll be able to play with. In the point light, one of those knobs is the position of the point light. In the video below, we’re just moving the position in a circle:

Share on Facebook0Share on Google+1Tweet about this on TwitterShare on LinkedIn0
walter

This entry has 20 replies

  1. Greg says:

    That looks incredible!

  2. This is what I’m talking about!,,, will we be able to have multiple point lights!? Just checking in case of multiple magic missiles being fired. I might have to attack the darkness!

    :)
    -Mario

    • FearTec says:

      I doubt it being a bump map

  3. Pablo Isidro says:

    Awesome!!

  4. This is crazy! Can’t wait to get my hand on it!

  5. Devin says:

    I don’t want to sound like some sour grape but back in May you said about Graphics 2.0::

    “BTW, if you are hankering to get your hands on the new graphics engine, we will be seeding this out to beta testers very soon — possibly as soon as next month!”

    Where “next month” would have been June and the “new graphics engine” is denoted as Graphics 2.0.

    In this post you say “Just a quick preview of what’s coming in the next update of graphics 2.0 that we’ll be seeding out soon to alpha testers.”

    So where does Graphics 2.0 really stand? Is it already being tested with beta testers or not?

    • Walter says:

      We’ve already seeded out to select developers — see my earlier post: http://www.coronalabs.com/blog/2013/08/07/corona-update-graphics-2-0/

      And what I was referring to was that a new update to those developers will be available soon.

      In terms of a more open beta, I alluded to this in my earlier post, but specifically we’ve chosen to delay it so that we are free to change things like API’s.

      • louis roy says:

        Dear Walter,

        Do you know when Bluetooth control will be available for the Iphone and Android platform ( for machine control …like Robots..etc… bluetooth enabled )

        Thanks,

  6. Chase Morell says:

    Will Graphics 2.0 be available for the corona starter edition(aka free version)???

    • David says:

      Chase – some of the features will be available to Starters, but many only to Pros. The final list is still being figured out.

  7. Devin says:

    Thank you Walter for the clarification!

  8. Cleverson says:
  9. Owen Yang says:

    increditable!!!

  10. Jay Patel says:

    Awesome video, 3D graphics is the great technology. It is very useful for web design and game developers.

  11. Thomas says:

    While I appreciate the effort to keep things simple, at some point I feel like I should just have direct control, a bit like this:

    local lux = display.newPointLight(color, intensity, x-position, y-position, z-position)

    And then have a z-position property for image. I know I’m oversimplifying here, but there comes a point where you start to stifle too much power under the hood for me. Of course I’m the type of guy that uses the openAL hooks instead of the Corona sound engine…

    • Walter says:

      Actually, you will get a lot more than I showed, but since you asked.

      The first thing you get is sensible defaults chosen for you.

      On top of that, you’ll be able to control the the effect properties. For the point light, it would look something like:

      local effect = object.fill.effect
      effect.pointLightColor = { r, g, b, a }
      effect.pointLightPos = { x, y, z }
      effect.ambientLightIntensity = 0.3 — value from 0 to 1
      effect.attenuationFactors = { a, b, c }

  12. Paolo says:

    This will come in handy in my current project… Do you think I will be able to somehow emulate some shadow casting as well?

  13. David Wallin says:

    Looks awesome! Really looking forward to graphics 2.0

  14. Theo Rushin Jr says:

    WOW!! Bring it on!

  15. Gianmichele says:

    Wth Graphic 2.0 are we also going to get export to desktop systems?

Leave a reply

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>