Thursday, February 28, 2013

Stuck on lighting

I've continued working as usual and made fine progress, but I can't give you any updates because for the past two days I've been completely stuck on the lighting shaders.

I starting implementing multiple lights. The idea was that things like your torch, a static light, a spell would serves as secondary light sources on top of the general lighting conditions. I started implementing point lights for this.

Here is where the problems started.

First I had problems with light intensity. Eventually I managed to normalize some values in shader so that all objects react uniformly to light, even scaled ones.

But the second problem is bigger. Imagine an upright barrel. It has it round side facing you and the cap of it is on top. I encountered the problem where the cap would react far sooner and far harder to the spot light. Eventually I started playing around with export options from Blender and after hundreds of trials and errors I removed the rotation of the barrel and this helped. But nothing would help the stone stool. After updating to a newer version of Blender, the same options + lack of rotation did the trick. It also removed some nasty flare up on the sides of rolling barrels which I believe could be seen in some videos too.

I thought the issue fixed until I tested with a tipped over barrel. The issue was back, this time with the cap facing the camera reacting less the sides.

Here is a picture showing this: 

The spot light is red and placed at the camera position. The barrel above the cross-hair is facing the camera, yet the caps receive almost no light and the top receives it instead  Like some sort of weird rotation. Which does not happen if I drop the barrel in the same position, but upright:

Above is the normal situation, with the sides reacting more than the cap. Before the Blender rotation fix, my original issue looked exactly like the above picture, but with the side black and the cap red.

This issue is driving me crazy. I won't be posting updates or working on something else until I either fix this issue or figure out why it is happening and don't fix it, be it a day, a month, a year...

1 comment:

  1. At least you seem to get spherical harmonics down better than I do :P I looked at the SH code you told me about but it uses an array of variables that I cannot figure out where they are being sent from to the shader. I gave up on that for now. I have Blinn-Phong specular working on my engine now.

    Also you're giving more hints about your game. Spells and torches? Is this a fantasy action game you're making?