Beispiel #1
0
 public override void ProcessOutput(SWShaderProcessBase processor, string keyword = "")
 {
     base.ProcessOutput(processor, keyword);
     foreach (var outp in processor.childOutputs)
     {
         foreach (var item in outp.outputs)
         {
             if (item.data.type == type)
             {
                 if (keyword == "add")
                 {
                     //UV加上去,一个影像
                     if (item.type == SWDataType._UV && item.uvOp == SWUVop.add)
                     {
                         processor.StringAddLine(string.Format("\t\t\t\t{0} = {0} + {1}*{2};", processor.uvParam, item.param, item.opFactor));
                     }
                 }
                 else if (keyword == "lerp")
                 {
                     //原影像和 UV后影像叠加
                     if (item.type == SWDataType._UV && item.uvOp == SWUVop.lerp)
                     {
                         //iNormal
                         processor.TextureSample(string.Format("color{0}_{1}", processor.node.data.iName, item.param),
                                                 true, processor.node.TextureShaderName(), string.Format("{0}+{1}", processor.uvParam, item.param, processor.node.data.useNormal));
                         processor.StringAddLine(string.Format("\t\t\t\tcolor{0} = lerp(color{0},color{0}_{1},clamp({2},0,1));    ", processor.node.data.iName, item.param, item.opFactor));
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 public override void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, string keyword = "")
 {
     base.ProcessOutputSingle(processor, item, keyword);
     if (keyword == "add")
     {
         //UV加上去,一个影像
         if (item.type == SWDataType._UV && item.uvOp == SWUVop.add)
         {
             processor.StringAddLine(string.Format("\t\t\t\t{0} = {0} + {1}*{2};", processor.uvParam, item.param, item.opFactor));
         }
     }
     else if (keyword == "lerp")
     {
         //原影像和 UV后影像叠加
         if (item.type == SWDataType._UV && item.uvOp == SWUVop.lerp)
         {
             //iNormal
             processor.TextureSample(string.Format("color{0}_{1}", processor.node.data.iName, item.param),
                                     true, processor.node.TextureShaderName(), string.Format("{0}+{1}", processor.uvParam, item.param, processor.node.data.useNormal));
             processor.StringAddLine(string.Format("\t\t\t\tcolor{0} = lerp(color{0},color{0}_{1},clamp({2},0,1));    ", processor.node.data.iName, item.param, item.opFactor));
         }
     }
     else if (keyword == "replace")
     {
         //UV加上去,一个影像
         if (item.type == SWDataType._UV && item.uvOp == SWUVop.replace)
         {
             processor.StringAddLine(string.Format("\t\t\t\t{0} = lerp({0},{1},{2});", processor.uvParam, item.param, item.opFactor));
         }
     }
 }
        public override void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, string keyword = "")
        {
            base.ProcessOutputSingle(processor, item, keyword);
            string uvParam = string.Format("uv{0}", processor.node.data.iName);

            processor.StringAddLine(string.Format("\t\t\t\t{0} = {1};", uvParam, item.param));
        }
        public override void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, string keyword = "")
        {
            base.ProcessOutputSingle(processor, item, keyword);
            string uvParam = string.Format("uv{0}", processor.node.data.iName);

            string param = string.Format("retroFactor{0}{1}", processor.node.data.iName, item.node.data.iName);

            processor.StringAddLine(string.Format("\t\t\t\tfloat {0} = {1}*max(rect{2}.z,rect{2}.w);", param, item.opFactor, processor.node.data.iName));
            processor.StringAddLine(string.Format("\t\t\t\t{0} = Retro({0},{1});", uvParam, param));
        }
        void ProcessFinal(SWShaderProcessBase processor, SWOutputSub item)
        {
            if (!item.data.effectData.pop_final)
            {
                return;
            }

            processor.StringAddLine(string.Format("\t\t\t\t{0} = float4({0}.rgb,{0}.a* lerp(1,clamp({1}*{2},{3},{4}),{5}));    ",
                                                  "result", item.param, item.opFactor, item.data.effectData.pop_min.ToStringEX(), item.data.effectData.pop_max.ToStringEX(), item.opFactor));
        }
        protected void ProcessOutpBlur(SWShaderProcessBase processor, SWOutputSub sub)
        {
            string uvParam = string.Format("uv{0}", processor.node.data.iName);

            string param = string.Format("retroFactor{0}{1}", processor.node.data.iName, sub.node.data.iName);

            processor.StringAddLine(string.Format("\t\t\t\t float {0} = {1}*max(rect{2}.z,rect{2}.w);", param, sub.opFactor, processor.node.data.iName));

            processor.StringAddLine(string.Format("\t\t\t\t{0} = float2({0}.x - {0}.x%{1} + {1}*0.5 ,{0}.y - {0}.y%{1} + {1}*0.5);", uvParam, param));
        }
 public override void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, string keyword = "")
 {
     base.ProcessOutputSingle(processor, item, keyword);
     if (keyword == "final")
     {
         ProcessFinal(processor, item);
     }
     else
     {
         Process(processor, item);
     }
 }
        void Process(SWShaderProcessBase processor, SWOutputSub item)
        {
            if (item.data.effectData.pop_final)
            {
                return;
            }

            string colorParam = string.Format("color{0}", processor.node.data.iName);

            processor.StringAddLine(string.Format("\t\t\t\t{0} = float4({0}.rgb,{0}.a* lerp(1,clamp({1}*{2},{3},{4}),{5}));    ",
                                                  colorParam, item.param, item.opFactor, item.data.effectData.pop_min.ToStringEX(), item.data.effectData.pop_max.ToStringEX(), item.opFactor));
        }
        public SWOutput Process(SWNodeBase node)
        {
            if (node.shaderOutput != null)
            {
                return(node.shaderOutput);
            }

            SWShaderProcessBase processor = CreateProcessor(node.data.type);

            node.shaderOutput = processor.Process(node);
            return(node.shaderOutput);
        }
Beispiel #10
0
 public virtual void ProcessOutput(SWShaderProcessBase processor, string keyword = "")
 {
     foreach (var outp in processor.childOutputs)
     {
         foreach (var item in outp.outputs)
         {
             if (item.data.type == type)
             {
                 ProcessOutputSingle(processor, item, keyword);
             }
         }
     }
 }
Beispiel #11
0
        /// <summary>
        /// Add:Keep alpha,only add rgb
        /// Mul:Simple multiple color
        /// Lerp:
        /// </summary>
        public override void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, string keyword = "")
        {
            base.ProcessOutputSingle(processor, item, keyword);
            if (keyword == "first")
            {
                //processor.StringAddLine (string.Format ("\t\t\t\tresult = {0}*{1};", item.param, item.opFactor));
                processor.StringAddLine(string.Format("\t\t\t\tresult = float4({0}.rgb,{0}.a*{1});", item.param, item.opFactor));
                return;
            }

            if (item.op == SWOutputOP.blend)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = lerp(result,float4({0}.rgb,1),clamp({0}.a*{1},0,1));    ",
                                                      item.param, item.opFactor));
            }
            else if (item.op == SWOutputOP.blendInner)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = lerp(result,float4({0}.rgb,rootTexColor.a),clamp({0}.a*{1},0,1));    ",
                                                      item.param, item.opFactor));
            }
            else if (item.op == SWOutputOP.add)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = result+float4({0}.rgb*{0}.a*{1},{0}.a*{1});", item.param, item.opFactor));
            }
            else if (item.op == SWOutputOP.addInner)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = result+float4({0}.rgb*{0}.a*{1},{0}.a*{1}*(rootTexColor.a - result.a));", item.param, item.opFactor));
            }
            else if (item.op == SWOutputOP.mul)
            {
                processor.StringAddLine(string.Format("result = result *lerp(float4(1,1,1,1),{0},{0}.a*{1});", item.param, item.opFactor));
            }
            else if (item.op == SWOutputOP.mulIntersect)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = result*{0}*{1};", item.param, item.opFactor));
            }
            else if (item.op == SWOutputOP.mulRGB)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = float4(result.rgb*lerp(float3(1,1,1),{0}.rgb,{1}),result.a);", item.param, item.opFactor));
            }
            else
            {
                string func = string.Format("Blend{0}", item.op.ToString());
                processor.StringAddLine(string.Format("\t\t\t\tresult3 = {2}({0}.rgb,{1}.rgb);", "result", item.param, func));
                processor.StringAddLine(string.Format("\t\t\t\tminA = min(result.a,{0}.a);", item.param));
                processor.StringAddLine(string.Format("\t\t\t\tresult3 = result.rgb*(result.a-minA)+{0}.rgb*({0}.a-minA)+minA*result3;", item.param));
                processor.StringAddLine(string.Format("\t\t\t\tresult2 = float4(result3,result.a+{0}.a*(1-result.a));", item.param));
                processor.StringAddLine(string.Format("\t\t\t\tresult = lerp(result,result2,{0});", item.opFactor));
            }
        }
 public override void ProcessOutput(SWShaderProcessBase processor, string keyword = "")
 {
     base.ProcessOutput(processor, keyword);
     foreach (var outp in processor.childOutputs)
     {
         foreach (var item in outp.outputs)
         {
             if (item.data.type == type)
             {
                 ProcessOutpBlur(processor, item);
             }
         }
     }
 }
        public override void ProcessOutput(SWShaderProcessBase processor, string keyword = "")
        {
            base.ProcessOutput(processor, keyword);
            processor.StringAddLine(string.Format("\t\t\t\tfloat4 color{0} = float4(0,0,0,0);", processor.node.data.iName));

            foreach (var outp in processor.childOutputs)
            {
                foreach (var item in outp.outputs)
                {
                    if (item.data.type == type)
                    {
                        ProcessOutpBlur(processor, item);
                    }
                }
            }
        }
