away3d / away3d-core-broomstick

Away3D engine for Flash Player Incubator
http://www.away3d.com
93 stars 25 forks source link

ColorTransformMethod color offsets in wrong range (0-255), should be (0.0-1.0) #69

Closed esvban closed 13 years ago

esvban commented 13 years ago

I've posted this on the away3d forums as well.

ColorTransformMethod.as line 72 override arcane function activate(context : Context3D, contextIndex : uint) : void { _colorTransformData[0] = _colorTransform.redMultiplier; _colorTransformData[1] = _colorTransform.greenMultiplier; _colorTransformData[2] = _colorTransform.blueMultiplier; _colorTransformData[3] = _colorTransform.alphaMultiplier; _colorTransformData[4] = _colorTransform.redOffset; _colorTransformData[5] = _colorTransform.greenOffset; _colorTransformData[6] = _colorTransform.blueOffset; _colorTransformData[7] = _colorTransform.alphaOffset; context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, _colorTransformIndex, _colorTransformData, 2); }

the ColorTransform class asks for offsets between -255 and 255. However the shading code uses colors between 0 and 1. Additional code needs to be added to convert the offsets to the correct range.

Maybe this - not sure if the boundary conditions matter for the shader. '_colorTransformData[4] = _colorTransform.redOffset / 0xff; _colorTransformData[5] = _colorTransform.greenOffset / 0xff; _colorTransformData[6] = _colorTransform.blueOffset / 0xff; _colorTransformData[7] = _colorTransform.alphaOffset / 0xff; '

DerSchmale commented 13 years ago

Yep, another one on the "duh"-pile! Fixed in the FP11 branch!