Bezier Path Lighting

Started by
13 comments, last by KRIGSSVIN 14 years, 5 months ago
Hi everyone, This is my first post on gamedev.net ([smile]), but I'd love to get some feedback on my new project I've just released on codeplex (http://xnapathlight.codeplex.com/). I call it "Bezier Path Lighting". Traditional point and spot lights have no length, and there seems to be no implementation of lights with "length", like fluorescent tubes or neon lights, which puzzled me a little. So, with a little help from a friend, I've developed Path Lights. The path of the light is defined by a bezier curve (linear or quadratic), then for each pixel, the closest point on the curve is found. The pixel is then lit from this closest point as a standard Phong point light. This creates a swept light effect which illuminates the scene. The codeplex project currently has only linear path lights, but I will add quadratic lights soon. I've written the demo application in C# for XNA, but the shader can be applied to many graphics libraries. Feel free to experiment with the source code, as long as you link back to the project site if you use it in an application. Thanks in advance. un4filled
Advertisement
Awesome. I'm interested in how it would look on more-complex geometry than a flat floor. Does it look right? The closest-point technique seems like it'd look weird, but on the floor at least, it looks nice.
Pretty rad

it would be neat to see a screenshot from a wilder looking curve (:
Hello CDProp,

The diffuse component of the light looks fine in any configuration, its the specular which might look a little odd.
There is a noticable line where the t value is clamped to prevent it leaving the ends of the line.

I was rather hoping to see the lights in a more complex scene made by others (I'm no artist [smile]).

If you haven't already, download the demo app and have a look. You'll need XNA GS 3.1 to run it.

Thanks for you interest.
I've seen that the lights in the unreal engine can be clipped by planes in at least 3 axes. You could squeeze the light down and obtain this effect.

Does your path support more than a single line segment or does that require multiple lights?

I'm also a bit skeptical that finding a point on the line (even the linear case) is comparable in speed to a single point, much worse when you add quadratic.

It still is pretty neat though.
Quote:Original post by bzroom
I'm also a bit skeptical that finding a point on the line (even the linear case) is comparable in speed to a single point, much worse when you add quadratic.


Looking at his shader there's definitely quite a bit of additional math for finding the L vector compared to a point light. But there's probably room for some optimization.

Currently the shader only supports single line segments, so merging lines to make a constant line shape will need multiple path lights and some fancy blending.

As for the performance, there are only a few more instructions per pixel to calculate the light position, so its only a little slower than a standard "fixed" point light.
There is a performance hit when you go to quadratic curves, but its still managable. The main problem with the quadratic curves (and the reason I've not posted its code yet) is the specular light has a noticable seam due to the nature of solving the value of t for the closest point.
That´s pretty neat.

I´m trying to implement rectangular area lights also, so that the lights family gets completed :P.

keep up the good work!!
Quote:Original post by un4filled
There is a performance hit when you go to quadratic curves, but its still managable. The main problem with the quadratic curves (and the reason I've not posted its code yet) is the specular light has a noticable seam due to the nature of solving the value of t for the closest point.


Do you have any numbers? Might be a good idea to check how many additional instructions are needed in different shader profiles. You can also take it a step further and measure the cycles required using NVShaderPerf and RenderMonkey. But before that definitely see if you can use a little algebra to simply, or if you can move anything into the vertex shader.

Using pixel and vertex shader 3, the current version of the shader uses 42 instructions in the pixel shader.

The lines of code which calculate t can be moved to the vertex shader, with no visual differences. This saves 6 instructions from the pixel shader.
I would imagine the same cannot be done with a curved light, since the value of t given to each pixel will not be interpolated correctly.

This topic is closed to new replies.

Advertisement