示例#1
0
 public DateTimeRange(DateTime Time, PrecisionType Precision = PrecisionType.Ticks)
 {
     this._Time = Time;
     this._Precision = Precision;
     this.WasUpdated = true;
     this._TimeStart = DateTime.MinValue;
     this._TimeEnd = DateTime.MaxValue;
 }
示例#2
0
 public static void GetShaderPrecisionFormat(ShaderType type, PrecisionType precisiontype, int[] range, int[] precision)
 {
     Delegates.glGetShaderPrecisionFormat(type, precisiontype, range, precision);
 }
示例#3
0
        // OBJECT TO TANGENT MATRIX
        static public string GenerateObjectToTangentMatrix(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            string normal   = GenerateVertexNormal(ref dataCollector, uniqueId, precision);
            string tangent  = GenerateVertexTangent(ref dataCollector, uniqueId, precision);
            string bitangen = GenerateVertexBitangent(ref dataCollector, uniqueId, precision);

            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3x3, ObjectToTangentStr, "float3x3( " + tangent + ", " + bitangen + ", " + normal + " )");
            return(ObjectToTangentStr);
        }
示例#4
0
 public unsafe partial void GetShaderPrecisionFormat([Flow(FlowDirection.In)] ARB shadertype, [Flow(FlowDirection.In)] PrecisionType precisiontype, [Count(Count = 2), Flow(FlowDirection.Out)] int *range, [Count(Count = 1), Flow(FlowDirection.Out)] int *precision);
示例#5
0
文件: QGL.cs 项目: bclnet/DroidNet
 public static void qglGetShaderPrecisionFormat(ShaderType shadertype, PrecisionType precisiontype, int *range, int *precision) => glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
示例#6
0
        // LIGHT DIRECTION WORLD
        static public string GenerateWorldLightDirection(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            dataCollector.AddToIncludes(uniqueId, Constants.UnityCgLibFuncs);
            string worldPos = GeneratorUtils.GenerateWorldPosition(ref dataCollector, uniqueId);

            dataCollector.AddLocalVariable(uniqueId, "#if defined(LIGHTMAP_ON) && UNITY_VERSION < 560 //aseld");
            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, WorldLightDirStr, "0");
            dataCollector.AddLocalVariable(uniqueId, "#else //aseld");
            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, WorldLightDirStr, (dataCollector.SafeNormalizeLightDir ? "Unity_SafeNormalize" : "normalize") + "( UnityWorldSpaceLightDir( " + worldPos + " ) )");
            dataCollector.AddLocalVariable(uniqueId, "#endif //aseld");
            return(WorldLightDirStr);
        }
示例#7
0
        // VIEW POS
        static public string GenerateViewPositionOnFrag(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                UnityEngine.Debug.LogWarning("View Pos not implemented on Templates");
            }

            string vertexName = GenerateVertexPositionOnFrag(ref dataCollector, uniqueId, precision);
            string value      = string.Format("UnityObjectToViewPos( {0} )", vertexName);

            dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT3, ViewPositionStr, value);
            return(ViewPositionStr);
        }
示例#8
0
        // VERTEX POSITION ON FRAG
        static public string GenerateVertexPositionOnFrag(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            dataCollector.AddToInput(uniqueId, SurfaceInputs.WORLD_POS);
            dataCollector.AddToIncludes(uniqueId, Constants.UnityShaderVariables);

            string value = "mul( unity_WorldToObject, float4( " + Constants.InputVarStr + ".worldPos , 1 ) )";

            dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT4, VertexPosition4Str, value);
            return(VertexPosition4Str);
        }
示例#9
0
        static public string GenerateScreenPositionNormalized(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true)
        {
            string stringPosVar = GenerateScreenPosition(ref dataCollector, uniqueId, precision, addInput);

            dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = {1} / {1}.w;", ScreenPositionNormalizedStr, stringPosVar));
            dataCollector.AddLocalVariable(uniqueId, ScreenPositionNormalizedStr + ".z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? " + ScreenPositionNormalizedStr + ".z : " + ScreenPositionNormalizedStr + ".z * 0.5 + 0.5;");

            return(ScreenPositionNormalizedStr);
        }
