Jump to content
  • Advertisement
Sign in to follow this  
un4filled

Bezier Path Lighting

This topic is 3161 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!