Ok I am at the point where I need to create a few billboards that get affect by light sources. I thought I could modify normals in one of those PLUGs so the billboard would always be illuminated when it goes near a light source, but I can’t seem to find any PLUG that allows me to do so. It would be nice if I can modify either normals, or the dot product of the normal & light direction.
The place to modify normal vectors is PLUG_fragment_eye_space
documented on A.2. Fragment shader plugs (so it’s a plug on a shape, not on the light source). You can change normal there, it’s inout vec3 normal_eye
in GLSL.
This plug is also used internally by the bump mapping (normalmap information modifies normal vectors using this plug), see castle-engine/src/scene/glsl/source/bump_mapping.fs at 8ce77b04e4420cfd4b9032aff43e7e883eaa8824 · castle-engine/castle-engine · GitHub . So it should be well tested
The issue is that this is not able to change the normals per light source, since I need the billboard to reach to multiple light sources near it (plus I don’t have any light direction in this PLUG, making the PLUG unusable in my use-case, even if it is just for 1 light source).
Edit: Although I would love for billboard to get lit even if the light source behind it, PLUG_fragment_eye_space is enough for me for now
Hm, indeed, it is not possible right now to change the normal vector for each light source differently. In calculate_lighting
in GLSL the normal is assumed to be constant. Some other plugs also expose “current normal value” to do fancy stuff (e.g. possibly “distort” the shape along the normal) so we kind of assume that “we have 1 proper normal vector value”. This should follow reality, I mean the surface you have has 1 normal which doesn’t depend on the light source.
I understand the current solution is good enough for now – let me know if you need more, and also what is the goal you want. Maybe it can be achieved by other way. Maybe you want a custom lighting model, to provide your own light calculation function (kind of like PLUG_add_light
is used now internally). I could think of various tweaks, but it will be best if I understand what is the “end goal”