示例#10
0
        // SCREEN POSITION NORMALIZED
        static public string GenerateScreenPositionNormalizedForValue(string customVertexPos, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true)
        {
            string stringPosVar = GenerateScreenPositionForValue(customVertexPos, outputId, ref dataCollector, uniqueId, precision, addInput);
            string varName      = ScreenPositionNormalizedStr + uniqueId;

            dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = {1} / {1}.w;", varName, stringPosVar));
            dataCollector.AddLocalVariable(uniqueId, varName + ".z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? " + varName + ".z : " + varName + ".z * 0.5 + 0.5;");

            return(varName);
        }
示例#11
0
        static public string GenerateTangentToWorldMatrixPrecise(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetTangentToWorldMatrixPrecise(precision));
            }

            if (dataCollector.IsFragmentCategory)
            {
                dataCollector.ForceNormal = true;

                dataCollector.AddToInput(-1, SurfaceInputs.WORLD_NORMAL, precision);
                dataCollector.AddToInput(-1, SurfaceInputs.INTERNALDATA, addSemiColon: false);
            }

            string worldToTangent = GenerateWorldToTangentMatrix(ref dataCollector, uniqueId, precision);

            Add3x3InverseFunction(ref dataCollector, UIUtils.PrecisionWirePortToCgType(precision, WirePortDataType.FLOAT));
            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToWorldPreciseStr, string.Format(Inverse3x3Header, worldToTangent));
            return(TangentToWorldPreciseStr);
        }
示例#12
0
        // TANGENT TO WORLD
        static public string GenerateTangentToWorldMatrixFast(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetTangentToWorldMatrixFast(precision));
            }

            if (dataCollector.IsFragmentCategory)
            {
                dataCollector.ForceNormal = true;

                dataCollector.AddToInput(-1, SurfaceInputs.WORLD_NORMAL, precision);
                dataCollector.AddToInput(-1, SurfaceInputs.INTERNALDATA, addSemiColon: false);
            }

            string worldNormal    = GenerateWorldNormal(ref dataCollector, uniqueId);
            string worldTangent   = GenerateWorldTangent(ref dataCollector, uniqueId);
            string worldBitangent = GenerateWorldBitangent(ref dataCollector, uniqueId);

            string result = string.Format("float3x3({0}.x,{1}.x,{2}.x,{0}.y,{1}.y,{2}.y,{0}.z,{1}.z,{2}.z)", worldTangent, worldBitangent, worldNormal);

            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToWorldFastStr, result);
            return(TangentToWorldFastStr);
        }
示例#13
0
        // TANGENT TO OBJECT
        //static public string GenerateTangentToObjectMatrixFast( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
        //{
        //	string normal = GenerateVertexNormal( ref dataCollector, uniqueId, precision );
        //	string tangent = GenerateVertexTangent( ref dataCollector, uniqueId, precision );
        //	string bitangent = GenerateVertexBitangent( ref dataCollector, uniqueId, precision );

        //	string result = string.Format( "float3x3({0}.x,{1}.x,{2}.x,{0}.y,{1}.y,{2}.y,{0}.z,{1}.z,{2}.z)",tangent,bitangent,normal );
        //	dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToObjectFastStr, result );
        //	return TangentToObjectFastStr;
        //}

        //static public string GenerateTangentToObjectMatrixPrecise( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
        //{
        //	string objectToTangent = GenerateObjectToTangentMatrix( ref dataCollector, uniqueId, precision );
        //	Add3x3InverseFunction( ref dataCollector, UIUtils.PrecisionWirePortToCgType( precision, WirePortDataType.FLOAT ) );
        //	dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToObjectStr, string.Format( Inverse3x3Header, objectToTangent ) );
        //	return TangentToObjectStr;
        //}

        // WORLD TO TANGENT MATRIX
        static public string GenerateWorldToTangentMatrix(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetWorldToTangentMatrix(precision));
            }

            if (dataCollector.IsFragmentCategory)
            {
                dataCollector.ForceNormal = true;

                dataCollector.AddToInput(-1, SurfaceInputs.WORLD_NORMAL, precision);
                dataCollector.AddToInput(-1, SurfaceInputs.INTERNALDATA, addSemiColon: false);
            }

            string worldNormal    = GenerateWorldNormal(ref dataCollector, uniqueId);
            string worldTangent   = GenerateWorldTangent(ref dataCollector, uniqueId);
            string worldBitangent = GenerateWorldBitangent(ref dataCollector, uniqueId);

            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3x3, WorldToTangentStr, "float3x3( " + worldTangent + ", " + worldBitangent + ", " + worldNormal + " )");
            return(WorldToTangentStr);
        }
