用于照明的Starling扩展的渐变阴影

时间:2015-01-22 14:51:44

标签: shader shadow lighting starling-framework agal

告诉我如何获得它http://devsbook.com/est.jpg http://devsbook.com/est2.jpg 在网站winxalex.blogspot.com上找到了一个例子 - > gradient-shadow-filter-starling.html但我无法使用它。谢谢你

此基础阴影着色器

var program:String =

        "sub vt0.xy, va0.xy, vc1.xy \n" + //world xy - light xy = delta xy
        "mul vt0.xy, vt0.xy, va0.z \n" + //delta xy * shadow multiplier (0 || 1) = shadow xy

        "mul vt0.xy, vt0.xy, vc0.z \n" + //shadow xy * 1000
        "add vt1.xy, va0.xy, vt0.xy \n" + //world xy + shadow xy

        "mov vt1.z, vc0.xy.x \n" + //vt1.z = 0
        "mov vt1.w, vc0.xy.y \n" + //vt1.w = 1
        "m44 op, vt1, vc2"; //project to clip space

1 个答案:

答案 0 :(得分:0)

不确定是否对您有任何帮助,但这是我创建渐变背景的方式:

//Background Gradient Colour
var topColor:uint = 0x81CCC9; // blue
var bottomColor:uint    = 0xFEFFFF; // white
var backgroundGradient:Quad = new Quad(scrWidth, scrHeight);
backgroundGradient.setVertexColor(0, topColor);
backgroundGradient.setVertexColor(1, topColor);
backgroundGradient.setVertexColor(2, bottomColor);
backgroundGradient.setVertexColor(3, bottomColor);
addChild(backgroundGradient);