Replace shader "if" instruction to "step"

This commit is contained in:
2017-08-06 02:07:09 +07:00
parent 17a7a1f10e
commit 9f7f0e5a2b
5 changed files with 6 additions and 22 deletions

View File

@@ -2,6 +2,7 @@
* Not save generated meshes in scene
* Fix (At line 908 of file "FTMain.jsfl": ReferenceError: ft is not defined)
* Fix warning on add missing components
* Replace shader "if" instruction to "step"
###### Version 1.3.8
* Fix shape groups in tweens problems

View File

@@ -137,9 +137,7 @@ inline fixed4 swf_frag(swf_v2f_t IN) : SV_Target {
fixed4 c = tex2D(_MainTex, IN.uv);
fixed4 a = tex2D(_AlphaTex, IN.uv).r;
c.a = lerp(c.a, a.r, _ExternalAlpha);
if ( c.a > 0.01 ) {
c = c * IN.mulcolor + IN.addcolor;
}
c = c * IN.mulcolor + step(0.01, c.a) * IN.addcolor;
c.rgb *= c.a;
return c;
}
@@ -148,10 +146,8 @@ inline fixed4 swf_grab_frag(swf_grab_v2f_t IN) : SV_Target {
fixed4 c = tex2D(_MainTex, IN.uv);
fixed4 a = tex2D(_AlphaTex, IN.uv).r;
c.a = lerp(c.a, a.r, _ExternalAlpha);
if ( c.a > 0.01 ) {
c = c * IN.mulcolor + IN.addcolor;
c = grab_blend(_GrabTexture, IN.screenpos, c);
}
c = c * IN.mulcolor + step(0.01, c.a) * IN.addcolor;
c = grab_blend(_GrabTexture, IN.screenpos, c);
c.rgb *= c.a;
return c;
}

View File

@@ -378,7 +378,7 @@ namespace FTEditor.Postprocessors {
var bitmap = inst != null
? FindBitmapFromAssetData(data, inst.Bitmap)
: null;
if ( bitmap != null && IsVisibleInstance(inst) ) {
if ( bitmap != null ) {
var width = bitmap.RealWidth / 20.0f;
var height = bitmap.RealHeight / 20.0f;
@@ -491,11 +491,6 @@ namespace FTEditor.Postprocessors {
return null;
}
static bool IsVisibleInstance(SwfInstanceData inst) {
var result_color = inst.ColorTrans.ApplyToColor(Color.white);
return result_color.a >= 0.01f;
}
// ---------------------------------------------------------------------
//
// UpdateAssetClips

View File

@@ -154,14 +154,6 @@ namespace FTEditor {
public SwfVec4Data mulColor;
public SwfVec4Data addColor;
public Color ApplyToColor(Color color) {
return new Color(
Mathf.Clamp01(color.r * mulColor.x + addColor.x),
Mathf.Clamp01(color.g * mulColor.y + addColor.y),
Mathf.Clamp01(color.b * mulColor.z + addColor.z),
Mathf.Clamp01(color.a * mulColor.w + addColor.w));
}
public static SwfColorTransData identity {
get {
return new SwfColorTransData{

View File

@@ -61,7 +61,7 @@ https://gist.github.com/talecrafter/111ea3345911bd238f4998b4d5a04bf3
можно в hideFlags на меше поиграться!
**** TODO Поддержка задавать теги и сплит текстур на альфу для etc
**** TODO Заменить установку пропертей шейдера с текстовых имён на id
**** TODO Заюзать step вместо if в шейдере
**** DONE Заюзать step вместо if в шейдере
https://web.archive.org/web/20161214092913/http://http.developer.nvidia.com:80/Cg/step.html
*** Баги
**** TODO Скейлы клипов не проверяются в группах