示例#14
0
        // WORLD NORMAL
        static public string GenerateWorldNormal(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precisionType, string normal, string outputId)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetWorldNormal(uniqueId, precisionType, normal, outputId));
            }

            string tanToWorld = GenerateTangentToWorldMatrixFast(ref dataCollector, uniqueId, precisionType);

            return(string.Format("mul({0},{1})", tanToWorld, normal));
        }
示例#15
0
        // WORLD TO TANGENT MATRIX
        static public string GenerateWorldToTangentMatrix(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            string worldNormal    = GenerateWorldNormal(ref dataCollector, uniqueId);
            string worldTangent   = GenerateWorldTangent(ref dataCollector, uniqueId);
            string worldBitangent = GenerateWorldBitangent(ref dataCollector, uniqueId);

            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3x3, WorldToTangentStr, "float3x3( " + worldTangent + ", " + worldBitangent + ", " + worldNormal + " )");
            return(WorldToTangentStr);
        }
示例#16
0
        // SCREEN POSITION
        static public string GenerateScreenPositionForValue(string customVertexPosition, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetScreenPosForValue(customVertexPosition, outputId));
            }


            string value            = GenerateVertexScreenPositionForValue(customVertexPosition, outputId, ref dataCollector, uniqueId, precision);
            string screenPosVarName = "screenPosition" + outputId;

            dataCollector.AddToInput(uniqueId, screenPosVarName, WirePortDataType.FLOAT4, precision);
            dataCollector.AddToVertexLocalVariables(uniqueId, Constants.VertexShaderOutputStr + "." + screenPosVarName + " = " + value + ";");

            string screenPosVarNameOnFrag = ScreenPositionStr + outputId;
            string globalResult           = Constants.InputVarStr + "." + screenPosVarName;

            dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = {1};", screenPosVarNameOnFrag, globalResult));
            return(screenPosVarNameOnFrag);
        }