Beispiel #14
0
        public override void ProcessOutput(SWShaderProcessBase processor, string keyword = "")
        {
            base.ProcessOutput(processor, keyword);
            string uvParam = string.Format("uv{0}", processor.node.data.iName);

            foreach (var outp in processor.childOutputs)
            {
                foreach (var item in outp.outputs)
                {
                    if (item.data.type == type)
                    {
                        processor.StringAddLine(string.Format("\t\t\t\t{0} = {1};", uvParam, item.param));
                    }
                }
            }
        }
        /// <summary>
        /// Add:Keep alpha,only add rgb
        /// Mul:Simple multiple color
        /// Lerp:
        /// </summary>
        public override void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, bool first)
        {
            base.ProcessOutputSingle(processor, item, first);
            if (first)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = {0};", item.param, item.opFactor));
                return;
            }

            if (item.op == SWOutputOP.blend)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = lerp(result,float4({0}.rgb,1),clamp({0}.a*{1},0,1));    ",
                                                      item.param, item.opFactor));
            }
            if (item.op == SWOutputOP.blendInner)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = lerp(result,float4({0}.rgb,rootTexColor.a),clamp({0}.a*{1},0,1));    ",
                                                      item.param, item.opFactor));
//				processor.StringAddLine( string.Format ("\t\t\t\tresult = lerp(result,float4({0}.rgb,result.a),clamp({0}.a*{1},0,1));    ",
//					item.param, item.opFactor));
            }


            if (item.op == SWOutputOP.add)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = result+float4({0}.rgb*{0}.a*{1},{0}.a*{1});", item.param, item.opFactor));
            }
            if (item.op == SWOutputOP.addInner)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = result+float4({0}.rgb*{0}.a*{1},{0}.a*{1}*(rootTexColor.a - result.a));", item.param, item.opFactor));
                //processor.StringAddLine( string.Format("\t\t\t\tresult = result+float4({0}.rgb*{0}.a*{1},0);",item.param,item.opFactor));
            }



            if (item.op == SWOutputOP.mul)
            {
                processor.StringAddLine(string.Format("result = result *lerp(float4(1,1,1,1),{0},{0}.a*{1});", item.param, item.opFactor));
            }
            if (item.op == SWOutputOP.mulIntersect)
            {
                processor.StringAddLine(string.Format("\t\t\t\tresult = result*{0}*{1};", item.param, item.opFactor));
            }
        }
