Messing with spotlight shaders

· by Steve · Read in about 2 min · (272 Words)

Free Image Hosting at www.ImageShack.usI kept meaning to spend some time doing more testing of the new texture shadow rendering techniques I added a week or so back, so took a little time yesterday and this morning to do that. But. as part of it I started implementing a more generic lighting shader so I could integrate a number of techniques. Our example shaders for normal and offset mapping deal with point and directional lights, but not spotlights, so I decided to add that in as well as dealing with several lights & their shadows in a single pass. What should have been quite simple ended up taking far too long because I changed the auto bindings a bit to make generalised spotlight shaders easier to write, and also found a bug in a couple of the auto parameter bindings (light_direction_object_space and light_direction_view_space - not normally used since point and directional lights can both be handled through the 4D light_position_object_space). The spot parameters I exposed as cos(angle/2) since that’s more useful for the shader’s spotlight calculation (dot(lightPosDir,spotDirection) - cos(outer/2)) / (cos(inner/2) - cos(inner/2)).

Early results are shown in the shot with 2 spotlights done in one pass with offset mapping. I’m not happy with it yet since the shadows are not correct - they’re the old modulative style since the 1-pass additive shadows aren’t quite working yet. Once I have them working I’ll be able to take account of the offset mapping in the shadow too. Anyway, it’s a start. But I’m out of time for now, I have to get back to contract work so will come back to this subject later in the week.