示例#17
0
        public string[] OutlineFunctionBody(ref MasterNodeDataCollector dataCollector, bool instanced, bool isShadowCaster, string shaderName, string[] billboardInfo, ref TessellationOpHelper tessOpHelper, string target, PrecisionType precision)
        {
            List <string> body = new List <string>();

            body.Add(ModeTags[dataCollector.CustomOutlineSelectedAlpha]);
            if (!string.IsNullOrEmpty(m_grabPasses))
            {
                body.Add(m_grabPasses.Replace("\t\t", string.Empty));
            }

            if (m_zWriteMode != 0)
            {
                body.Add("ZWrite " + ZBufferOpHelper.ZWriteModeValues[m_zWriteMode]);
            }
            if (m_zTestMode != 0)
            {
                body.Add("ZTest " + ZBufferOpHelper.ZTestModeValues[m_zTestMode]);
            }

            body.Add("Cull " + m_cullMode);
            body.Add("CGPROGRAM");
            if (tessOpHelper.EnableTesselation)
            {
                body.Add("#include \"" + TessellationOpHelper.TessInclude + "\"");
                body.Add("#pragma target " + target);
            }
            else
            {
                body.Add("#pragma target 3.0");
            }
            bool   customOutline = dataCollector.UsingCustomOutlineColor || dataCollector.UsingCustomOutlineWidth || dataCollector.UsingCustomOutlineAlpha;
            int    outlineMode   = customOutline ? m_offsetMode : (m_mode == OutlineMode.VertexOffset ? 0 : 1);
            string extraOptions  = (customOutline ? m_customNoFog : m_noFog) ? "nofog " : string.Empty;

            if (dataCollector.CustomOutlineSelectedAlpha > 0)
            {
                extraOptions += ModePragma[dataCollector.CustomOutlineSelectedAlpha];
            }

            string surfConfig = string.Format(OutlineSurfaceConfig, extraOptions);

            if (tessOpHelper.EnableTesselation)
            {
                tessOpHelper.WriteToOptionalParams(ref surfConfig);
            }

            body.Add(surfConfig);
            if (!isShadowCaster)
            {
                AddMultibodyString(m_defines, body);
                AddMultibodyString(m_includes, body);
                AddMultibodyString(m_pragmas, body);
            }
            AddMultibodyString(m_standardAdditionalDirectives, body);
            //if( instanced )
            //{
            //	body.Add( OutlineInstancedHeader );
            //}

            if (customOutline)
            {
                if (isShadowCaster)
                {
                    for (int i = 0; i < InputList.Count; i++)
                    {
                        dataCollector.AddToInput(InputList[i].NodeId, InputList[i].PropertyName, !InputList[i].IsDirective);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(m_inputs))
                    {
                        body.Add(m_inputs.Trim('\t', '\n'));
                    }
                }

                if (!DirtyInput && !isShadowCaster)
                {
                    body.Add(OutlineBodyStructDefault);
                }

                if (!isShadowCaster)
                {
                    body.Add(OutlineBodyStructEnd);
                }
            }
            else if (!isShadowCaster)
            {
                body.Add(OutlineBodyStructBegin);
                body.Add(OutlineBodyStructDefault);
                body.Add(OutlineBodyStructEnd);
            }

            if (instanced)
            {
                //for( int i = 0; i < OutlineBodyInstancedBegin.Length; i++ )
                //{
                //	body.Add( ( i == 0 ) ? string.Format( OutlineBodyInstancedBegin[ i ], shaderName ) : OutlineBodyInstancedBegin[ i ] );
                //}

                //if( (object)billboardInfo != null )
                //{
                //	for( int j = 0; j < billboardInfo.Length; j++ )
                //	{
                //		body.Add( string.Format( BillboardInstructionFormat, billboardInfo[ j ] ) );
                //	}
                //}

                //switch( outlineMode )
                //{
                //	case 0: body.Add( string.Format( OutlineVertexOffsetMode, WidthVariableAccessInstanced ) ); break;
                //	case 1: body.Add( string.Format( OutlineVertexScaleMode, WidthVariableAccessInstanced ) ); break;
                //	case 2: body.Add( string.Format( OutlineVertexCustomMode, WidthVariableAccessInstanced ) ); break;
                //}
                //for( int i = 0; i < OutlineBodyInstancedEnd.Length; i++ )
                //{
                //	body.Add( OutlineBodyInstancedEnd[ i ] );
                //}

                //Instanced block name must differ from used on main shader so it won't throw a duplicate name error
                shaderName = shaderName + "Outline";
                bool openCBuffer = true;
                if (customOutline)
                {
                    if (isShadowCaster)
                    {
                        for (int i = 0; i < UniformList.Count; i++)
                        {
                            dataCollector.AddToUniforms(UniformList[i].NodeId, UniformList[i].PropertyName);
                        }

                        foreach (KeyValuePair <string, string> kvp in m_localFunctions)
                        {
                            dataCollector.AddFunction(kvp.Key, kvp.Value);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Uniforms))
                        {
                            body.Add(Uniforms.Trim('\t', '\n'));
                        }

                        openCBuffer = false;
                        body.Add(string.Format(IOUtils.InstancedPropertiesBegin, shaderName));
                        if (!string.IsNullOrEmpty(InstancedProperties))
                        {
                            body.Add(InstancedProperties.Trim('\t', '\n'));
                        }
                    }
                }

                if (openCBuffer)
                {
                    body.Add(string.Format(IOUtils.InstancedPropertiesBegin, shaderName));
                }

                if (!dataCollector.UsingCustomOutlineColor)
                {
                    body.Add(precision == PrecisionType.Float ? OutlineDefaultUniformColorInstanced.Replace("half", "float") : OutlineDefaultUniformColorInstanced);
                }

                if (!dataCollector.UsingCustomOutlineWidth)
                {
                    body.Add(precision == PrecisionType.Float ? OutlineDefaultUniformWidthInstanced.Replace("half", "float") : OutlineDefaultUniformWidthInstanced);
                }

                body.Add(IOUtils.InstancedPropertiesEnd);

                //Functions
                if (customOutline && !isShadowCaster)
                {
                    body.Add(Functions);
                }

                if (tessOpHelper.EnableTesselation && !isShadowCaster)
                {
                    body.Add(tessOpHelper.Uniforms().TrimStart('\t'));
                    body.Add(tessOpHelper.GetCurrentTessellationFunction(ref dataCollector).Trim('\t', '\n') + "\n");
                }

                if (tessOpHelper.EnableTesselation)
                {
                    body.Add(OutlineTessVertexHeader);
                }
                else
                {
                    body.Add(OutlineDefaultVertexHeader);
                    body.Add(OutlineDefaultVertexOutputDeclaration);
                }

                if (customOutline)
                {
                    if (!string.IsNullOrEmpty(VertexData))
                    {
                        body.Add("\t" + VertexData.Trim('\t', '\n'));
                    }
                }

                if ((object)billboardInfo != null)
                {
                    for (int j = 0; j < billboardInfo.Length; j++)
                    {
                        body.Add(string.Format(BillboardInstructionFormat, billboardInfo[j]));
                    }
                }

                switch (outlineMode)
                {
                case 0: body.Add(string.Format(OutlineVertexOffsetMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyNameInstanced)); break;

                case 1: body.Add(string.Format(OutlineVertexScaleMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyNameInstanced)); break;

                case 2: body.Add(string.Format(OutlineVertexCustomMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyNameInstanced)); break;
                }

                for (int i = 0; i < OutlineBodyDefaultSurfBegin.Length; i++)
                {
                    body.Add(OutlineBodyDefaultSurfBegin[i]);
                }
                if (dataCollector.UsingCustomOutlineColor || dataCollector.CustomOutlineSelectedAlpha > 0)
                {
                    body.Add("\t" + Instructions.Trim('\t', '\n'));
                }
                else
                {
                    for (int i = 0; i < OutlineSurfBodyInstanced.Length; i++)
                    {
                        body.Add(OutlineSurfBodyInstanced[i]);
                    }
                }

                for (int i = 0; i < OutlineBodyDefaultSurfEnd.Length; i++)
                {
                    body.Add(OutlineBodyDefaultSurfEnd[i]);
                }
            }
            else
            {
                if (customOutline)
                {
                    if (isShadowCaster)
                    {
                        for (int i = 0; i < UniformList.Count; i++)
                        {
                            dataCollector.AddToUniforms(UniformList[i].NodeId, UniformList[i].PropertyName);
                        }

                        foreach (KeyValuePair <string, string> kvp in m_localFunctions)
                        {
                            dataCollector.AddFunction(kvp.Key, kvp.Value);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Uniforms))
                        {
                            body.Add(Uniforms.Trim('\t', '\n'));
                        }
                    }
                }

                if (!dataCollector.UsingCustomOutlineColor)
                {
                    body.Add(precision == PrecisionType.Float ? OutlineDefaultUniformColor.Replace("half", "float") : OutlineDefaultUniformColor);
                }

                if (!dataCollector.UsingCustomOutlineWidth)
                {
                    body.Add(precision == PrecisionType.Float ? OutlineDefaultUniformWidth.Replace("half", "float") : OutlineDefaultUniformWidth);
                }

                //Functions
                if (customOutline && !isShadowCaster)
                {
                    body.Add(Functions);
                }

                if (tessOpHelper.EnableTesselation && !isShadowCaster)
                {
                    body.Add(tessOpHelper.Uniforms().TrimStart('\t'));
                    body.Add(tessOpHelper.GetCurrentTessellationFunction(ref dataCollector).Trim('\t', '\n') + "\n");
                }

                if (tessOpHelper.EnableTesselation)
                {
                    body.Add(OutlineTessVertexHeader);
                }
                else
                {
                    body.Add(OutlineDefaultVertexHeader);
                    body.Add(OutlineDefaultVertexOutputDeclaration);
                }

                if (customOutline)
                {
                    if (!string.IsNullOrEmpty(VertexData))
                    {
                        body.Add("\t" + VertexData.Trim('\t', '\n'));
                    }
                }

                if ((object)billboardInfo != null)
                {
                    for (int j = 0; j < billboardInfo.Length; j++)
                    {
                        body.Add(string.Format(BillboardInstructionFormat, billboardInfo[j]));
                    }
                }

                switch (outlineMode)
                {
                case 0: body.Add(string.Format(OutlineVertexOffsetMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName)); break;

                case 1: body.Add(string.Format(OutlineVertexScaleMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName)); break;

                case 2: body.Add(string.Format(OutlineVertexCustomMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName)); break;
                }
                for (int i = 0; i < OutlineBodyDefaultSurfBegin.Length; i++)
                {
                    body.Add(OutlineBodyDefaultSurfBegin[i]);
                }
                if (dataCollector.UsingCustomOutlineColor || dataCollector.CustomOutlineSelectedAlpha > 0)
                {
                    body.Add("\t" + Instructions.Trim('\t', '\n'));
                }
                else
                {
                    for (int i = 0; i < OutlineSurfBody.Length; i++)
                    {
                        body.Add(OutlineSurfBody[i]);
                    }
                }

                for (int i = 0; i < OutlineBodyDefaultSurfEnd.Length; i++)
                {
                    body.Add(OutlineBodyDefaultSurfEnd[i]);
                }
            }

            string[] bodyArr = body.ToArray();
            body.Clear();
            body = null;
            return(bodyArr);
        }
