Add support for updating surface normals from procedural shaders


Right now surface normals are provided as read-only input values to shaders – but if they were also output values then new kinds of virtual materials could be improvised and configured inworld for primitives.

As a simple example, here is a bump mapping effect applied to ordinary Sphere entities in that way (for now using a workaround approach to output the updated normals):


Cool idea. I can think of some things that might work well with something like that although I suspect your workaround is now essentially a post process thing and worries again that people will make shaders that gobble up GPU resources.


Well for prototyping I just used a #define to splice-in my own main(). Basically, replicating the original and then adapting it slightly to get my updated normal values into the fragment output slots (which were already being used and so already GPU costs).

That’s not a bad worry to have. So far using primitive shapes + virtual materials seem pretty reasonable.

The Spheres above use a bump map texture as a basis for the normals and other material properties are just floating point uniform values (stored in Entity userData). To me this is an ideal setup for experimenting with materials inworld because a large variety of perceptive qualities can be emerged using a few simple controls like sliders and real-time feedback.