Beispiel #16
0
        public void Blur(SWShaderProcessBase processor, SWOutputSub sub, string colorName, string texName, string uv)
        {
            //			processor.StringAddLine (string.Format ("\t\t\t\t{1} = Blur(_{2},{3},{4}*rect{0}.zw);",
            //				processor.node.data.iName,colorName,texName,uv,sub.opFactor));

            //Blur constrains in rect_Sprite
            if (processor.NeedRectSprite())
            {
                processor.StringAddLine(string.Format("\t\t\t\t{1} = Blur(_{2},{3},{4}*rect{0}.zw,i.rect_Sprite,{5});",
                                                      processor.node.data.iName,
                                                      colorName,
                                                      texName,
                                                      uv,
                                                      sub.opFactor,
                                                      processor.IsSpriteType_SamplingSprite()?"true":"false"
                                                      ));
            }
            else
            {
                processor.StringAddLine(string.Format("\t\t\t\t{1} = Blur(_{2},{3},{4}*rect{0}.zw,float4(0,0,1,1),false);",
                                                      processor.node.data.iName, colorName, texName, uv, sub.opFactor));
            }
        }
Beispiel #17
0
 public virtual void ProcessOutput(SWShaderProcessBase processor, string keyword = "")
 {
 }
Beispiel #18
0
 public virtual void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, string keyword = "")
 {
 }
 public void Blur(SWShaderProcessBase processor, SWOutputSub sub, string colorName, string texName, string uv)
 {
     processor.StringAddLine(string.Format("\t\t\t\t{1} = Blur(_{2},{3},{4}*rect{0}.zw);",
                                           processor.node.data.iName, colorName, texName, uv, sub.opFactor));
 }
        protected void ProcessOutpBlur(SWShaderProcessBase processor, SWOutputSub sub)
        {
            string uvParam = string.Format("uv{0}", processor.node.data.iName);

            processor.StringAddLine(string.Format("\t\t\t\t\tcolor{0} = Blur(_{1},{2},{3});", processor.node.data.iName, processor.node.TextureShaderName(), uvParam, sub.opFactor));
        }
        public static SWShaderProcessBase CreateProcessor(SWNodeType type)
        {
            SWShaderProcessBase processor = null;

            if (type == SWNodeType.root)
            {
                processor = new SWShaderProcessRoot();
            }
            else if (type == SWNodeType.mask)
            {
                processor = new SWShaderProcessMask();
            }
            else if (type == SWNodeType.color)
            {
                processor = new SWShaderProcessColor();
            }
            else if (type == SWNodeType.image)
            {
                processor = new SWShaderProcessImage();
            }
            else if (type == SWNodeType.uv)
            {
                processor = new SWShaderProcessUV();
            }
            else if (type == SWNodeType.alpha)
            {
                processor = new SWShaderProcessAlpha();
            }
            else if (type == SWNodeType.mixer)
            {
                processor = new SWShaderProcessMixer();
            }
            else if (type == SWNodeType.remap)
            {
                processor = new SWShaderProcessRemap();
            }
            else if (type == SWNodeType.blur)
            {
                processor = new SWShaderProcessBlur();
            }
            else if (type == SWNodeType.retro)
            {
                processor = new SWShaderProcessRetro();
            }
            else if (type == SWNodeType.refract)
            {
                processor = new SWShaderProcessRefraction();
            }
            else if (type == SWNodeType.reflect)
            {
                processor = new SWShaderProcessReflection();
            }

            else if (type == SWNodeType.coord)
            {
                processor = new SWShaderProcessCoord();
            }
            else if (type == SWNodeType.dummy)
            {
                processor = new SWShaderProcessDummy();
            }


            else if (type == SWNodeType.code)
            {
                processor = new SWShaderProcessCode();
            }
            return(processor);
        }
Beispiel #22
0
 public virtual void ProcessOutputSingle(SWShaderProcessBase processor, SWOutputSub item, bool b)
 {
 }