示例#18
0
        static public string GenerateScreenPosition(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true)
        {
            if (dataCollector.UsingCustomScreenPos && dataCollector.IsFragmentCategory)
            {
                string value = GenerateVertexScreenPosition(ref dataCollector, uniqueId, precision);
                dataCollector.AddToInput(uniqueId, "screenPosition", WirePortDataType.FLOAT4, precision);
                dataCollector.AddToVertexLocalVariables(uniqueId, Constants.VertexShaderOutputStr + ".screenPosition = " + value + ";");

                string globalResult = Constants.InputVarStr + ".screenPosition";
                dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = {1};", ScreenPositionStr, globalResult));
                return(ScreenPositionStr);
            }
            else
            {
                if (!dataCollector.IsFragmentCategory)
                {
                    return(GenerateVertexScreenPosition(ref dataCollector, uniqueId, precision));
                }

                if (dataCollector.IsTemplate)
                {
                    return(dataCollector.TemplateDataCollectorInstance.GetScreenPos());
                }
            }


            if (addInput)
            {
                dataCollector.AddToInput(uniqueId, SurfaceInputs.SCREEN_POS, precision);
            }

            string result = Constants.InputVarStr + ".screenPos";

            dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = float4( {1}.xyz , {1}.w + 0.00000000001 );", ScreenPositionStr, result));

            return(ScreenPositionStr);
        }
