Ok I have a fix for the lighting scale.
by John Kabus (BobTheCBuilder) · in Torque Game Engine · 09/28/2003 (1:20 pm) · 14 replies
Ok I have a fix for the lighting scale.
In SceneLighting::InteriorProxy::light() starting at line 1839 (originally wrong line number, sorry for the confusion) you will see the following lines:
and at line 1881 (originally wrong line number, sorry for the confusion):
The first problem is that lumelScale should be inversely proportional to the lighting scale. This is because the variable actually represents the number of world units per lumel not the lume scale as the name might suggest.
The second problem is that the lighting scale should affect the surface members 'mapOffsetX' and 'mapOffsetY'.
Remove both lines at line 2129 and change the lines at 2088 to:
That's it.
John Kabus.
In SceneLighting::InteriorProxy::light() starting at line 1839 (originally wrong line number, sorry for the confusion) you will see the following lines:
// get the start point on the lightmap
pStart[si] = ((surface.mapOffsetX / (1 / lGenX[si])) - lGenX[3]) / lGenX[si];
pStart[ti] = ((surface.mapOffsetY / (1 / lGenY[ti])) - lGenY[3]) / lGenY[ti];
pStart[axis] = ((pNormal[si] * pStart[si]) +
(pNormal[ti] * pStart[ti]) + plane.d) / -pNormal[axis];and at line 1881 (originally wrong line number, sorry for the confusion):
// scale the vectors
F32 lumelScale = lGenX[si] * normLightmap->getWidth();The first problem is that lumelScale should be inversely proportional to the lighting scale. This is because the variable actually represents the number of world units per lumel not the lume scale as the name might suggest.
The second problem is that the lighting scale should affect the surface members 'mapOffsetX' and 'mapOffsetY'.
Remove both lines at line 2129 and change the lines at 2088 to:
F32 lumelScale = 1 / (lGenX[si] * normLightmap->getWidth()); // get the start point on the lightmap pStart[si] = (((surface.mapOffsetX * lumelScale) / (1 / lGenX[si])) - lGenX[3]) / lGenX[si]; pStart[ti] = (((surface.mapOffsetY * lumelScale) / (1 / lGenY[ti])) - lGenY[3]) / lGenY[ti]; pStart[axis] = ((pNormal[si] * pStart[si]) + (pNormal[ti] * pStart[ti]) + plane.d) / -pNormal[axis];
That's it.
John Kabus.
#2
Glad to hear that. I posted the update here in the bug forum so the changes will make it into head.
Also if you scale your interiors you might want to check out this: www.garagegames.com/mg/forums/result.thread.php?qt=12918.
John Kabus.
09/28/2003 (4:20 pm)
Gilles,Glad to hear that. I posted the update here in the bug forum so the changes will make it into head.
Also if you scale your interiors you might want to check out this: www.garagegames.com/mg/forums/result.thread.php?qt=12918.
John Kabus.
#4
ie both of you fixes have line numbers that are off by many hundred lines in my local copy...
Have you tried those fixes on a vanilla HEAD to make sure they work as intended, if your scenelighting is that different from the stock one ?
Thanks for sharing :)
09/29/2003 (8:25 am)
John, have you added a lot of code to sceneLighting.cc ?ie both of you fixes have line numbers that are off by many hundred lines in my local copy...
Have you tried those fixes on a vanilla HEAD to make sure they work as intended, if your scenelighting is that different from the stock one ?
Thanks for sharing :)
#5
Reading from his plan, John have made a lot more of cool things with the lightning :) That's why his line number don't match ours.
I've included it in my build and I hadn't touched sceneLightning.cc before so it's the head version. It's working really good.
John,
BTW, the other fix is really cool too. You've made me lose precious production time with both those fix because I couldn't resist to go see all my level, one after another to see how wonderfull they are now :) (around 60 levels, doh !). Can't say enough thanks !
Gilles Jr
09/29/2003 (8:45 am)
Nicolas,Reading from his plan, John have made a lot more of cool things with the lightning :) That's why his line number don't match ours.
I've included it in my build and I hadn't touched sceneLightning.cc before so it's the head version. It's working really good.
John,
BTW, the other fix is really cool too. You've made me lose precious production time with both those fix because I couldn't resist to go see all my level, one after another to see how wonderfull they are now :) (around 60 levels, doh !). Can't say enough thanks !
Gilles Jr
#6
So it works fine for you Gilles ? your interiors still cast shadows not only on each other, but on the terrain too ?
ie looks like my interiors are not projecting shadows anymore, and since I noticed it right after applying those fixes, I wondered if they might have been the cause...
Alas, doesn't look like it, as I just took it out, and the buildings still cast shadows on each other, but not on the terrain... (Grrrr !!! ;))
09/29/2003 (9:13 am)
Doh, I saw his .plan :) So it works fine for you Gilles ? your interiors still cast shadows not only on each other, but on the terrain too ?
ie looks like my interiors are not projecting shadows anymore, and since I noticed it right after applying those fixes, I wondered if they might have been the cause...
Alas, doesn't look like it, as I just took it out, and the buildings still cast shadows on each other, but not on the terrain... (Grrrr !!! ;))
#7
EDIT: Ah, it was for scaling/translating interiors
09/29/2003 (9:15 am)
What are these other fixes that have been made? The only other one I've seen was where 2 lines were switched around, which was made a few days ago, but I forget what that fixed...EDIT: Ah, it was for scaling/translating interiors
#8
Couldn't live without it now :) I have shadows everywhere (on terrain and dif 2 dif). Really no idea why you don't have shadows on terrain, but I'm sure it's not because of those fixes.
09/29/2003 (9:46 am)
Nicolas,Couldn't live without it now :) I have shadows everywhere (on terrain and dif 2 dif). Really no idea why you don't have shadows on terrain, but I'm sure it's not because of those fixes.
#9
-J
09/29/2003 (10:16 am)
I don't have a moment to check this out right now... But, thanks for reporting these issues... bookmarked :)-J
#10
I still can't believe I used the wrong line numbers. I had to find the old copy of head to get the exact code snippets, but for some reason I used the line numbers off of my code base instead. Thanks for pointing that out. :)
Glad this is helping out...
John.
09/29/2003 (6:48 pm)
Ok, I updated the line numbers in both posts (sorry for the confusion). The new numbers are based off of head from August 29, so they should be a lot closer.I still can't believe I used the wrong line numbers. I had to find the old copy of head to get the exact code snippets, but for some reason I used the line numbers off of my code base instead. Thanks for pointing that out. :)
Glad this is helping out...
John.
#11
Based on other threads in the community it sounds like a bug was introduced into scene lighting recently. I would guess that Gilles is using an older head (or ver 1.1.2). I know that scene lighting was working prior to August 30, so I would recommend checking out by date at August 29. You could then do a diff to figure out what changed and maybe revert your scene lighting to the earlier version (or update the affected code).
John.
09/30/2003 (7:50 am)
Nicolas,Based on other threads in the community it sounds like a bug was introduced into scene lighting recently. I would guess that Gilles is using an older head (or ver 1.1.2). I know that scene lighting was working prior to August 30, so I would recommend checking out by date at August 29. You could then do a diff to figure out what changed and maybe revert your scene lighting to the earlier version (or update the affected code).
John.
#12
Yup, you're right. We were working with a 2 months old head, approx. Probably why I didn't see this one.
We are now ported to the new HEAD and there is still shadows on terrain in my levels (I deleted all .ml to be sure), plus I added your 2 fixes. Everything works fine.
So, it's propably fixed now ?!
09/30/2003 (9:11 am)
John,Yup, you're right. We were working with a 2 months old head, approx. Probably why I didn't see this one.
We are now ported to the new HEAD and there is still shadows on terrain in my levels (I deleted all .ml to be sure), plus I added your 2 fixes. Everything works fine.
So, it's propably fixed now ?!
#13
John.
09/30/2003 (10:02 am)
Thanks for checking into it for us, also glad to hear that it's fixed.John.
#14
As I said, it made me wonder if the fixes were the cause of disappearing shadows because of discrepancies between HEAD and your codebased :)
Glad to head, and notice, that the new HEAD seems to work fine in that respect..
Merging our codebase today :)
09/30/2003 (11:03 am)
Thanks John and Gilles, the line numbers weren't really a problem for me, since I rarely use them to find the code in snippets :)As I said, it made me wonder if the fixes were the cause of disappearing shadows because of discrepancies between HEAD and your codebased :)
Glad to head, and notice, that the new HEAD seems to work fine in that respect..
Merging our codebase today :)
Torque Owner Gilles Jr Lafrance
This should really be included into the HEAD. At least, send it as a ressource for easy finding. All my interiors are giant in our actual game and I hadn't shadows on my dif to dif a lot of place. Now, my levels are wonderfull and really more natural with your fix.
Awesome ! Thanks a million !
Gilles Jr
Note : I had to delete the .ml files in /missions so see the change.