"Line light" is there such a thing?
category: general [glöplog]
I want to implement a light that comes from a line like emitter instead of a point. I could try to figure out some math but it would probably be too slow or something. Any ideas / articles?
just use distance?
either distance or angle, depending on whether you want absorption or not
But... but...
the whole point of line/area/volume lights is to get soft shadows!!
the whole point of line/area/volume lights is to get soft shadows!!
draw a white line on black background
apply hypnoglow+zoomblur
et voila
apply hypnoglow+zoomblur
et voila
Sounds like a special case of area lights..
glue some glowsticks on your screen
rudi that can be done via my pseudo code :)
this is how it is done in size antimatters:
in the fr shaders of all materials in the scene there is a pass that adds a function of the distance of the position of the texel - in w. coordinates - to the line eq. It is trivial to work out if your line falls across, say, the x coords. the function is of type sinc, or gaussian or something like that to give it a smoothness. blur + hypnoglow.
in the fr shaders of all materials in the scene there is a pass that adds a function of the distance of the position of the texel - in w. coordinates - to the line eq. It is trivial to work out if your line falls across, say, the x coords. the function is of type sinc, or gaussian or something like that to give it a smoothness. blur + hypnoglow.
rasmus: true. you need directional blur though :p
it all depends on how you implement your zoom blur.
ryg: no it isn't. unless you want every light to look like
light light, not the ever present illumination.
The light coming from this (not the best example) is not circular / radial...
Anyway I came up with some math / drawings. I'll try to implement it and see how it looks. Step 2 is ripping size antimatters.
light light, not the ever present illumination.
The light coming from this (not the best example) is not circular / radial...
Anyway I came up with some math / drawings. I'll try to implement it and see how it looks. Step 2 is ripping size antimatters.
I see google returns plenty of stuff for "Linear Lights" + rendering
of course you can see a linear light as many consecutive point lights.
Then if you just a kind of inverse square light intensity measure, go with point-line distance like this or this and do something like 1/d^2 or similar (or was that 1/d for linear sources...?)...
of course you can see a linear light as many consecutive point lights.
Then if you just a kind of inverse square light intensity measure, go with point-line distance like this or this and do something like 1/d^2 or similar (or was that 1/d for linear sources...?)...
xernobyl: you could pre-calculate the radiance into a 3d-texture.
just put your god damn line on the x axis and do a:
gl_Color+=100.0*pow (clamp (cos(pos.y*0.1),0.0,1.0),10.0);
gl_Color+=100.0*pow (clamp (cos(pos.y*0.1),0.0,1.0),10.0);
(the line is wrong but yo uget the idea)
sure, check "irradiance volumes"
You can find info about "irradiance slices" here :)
You can find info about "irradiance slices" here :)
light travels at the same speed whether its focused as a point or a line, mate!
dist to line eq.
apply falloff et cetera as you wish
apply falloff et cetera as you wish
If you just want a line-shaped regular light, the math is super-simple:
Line between line_start, line_end.
Setup:
In the shader:
And then determine dir to light, attenuation etc. from there as if it was a point light.
But my point still stands, with a line light you want the appropriate soft shadows too :). This is nicest in Monte Carlo raytracing. You just sample along the light source randomly, the rest happens automatically. Or of course you can just "sample" the line light by replacing it with a number of point lights (on the line, either uniformly sampled - which will usually be visible - or stochastically, usually following some kind of Poisson distribution).
Line between line_start, line_end.
Setup:
Code:
float3 line_vec = line_end - line_start;
float3 line_axis = line_vec * (1.0 / dot(line_vec, line_vec));
In the shader:
Code:
float proj_on_line = saturate(dot(here - line_start, line_axis));
float3 closest_pt_on_line = line_start + line_vec * proj_on_line;
And then determine dir to light, attenuation etc. from there as if it was a point light.
But my point still stands, with a line light you want the appropriate soft shadows too :). This is nicest in Monte Carlo raytracing. You just sample along the light source randomly, the rest happens automatically. Or of course you can just "sample" the line light by replacing it with a number of point lights (on the line, either uniformly sampled - which will usually be visible - or stochastically, usually following some kind of Poisson distribution).
Actually, you could use some neat matrix stuff and do what raymarching and bumpmapping shaders do. Just translate your lighting coord into light space and do what Navis said. In that space, the light could just be on the x-axis.
line lights are very common in movies. for the implementation, what ryg just wrote.