示例#19
0
        // CLIP POSITION ON FRAG
        static public string GenerateClipPositionOnFrag(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetClipPos());
            }

            string vertexName = GenerateVertexPositionOnFrag(ref dataCollector, uniqueId, precision);
            string value      = string.Format("ComputeScreenPos( UnityObjectToClipPos( {0} ) )", vertexName);

            dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT4, ClipPositionStr, value);
            return(ClipPositionStr);
        }
示例#20
0
        // GRAB SCREEN POSITION
        static public string GenerateGrabScreenPosition(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true, string customScreenPos = null)
        {
            string screenPos = string.Empty;

            if (string.IsNullOrEmpty(customScreenPos))
            {
                screenPos = GenerateScreenPosition(ref dataCollector, uniqueId, precision, addInput);
            }
            else
            {
                screenPos = customScreenPos;
            }

            string computeBody = string.Empty;

            IOUtils.AddFunctionHeader(ref computeBody, GrabFunctionHeader);
            foreach (string line in GrabFunctionBody)
            {
                IOUtils.AddFunctionLine(ref computeBody, line);
            }
            IOUtils.CloseFunctionBody(ref computeBody);
            string functionResult = dataCollector.AddFunctions(GrabFunctionCall, computeBody, screenPos);

            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT4, GrabScreenPositionStr, functionResult);
            return(GrabScreenPositionStr);
        }
示例#21
0
        // SCREEN DEPTH
        static public string GenerateScreenDepthOnFrag(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                UnityEngine.Debug.LogWarning("Screen Depth not implemented on Templates");
            }

            string viewPos = GenerateViewPositionOnFrag(ref dataCollector, uniqueId, precision);
            string value   = string.Format("-{0}.z", viewPos);

            dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT, ScreenDepthStr, value);
            return(ScreenDepthStr);
        }
