All lights are realtime and the fps is good (50 fps uncompiled, 8 objects, 2 lights and I havent optimized yet). The lighting is perpixel lighting and the shadows are the only things slowing down the framerate, the perpixel lighting is actually very efficient.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
In the first image the box near the centre should be illuminated on three sides but it appears to be only two on the image. Looks a bit odd. Also on some other boxes the shadows are actually cancelling out some lit regions. Or am I reading it wrong?
Re: VB: Advanced Lighting and Shadowing (Tutorial)
In the first pic, there are only 2 lights. The shadows cancel out the lit areas where the lights meet, where the light is full intensity, the shadow wont cancel out.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
The shadows shouldn't fall on the boxes? I mean... shadow should go on another box only if it is shorter than the box that makes the shadow. Though, I guess this is more of a 2D... but in that case a shadow should never go on top of another box afaik. It just looks weird and unrealistic.
Of course other than that it is great, though I didn't take a look in the source
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Er... I cant put it back without writing a whole new program(just tried), the shadows and lights are both drawn on the same buffer, the objects onto another and they are multiplied, with the output on the backbuffer.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Here you have a sample of what is somewhat should look like:
You can clearly see what is the problem when you compare it to the screenshots: the more lights, the more shadows, but the more shadows, the lighter they are: except in the places where there are shadow on shadow. The light strength should also be taken into account, a stronger light surpasses a weaker one and makes shadow to the area of a weaker one.
I'm not an expert in this area, but I've thought about lights and shadows in the dark nights when I've been walking from a light to another in the street
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Merri, what you get up to on the streets at night is your own business j/k.
I don't think the problem lies with shadows being on top of boxes or not, the fact is that if the shadow engine was more realistic then that effect wouldn't occur at all...
I think the first picture would look more like this... (the grey areas would be in light, the black areas in shadow, I haven't bothered with gradients)
Since the middle square is being lit from 3 sides, then only the 4th side can be in shadow, and not as in the original pic. I omitted a couple of boxes for clarity.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
If anyone could modify the code I did and show the updated code, that would be really nice. What I do is, for each light, all the shadows are subtracted from the light and then the light is added onto the lightbuffer.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
By using 2 lights, 1 object and the same code I uploaded (only difference is number of lights & objects), I position the lights at 0,0 and 640,0 and the object at 320,240, I get the following
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Yeah, but you should make it take other objects into account At the moment it works somewhat correctly to one object (it seems), but the first screenshots up there were odd. What happens when you include another object near the other one??
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Yup, it gets distorted. For example, it seems that it can make a shadow on a light source. There should be no shadow on a light source. The shadows should get weaker when close to light. And as stated already, the shadows should cut out when they go on another object (they do cut out now, but in the wrong edge).
Humm... I played around with a flashlight. I think I got the real problem now: your lights are in the same level as the objects. When I placed a flashlight in the same (ground)level with the object, it didn't make any shadow. So, you should also know how high your lights are compared to the objects. This way you can do more accurate shadow and also calculate where the shadow ends (and where extra light should be made).
Re: VB: Advanced Lighting and Shadowing (Tutorial)
The reason why it looks strange is because the shadows are extending too close to the light sources.
The shadow generation seems perfect but after the shadows are generated they are not lit up enough by the light source. Look at the picture and see those shadows right close to the lights, they should be much fainter if not invisible.
The red areas show where it is too dark too close to the light
The blue rings show how far the light should extend where no shadows form and from then onwards shadows should get gradually darker.
Last edited by First.Assassin; Jul 17th, 2005 at 02:26 PM.
Reason: addition
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Anyone else get a automation error when you run it? Haven't had time to look into why its happening but think its not being initalised properly for all cards.
As for the problem its seems from the pics that when you generate a shadow from one light you don't take into account any other lights at that time. Would probably mean taking a different approch, instead of using each light and applying it to each pixel then the next light ect. you could go through each pixel once each and calculate its light value. That sounds like it would be a rather big rewrite so i guess you could go back to how you've done it using each light at a time but when doing each pixel cross referance it with other lights. This might result in still a one pass situation but could be rather processor hungry too .
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
One way would be to use a midpoint, which would be the highest light. I'll explain this a bit better:
values 0 - 127 = black to white
value 128 - 255 = "too bright to see the brightness", are always considered to be white
Now what does this give to use? You got it: the possibility to have too big values! But why? This would be a small "override" to the problem mentioned by First.Assasin. It would give you the power to control easier what would be the point where shadow turns out to be invisible. The lights would be stronger and not weak as they are now.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Update: I am working on a new version with stencil shadow volumes (much more faster) and I am trying to make the light fade using a 1D .bmp (1x256), i'll post it as soon as im done.
Re: VB: Advanced Lighting and Shadowing (Tutorial)
Sorry I was meaning to post this but forgot about it ...
I think I figured out why it was looking wrong, the way you are doing it is starting with white and then turning the pixels darker where the shadows are cast....if you go at it the other way by starting with black and lighten the pixels where the lights fall it will give the correct/natural effect .
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.