Jump to content
The Dark Mod Forums
Sign in to follow this  
Farsead

Spherical lights

Recommended Posts

Is there any way to make light sources more natural, in the manner that they cast a sphere of light?

 

In some situations, a cube-shaped light seems strange.

Share this post


Link to post
Share on other sites

Note that the standard light entity is not a cube - it is displayed that way in the editor but its light is cast like a chunky 6-pointed star with pyramids pointing outwards to the centres of the sides of the cube. This is a compromise for performance and roughly simulates how a sphere of light is cast. Try creating a light in the middle of a room and somewhat bigger than the room. It's light is brightest in the centre of the walls, floor and ceiling and darkest in the corners - just like a sphere would be. And its faster than calculating a sphere of light.

Share this post


Link to post
Share on other sites

The light volume of a point light IS a cube. It projects a texture in all 6 directions and the intensity changes with the distance from the origin (falloff). It's spherical because of this falloff (the texture also affects this) but the affected geometry is determined by the cubic volume.

Please correct me I'm mistaken somewhere. :)

Share this post


Link to post
Share on other sites

I can't confirm at this time. That's what I recall from about 2 years ago when I was just a lad so it might well be wrong. :blush: I can't find the old post I got it from.

Share this post


Link to post
Share on other sites

I found the old post in one of the internal forums. I was asking the same sort of question as you. I'm not sure I got it exactly right:

 

The default light is not a sphere, but a fading square (like a pyramid viewed from above).

 

The image posted is like a pyramid on top of an inverted pyramid. I think also it ought to be rotated 45 degrees. So it's like a diamond with 6 points rather than a star with its points in the centre of each side of the cube volume. I think this is probably right. Someone will confirm or correct no doubt.

 

[EDIT] Otherwise, why do we want a spherical light if the falloff is already perfectly spherical?

Share this post


Link to post
Share on other sites

You're both kind of right actually -- the light volume as considered by the game is a cube, but the default falloff textures are linear in each dimension which means that the illuminated area will be a sort of eight-sided diamond shape (like two pyramids on top of each other, one pointing up and the other down).

 

Of course this depends on the texture you choose; with biground1 the shape is more like two cones on top of each other (possibly two rounded cones, or even an actual sphere; I haven't checked the Z falloff texture it uses).

Share this post


Link to post
Share on other sites

I don't really know how the falloff works. I thought it was just determined by the distance and a 1D look up texture. But it seems to be more complicated.

Share this post


Link to post
Share on other sites

In the XY plane, yes, it's just a lookup in the light texture, though it's a 2D lookup.

 

However, to calculate the intensity in the entire volume another value is read from a separate z falloff image (presumably it just gets multiplied) - that's what you specify by lightFalloffImage in the material.

Share this post


Link to post
Share on other sites

Yes exactly, the XY planar texture is multiplied by the value from the Z falloff texture to produce the final value. If the XY texture is a gradient (as most are), the Z falloff will cause it to "shrink" to a point as you go further from the center, with the gradient in the Z falloff determining the rate of shrinkage.

Share this post


Link to post
Share on other sites

I also read somewhere that the Z falloff image defaults to makeIntensity(lights/squarelight1a), so you get a smooth falloff in the vertical direction by default.

Share this post


Link to post
Share on other sites
the Z falloff image defaults to makeIntensity(lights/squarelight1a)
It's in the "lights/defaultPointLight" material in "lights.mtr".

 

So the 2D falloff texture is the projected texture and lightFalloffImage is the 1D falloff?

Share this post


Link to post
Share on other sites

Yes, lightFalloffImage is only affecting the Z falloff (the third axis).

Share this post


Link to post
Share on other sites

Some light material definitions I came across use a 2D texture as lightFalloffImage. I guess that's an error then.

Share this post


Link to post
Share on other sites

Can't be sure - there's lots of stuff I don't know about the D3 engine, so maybe it has actually some use. Z-Falloff images are 2D textures too, so maybe they got some cool effect out of it by using a special pattern there?

Share this post


Link to post
Share on other sites

In the "interaction.vfp" fragment shader the y texture coordinate for the falloff lookup is a constant (0.5). Now it makes sense. :)

Share this post


Link to post
Share on other sites

I guess they figured it was easier for an artist to use a 2D texture, rather than having to create a 1D texture. Also this approach means that you can use the same texture for both XY and Z falloffs, for example you could use the lights/biground1 image as a Z falloff if you didn't want it to be linear.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...