示例#22
0
        // GRAB SCREEN POSITION NORMALIZED
        static public string GenerateGrabScreenPositionNormalized(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true, string customScreenPos = null)
        {
            string stringPosVar = GenerateGrabScreenPosition(ref dataCollector, uniqueId, precision, addInput, customScreenPos);

            dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = {1} / {1}.w;", GrabScreenPositionNormalizedStr, stringPosVar));
            return(GrabScreenPositionNormalizedStr);
        }
示例#23
0
 // LIGHT DIRECTION Object
 static public string GenerateObjectLightDirection(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, string vertexPos)
 {
     dataCollector.AddToIncludes(uniqueId, Constants.UnityCgLibFuncs);
     dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, ObjectLightDirStr, "normalize( ObjSpaceLightDir( " + vertexPos + " ) )");
     return(ObjectLightDirStr);
 }
示例#24
0
        // SCREEN POSITION ON VERT
        static public string GenerateVertexScreenPositionForValue(string customVertexPosition, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetScreenPosForValue(customVertexPosition, outputId));
            }

            string screenPosVarName = ScreenPositionStr + outputId;
            string value            = string.Format("ComputeScreenPos( UnityObjectToClipPos( {0}.vertex ) )", Constants.VertexShaderInputStr);

            dataCollector.AddToVertexLocalVariables(uniqueId, precision, WirePortDataType.FLOAT4, screenPosVarName, value);
            return(screenPosVarName);
        }
 public static unsafe void GetShaderPrecisionFormat(this ArbES2Compatibility thisApi, [Flow(FlowDirection.In)] ShaderType shadertype, [Flow(FlowDirection.In)] PrecisionType precisiontype, [Count(Count = 2), Flow(FlowDirection.Out)] Span <int> range, [Count(Count = 1), Flow(FlowDirection.Out)] Span <int> precision)
 {
     // SpanOverloader
     thisApi.GetShaderPrecisionFormat(shadertype, precisiontype, out range.GetPinnableReference(), out precision.GetPinnableReference());
 }
示例#26
0
        static public string GenerateVertexScreenPosition(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetScreenPos());
            }

            string value = string.Format("ComputeScreenPos( UnityObjectToClipPos( {0}.vertex ) )", Constants.VertexShaderInputStr);

            dataCollector.AddToVertexLocalVariables(uniqueId, precision, WirePortDataType.FLOAT4, ScreenPositionStr, value);
            return(ScreenPositionStr);
        }
示例#27
0
 public partial void GetShaderPrecisionFormat([Flow(FlowDirection.In)] ShaderType shadertype, [Flow(FlowDirection.In)] PrecisionType precisiontype, [Count(Count = 2), Flow(FlowDirection.Out)] out int range, [Count(Count = 1), Flow(FlowDirection.Out)] out int precision);
示例#28
0
        // VERTEX NORMAL
        static public string GenerateVertexNormal(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetVertexNormal(UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision));
            }

            string value = Constants.VertexShaderInputStr + ".normal.xyz";

            if (dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug)
            {
                GenerateWorldNormal(ref dataCollector, uniqueId);
                dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT3, VertexNormalStr, "mul( unity_WorldToObject, float4( " + WorldNormalStr + ", 0 ) )");
            }
            else
            {
                dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, VertexNormalStr, value);
            }
            return(VertexNormalStr);
        }
示例#29
0
        // TANGENT TO OBJECT
        static public string GenerateTangentToObjectMatrix(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            string normal    = GenerateVertexNormal(ref dataCollector, uniqueId, precision);
            string tangent   = GenerateVertexTangent(ref dataCollector, uniqueId, precision);
            string bitangent = GenerateVertexBitangent(ref dataCollector, uniqueId, precision);

            string.Format("{0}.x,{1}.x,{2}.x,{0}.y,{1}.y,{2}.y,{0}.z,{1}.z,{2}.z");
            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToWorldStr, "float3x3( " + tangent + ", " + bitangent + ", " + normal + " )");
            return(TangentToObjectStr);
        }
