Sample: falloff for spotlights in simplePBR

Archive.zip (3.7 KB)
assuming you’re already on simplePBR and have a spotlight… I’ve tweaked the shaders to do falloff as described at pbr-book.org

you don’t even need a custom build of simpleBPR. you can grab the shaders from the zip file or the pull-request, and then drop them into <your_project_dir>/shaders

        spot = light.node()
        lens = spot.get_lens()
        lens.set_fov(self.state.angle * 2) 
        # dirty. use the previously unused-by-pbr 'exponent' field to pass the PBR falloff angle to the shader
        spot.set_exponent(math.cos(math.radians(self.state.inner_angle)))
        spot.set_color(self.get_color())
        spot.set_specular_color(self.get_color())
        spot.set_attenuation((0,0,1))

works with or without shadows