Sitemap
Ben Golus
1 min readMay 21, 2021

--

I release most of my stuff under unlicense. https://unlicense.org/

Basically my code in the shader is public domain and can be used as you wish.

I am also using a function derived from Inigo Quiles’ example GLSL code. His works are under the MIT License.

OpenGL point light sources

Nothing needs to be done to the shader to support OpenGL point lights. The only thing omitted was support for point light shadows when limited to OpenGLES 2.0 (i.e.: very old mobile phones). Honestly, if you’re running on that class of device, you probably don’t want to be using point light shadows anyway because they are very expensive.

However if you really did want to support them you’d need to modify the frag_shadow() function by replacing the return 0; at the end with something like:

struct shadowCasterInput { float3 vec; }
shadowCasterInput casterDummy = (shadowCasterInput)0;

#if defined(SHADOWS_CUBE) && !defined(SHADOWS_CUBE_IN_DEPTH_TEX)
float4 wPos = mul(unity_ObjectToWorld, vertex);
casterDummy.vec =wPos - _LightPositionRange.xyz;
#endif

SHADOW_CASTER_FRAGMENT(casterDummy)

--

--

Ben Golus
Ben Golus

Written by Ben Golus

Tech Artist & Graphics Programmer lately focused on Unity VR game dev. https://ko-fi.com/bgolus

Responses (1)