示例#30
0
        // VERTEX TANGENT SIGN
        static public string GenerateVertexTangentSign(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetTangentSign(UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision));
            }

            string value = Constants.VertexShaderInputStr + ".tangent.w";

            if (dataCollector.IsFragmentCategory)
            {
                dataCollector.AddToInput(uniqueId, VertexTangentSignStr, WirePortDataType.FLOAT, PrecisionType.Half);
                dataCollector.AddToVertexLocalVariables(uniqueId, Constants.VertexShaderOutputStr + "." + VertexTangentSignStr + " = " + Constants.VertexShaderInputStr + ".tangent.w;");
                return(Constants.InputVarStr + "." + VertexTangentSignStr);
            }
            else
            {
                dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT, VertexTangentSignStr, value);
            }
            return(VertexTangentSignStr);
        }
示例#31
0
 public static void ModifiedTimeRange(DateTime Time, PrecisionType Precision, out DateTime ModifiedTimeStart, out DateTime ModifiedTimeEnd)
 {
     switch (Precision)
     {
         case PrecisionType.Ticks:
             ModifiedTimeEnd = ModifiedTimeStart = new DateTime(Time.Ticks);
             break;
         case PrecisionType.Seconds:
             ModifiedTimeStart = new DateTime(Time.Year, Time.Month, Time.Day, Time.Hour, Time.Minute, Time.Second + 0);
             ModifiedTimeEnd = new DateTime(Time.Year, Time.Month, Time.Day, Time.Hour, Time.Minute, Time.Second + 1);
             break;
         case PrecisionType.Minutes:
             ModifiedTimeStart = new DateTime(Time.Year, Time.Month, Time.Day, Time.Hour, Time.Minute + 0, 0);
             ModifiedTimeEnd = new DateTime(Time.Year, Time.Month, Time.Day, Time.Hour, Time.Minute + 1, 0);
             break;
         case PrecisionType.Hours:
             ModifiedTimeStart = new DateTime(Time.Year, Time.Month, Time.Day, Time.Hour + 0, 0, 0);
             ModifiedTimeEnd = new DateTime(Time.Year, Time.Month, Time.Day, Time.Hour + 1, 0, 0);
             break;
         case PrecisionType.Days:
             ModifiedTimeStart = new DateTime(Time.Year, Time.Month, Time.Day + 0);
             ModifiedTimeEnd = new DateTime(Time.Year, Time.Month, Time.Day + 1);
             break;
         case PrecisionType.Months:
             ModifiedTimeStart = new DateTime(Time.Year, Time.Month + 0, 0);
             ModifiedTimeEnd = new DateTime(Time.Year, Time.Month + 1, 0);
             break;
         case PrecisionType.Years:
             ModifiedTimeStart = new DateTime(Time.Year + 0, 0, 0);
             ModifiedTimeEnd = new DateTime(Time.Year + 1, 0, 0);
             break;
         default:
             ModifiedTimeStart = DateTime.MinValue;
             ModifiedTimeEnd = DateTime.MaxValue;
             break;
     }
 }
示例#32
0
        // VERTEX BITANGENT
        static public string GenerateVertexBitangent(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetVertexBitangent(UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision));
            }

            if (dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug)
            {
                GenerateWorldBitangent(ref dataCollector, uniqueId);
                dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT3, VertexBitangentStr, "mul( unity_WorldToObject, float4( " + WorldBitangentStr + ", 0 ) )");
            }
            else
            {
                GenerateVertexNormal(ref dataCollector, uniqueId, precision);
                GenerateVertexTangent(ref dataCollector, uniqueId, precision);
                dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, VertexBitangentStr, "cross( " + VertexNormalStr + ", " + VertexTangentStr + ") * " + Constants.VertexShaderInputStr + ".tangent.w * unity_WorldTransformParams.w");
            }
            return(VertexBitangentStr);
        }
示例#33
0
 static DateTimeRange FromUnixTimestamp(long UnixTimestamp, PrecisionType Precision = PrecisionType.Seconds)
 {
     return new DateTimeRange(ConvertFromUnixTimestamp(UnixTimestamp), Precision);
 }
示例#34
0
 public abstract unsafe void GetShaderPrecisionFormat([Flow(FlowDirection.In)] ShaderType shadertype, [Flow(FlowDirection.In)] PrecisionType precisiontype, [Count(Count = 2), Flow(FlowDirection.Out)] int *range, [Count(Count = 1), Flow(FlowDirection.Out)] int *precision);