For some reason, FlatShadeMaterial in Great White doesn’t work quite how I expect it to.
Look at this example (view source is enabled) … the light only reflects on one side. Strange, huh?
However, one good thing I discovered while making the example to show others, is that the dark colour (the “ambient” argument passed to the constructor) always shows up. Earlier, using a black shade for my panes against the black background of my movie, the planes were going totally out of sight, and I was getting very confused indeed! Yet another reminder to simplify the scenario to isolate the problem … something I often forget when there’s deadline looming …


Think your right…
Looking at lines 42 and 43 of FlatShadeMaterial….
42 does a dot-product of the face normal with the light
43 checks to see if light is ‘behind’ if it is clamps the dot to 0
quick fix is to change line 43 to:
if(zd < 0){zd = -zd;};
That seems to work. Might want to put in the doubleSided check.
Also, is it just me or does it flicker black when normal is aligned with the light?
Thanks for the quickfix! Nice one, I will try that out.
Yes that flicker is annoying isn’t it. I see it also.
If you look at lines 46/47 the dot product is scaled by 255 (0xFF) and then used to look up a color in the _colors array (see line 30 for that). Do a trace on zAngle and you should be able to figure out wtf is going on….
Seems LightMaps.getFlatMapArray returns an array of length 255, instead of 256.
change LighMaps.getFlatMapArray to look like this (it returns 256 colors):
public static function getFlatMapArray(lightColor:int, ambientColor:int, specularLevel:int):Array
{
var array:Array = new Array();
var tempmap:BitmapData = new BitmapData(256,1,false,0);
var s:Sprite = new Sprite();
var m:Matrix = new Matrix();
m.createGradientBox(256,1,0,0,0)
s.graphics.beginGradientFill(GradientType.LINEAR, [lightColor,ambientColor],[1,1],[0,255],m);
s.graphics.drawRect(0,0,256,1);
s.graphics.endFill();
tempmap.draw(s);
var i:int = 256;
while(–i > -1){
array.push(tempmap.getPixel(i,0));
}
return array;
}
Should probably lodge this with papervision team…