Experimental world space per face lights, with baking
This is a very experimental feature, I am releasing it to get feedback and see if it will have a mode that is useful or there is a reasonable use case in a production game.
For now, I suggest _not_ using this addon in a game on the way to production. I have left the last version of the addon also available.
This is a simple lighting model, it changes the light on each face (triangle) of the model it is applied to. It is integrated into 3DObject, it is not an effect that impact other objects beside 3DObject. I am hoping to one day have a better lighting model implemented with an effect that would work on the per pixel level, but I think it will take some changes in the C3 effect stack to do that work.
Since it is based on per face lighting, objects like simple cubes or planes will have their full surface lit up. In the example there is a rotating cube which has smoother lighting, but the model itself has been subdivided, so each face is made of _many_ triangles, not just two. While this looks better for the spotlight lighting, it takes a lot more performance than a simple cube.
The main ACEs are Add Light, Enable Lights, Update Light.
Add Light, adds a named light w/ a tag, it can also be used to update the parameters of a light, by adding the light again with the same name. The light has a position and color, there is also an option to set a spot light with a certain direction and cone angle. The cone angle setting is based on a cosine calculation, see the example project for a reference. In a future release, I'll probably change it to an angle and percent for edge.
Enable Lights turns on the display of lights (the last calculated light per face).
Update Light dynamically updates the objects lighting calculations.
Baking lights
When turned update light is turned off, the last Light calculation is saved, this can be used for 'baking' lights on the start of a level or at the start of a game.
In webGPU mode, displaying the last light calculation has low performance impact, so baking a large number of lights on 3DObjects (e.g. environment) will have a small effect.
For webGPU usage, it requires r338+ and Chrome Canary, enabling webGPU in chrome canary and enabling webgpu in C3.
Dynamic lights take significant CPU to calculate, so they can only be used in a limited amount
It works best when webGPU is enabled, in webgl it takes significant performance to display the lights.
There are two expressions, LightColor(<color name>) and LightsData, a JSON string with all the current lights defined.
Future work
- Change spot light ACE to use angle and percentage
- More expressions
- Distance attenuation
- Enable light calculations in worker mode (this will distribute CPU requirements for the light calculations to other CPU threads if available.)
Please leave feedback, on how you may use it. This is kind of back to the future, feature, in the very early 3D days per face lighting was done, but now.
Also, thanks to a contract from PixelMetal, we now have ACEs for Material UV offset and Material UV rotate (they can be useful for doing things like simulating environment mapping on a car windshield or spaceship canopy.)
Files
Get Construct 3 3DObject Plugin
Construct 3 3DObject Plugin
Construct 3 3DObject, loaded from 3D model files (gltf embedded format)
Status | Released |
Category | Assets |
Author | kindeyegames |
Tags | 3D, construct, construct-3 |
More posts
- fix (addon) fix corrupted addon16 days ago
- fix (accessors) add support for sparse accessors in gltf17 days ago
- Fix (node-disable) fix node disable without skinned node37 days ago
- fix (node-disable) regression43 days ago
- Fix (playable Ad)55 days ago
- fix (worker) correct animation blend for worker (translation)72 days ago
- fix (opacity)78 days ago
- add (sample) sample gpu-skin with phong light91 days ago
- fix (gpu-skinning) fix regression for worker mode91 days ago
- fix (light) fix for simple phong orientation92 days ago
Comments
Log in with itch.io to leave a comment.
Warm and warmer, 3D lights become slowly possible:) its any chance to work with Scirras 3D Shapes? i cant wait to use in my game remake :>
Just for future folks looking at this question - yes, there is an experimental one available.