Jump to content

Light2D, rotating normal map issue


Recommended Posts

Hi,

I think I've found an issue with the normal map spot light. Either that or I've done something daft in my code.

I believe the spot light system correctly selects which pixels to illuminate, but it doesn't consider the sprite's rotation, only the pixel normal value, when calculating per pixel lightness. This only becomes apparent when a sprite is rotated, and it is difficult to demonstrate when using very flat normal maps, like in this spot light demo http://labs.phaser.io/view.html?src=src\game objects\lights\spotlight.js

You can see my below code snippet running here https://madcarrot.itch.io/phaser3-demo?secret=70SZ1Whbm3Wsf9onEXXdRM2deQ

If you position the spot light (attached to pointer) behind the insect to highlight the abdomen, when the insect is facing downward, the light angle is correct, when the insect is facing upward, the light angle is 180 degs off.

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    scene: {
        preload: preload,
        create: create,
        update: update
    }
};

var game = new Phaser.Game(config);

var insect;

function preload () {

    this.load.image('insect', [
        'assets/images/bug-99x103.png',
        'assets/images/bug-nm-99x103.png'
    ]);
}

function create () {
    
    this.lights.enable().setAmbientColor(0x333333);
    
    insect = this.add.image(400, 300, 'insect').setOrigin(0.5).setScale(3);
    insect.setPipeline('Light2D');
    
    var light = this.lights.addLight(180, 80, 200).setColor(0xffffff).setIntensity(2);
    
    this.input.on('pointermove', function (pointer) {
        light.x = pointer.x;
        light.y = pointer.y;
    });
}

function update() {
    
    insect.angle += 0.5;
}

Can anyone see if I've done anything daft here? Or whether this is worth raising as a bug?

Thanks in advance

 

bug-99x103.png

bug-nm-99x103.png

Link to post
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...