Skip to content

A Construct 3 effect. Control colored point lights that interact with a 2D normal map texture. The result is a simulated 3D lighting effect.

License

Notifications You must be signed in to change notification settings

Everade/NormalMap32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NormalMap32 for Construct 3

normalmap32

This repository contains code for the NormalMap32 Construct effect. NormalMap32 allows to create and control up to 32 colored point lights that interact with a 2D normal map texture. The result is a simulated 3D lighting effect. There are two main components in this repository:

  • construct-addon: the Construct addon, written in GLSL/WGSL using the Construct Addon SDK
  • example-project: the Construct example project, demonstrating some of the effect capabilities

Distributing

The Construct plugin is distributed as a .c3addon file, which is essentially a renamed zip file with the addon files.

Warning

If you want to modify the plugin for your own purposes, it is strongly advised to change the Construct plugin ID. This will avoid serious compatibility problems which could result in your project becoming unopenable.

What is a Normal Map?

Normal mapping is a texture mapping technique used for faking the lighting of bumps and dents – an implementation of bump mapping. Each normal map pixel represents the direction in which the sprite's pixel is facing.

normals60degreescropped

NM32.mp4

How does it work?

You have to create OpenGL/WebGL compatible normal map sprites for each 2D sprite you want to apply the effect onto. This normal map sprite is used as a foreground effect that needs to be placed on top of the original 2D sprite background.

You can create Normal Map sprites either automatically using Normal Map Generator software, or draw them by hand. The NormalMap32 effect needs to be applied to each normal map sprite you've imported into Construct 3. Light sources are then defined within the parameters of each normal map sprite effect.

Please note that a light source object is not a requirement, but it's a convenient way to create dynamic lights within your game, as shown in the fully documented example project.

Performance Considerations

Applying the effect to lots of individual normal map sprites can be costly. Consider to either draw all normal sprites to a canvas or apply it to a layer instead. Set Max Light ID to the lowest possible value for enhanced shader performance.

Features

  • Supports WebGL1, WebGL2 and WebGPU.
  • Up to 32 simultaneous RGB light sources per normal map.
  • Linear, quadratic or mixed light falloff.
  • Distance clamping for spot light effects.
  • Supports flipped and rotated normal maps.
  • Global ambient light (RGB).

Credits

License

This code is published under the MIT license.