Jump to content

Light and Normal Maps


Taleforge
 Share

Recommended Posts

Hi,

 

this (https://gamedevelopment.tutsplus.com/articles/how-to-learn-the-phaser-html5-game-engine--gamedev-13643) article says "The latest release of Phaser introduced WebGL shader and filter support, and forthcoming ones will implement normal maps so you can benefit from new tools like Sprite Lamp.".

 

I am interested in this normal maps. :)

1. Is there any example for normal maps working with phaser? 

2. Where is the support on the current roadmap?

Link to comment
Share on other sites

This has been experimented with in Pixi.js, and as soon as it hits stable in there we will support it in Phaser (as we rely on them adopting it first really). As SpriteLamp isn't yet finished I'm guessing this isn't a high priority for them just yet (plus they've loads of other work to be getting on with!)

Link to comment
Share on other sites

  • 1 year later...

That's awesome that it will be fully supported and documented in Phaser 3!

 

I found this also, playing around with it and seeing what I can do with it ATM:

 

http://www.html5gamedevs.com/topic/15638-im-having-a-hell-of-a-time-trying-to-get-normalmapfilter-to-work/?hl=normal#entry88695

 

PS: Anyone that can help chime in on how to port this into Phaser, let me know! 

 

EDIT - 

Looks like this needs PIXI 3.0.7 but Phaser 2.4 is using PIXI 2.2.8 :'( 

Link to comment
Share on other sites

A possible way to do this in Phaser (I've implemented parts of this successfully, but it's a different look than what I'm after so I didn't completely port it. should work though!):

 

- set up 3 fullscreen renderTextures for your diffuse, normals, and lights.

- keep your scenery/actors in one group and the lights in another. lights in this implementation are just sprites.

- in state.preRender, render the appropriate groups to each of the RTs in turn (diffuse/normal -> scenery group, lights -> light group), setting a flag for which pass it is you're currently doing. 

- extend sprites so that they know what pass it is and modify their behaviour to switch out their regular texture for the normal texture when that pass is being done.

- last thing in state.preRender, set your scenery and lights groups to be invisible (i use alpha = 0 but there are other ways) so that they don't get rendered again. all the info you need to display your game are in the renderTextures. 

- in state.render (which is called after the framework's renderer is done), turn them back on for the next frame

- you need to write a normal shader that applies the normals calculations, using your three RTs. This is the part i didn't bother with ;) You can basically crib the calculations from pixi-lights, I think, or there are tutorials on the web otherwise. You need to pass the three RTs to the shader as uniforms (or perhaps it's possible to work on the diffuse directly and only pass the other two). 

 

Here's a sample of what my slightly different technique does:

 

TSDnvRV.gif

 

Good luck!

Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...