【发布时间】:2014-01-23 11:56:10
【问题描述】:
我已经创建了一个过渡着色器。
这是做什么的:
On each update the color that should be alpha changes.
Then preform a check for each pixel.
If the color of the pixel is more that the 'alpha' value
Set this pixel to transparent.
Else If the color of the pixel is more that the 'alpha' value - 50
Set this pixel to partly transparent.
Else
Set the color to black.
编辑(删除旧部分):
我尝试将我的 GLSL 转换为 AGAL(使用 http://cmodule.org/glsl2agal):
片段着色器:
const float alpha = 0.8;
varying vec2 TexCoord; //not used but required for converting
uniform sampler2D transition;//not used but required for converting
void main()
{
vec4 color = texture2D(transition, TexCoord.st);//not used but required for converting
color.a = float(color.r < alpha);
if(color.r >= (alpha - 0.1)){
color.a = 0.2 * (color.r - alpha - 0.1);
}
gl_FragColor = vec4(0, 0, 0, color.a);
}
我已经自定义了输出并将其添加到(自定义)Starling 过滤器:
var fragmentShader:String =
"tex ft0, v0, fs0 <2d, clamp, linear, mipnone> \n" + // copy color to ft0
"slt ft0.w, ft0.x, fc0.x \n" + // alpha = red < inputAlpha
"mov ft0.xyz, fc1.xyzz \n" + // set color to black
"mov oc, ft0";
mShaderProgram = target.registerProgramFromSource(PROGRAM_NAME, vertexShader, fragmentShader);
它可以工作,当我设置过滤器 alpha 时,它会更新内容。唯一剩下的是部分透明的东西,但我不知道该怎么做。
【问题讨论】:
-
我对八哥的了解几乎为零,但我建议您使用help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/… 来处理颜色过渡。我很确定,如果你正确构建矩阵,你可以在循环方法的 1000 倍的速度下获得相同的效果。
-
是的,starling 也有滤镜,所以基本相同,虽然我不知道如何使用彩色矩阵滤镜实现这种行为。
标签: image actionscript-3 shader transition