Ejemplo n.º 1
0
        /// <inheritdoc />
        public override void UpdateVertexBuilder(ParticleVertexBuilder vertexBuilder)
        {
            base.UpdateVertexBuilder(vertexBuilder);

            // TODO Part of the graphics improvement XK-3052
            //  Ideally, the whole code here should be extracting information from the ShaderBytecode instead as it is quite unreliable and hacky to extract semantics with text matching.
            //  The arguments we need are in the GenericArguments, which is again just an array of strings
            //  We could search it element by element, but in the end getting the entire string and searching it instead is the same
            {
                // 95% of all particle effects will require both texture coordinates and vertex color, so we can add it to the layout here
                // Possible optimization can be detecting material changes
                vertexBuilder.AddVertexElement(ParticleVertexElements.Color);
                vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[0]);
            } // Part of the graphics improvement XK-3052
        }
Ejemplo n.º 2
0
        public override void UpdateVertexBuilder(ParticleVertexBuilder vertexBuilder)
        {
            base.UpdateVertexBuilder(vertexBuilder);

            var code = shaderBaseColor != null?shaderBaseColor.ToString() : null;

            if (code != null && code.Contains("COLOR0"))
            {
                vertexBuilder.AddVertexElement(ParticleVertexElements.Color);
            }

            //  There are two UV builders, building texCoord0 and texCoord1
            //  Which set is referenced can be set by the user in the IComputeColor tree
            vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[0]);

            vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[1]);
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public override void UpdateVertexBuilder(ParticleVertexBuilder vertexBuilder)
        {
            base.UpdateVertexBuilder(vertexBuilder);

            // TODO Part of the graphics improvement XK-3052
            //  Ideally, the whole code here should be extracting information from the ShaderBytecode instead as it is quite unreliable and hacky to extract semantics with text matching.
            //  The arguments we need are in the GenericArguments, which is again just an array of strings
            //  We could search it element by element, but in the end getting the entire string and searching it instead is the same
            {
                var code = shaderSource?.ToString();

                if (code?.Contains("COLOR0") ?? false)
                {
                    vertexBuilder.AddVertexElement(ParticleVertexElements.Color);
                }

                var coordIndex = code?.IndexOf("TEXCOORD", 0, StringComparison.Ordinal) ?? -1;

                if (coordIndex < 0)
                {
                    // If there is no explicit texture coordinate usage, but we can still force it
                    if (ForceTexCoords)
                    {
                        vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[0]);
                    }
                }

                while (coordIndex >= 0)
                {
                    var semanticIndex = 0;
                    var subStr        = code.Substring(coordIndex + 8);

                    if (int.TryParse(Regex.Match(subStr, @"\d+").Value, out semanticIndex))
                    {
                        semanticIndex = (semanticIndex < 0) ? 0 : semanticIndex;
                        semanticIndex = (semanticIndex > 15) ? 15 : semanticIndex;

                        vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[semanticIndex]);
                    }

                    coordIndex = code.IndexOf("TEXCOORD", coordIndex + 1);
                }
            } // Part of the graphics improvement XK-3052
        }
        public override void UpdateVertexBuilder(ParticleVertexBuilder vertexBuilder)
        {
            base.UpdateVertexBuilder(vertexBuilder);

            var code = shaderBaseColor != null ? shaderBaseColor.ToString() : null;

            if (code != null && code.Contains("COLOR0"))
            {
                vertexBuilder.AddVertexElement(ParticleVertexElements.Color);
            }

            //  There are two UV builders, building texCoord0 and texCoord1
            //  Which set is referenced can be set by the user in the IComputeColor tree
            vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[0]);

            vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[1]);
        }
        /// <inheritdoc />
        public override void UpdateVertexBuilder(ParticleVertexBuilder vertexBuilder)
        {
            base.UpdateVertexBuilder(vertexBuilder);

            // TODO Part of the graphics improvement XK-3052
            //  Ideally, the whole code here should be extracting information from the ShaderBytecode instead as it is quite unreliable and hacky to extract semantics with text matching.
            //  The arguments we need are in the GenericArguments, which is again just an array of strings
            //  We could search it element by element, but in the end getting the entire string and searching it instead is the same
            {
                // 95% of all particle effects will require both texture coordinates and vertex color, so we can add it to the layout here
                // Possible optimization can be detecting material changes
                vertexBuilder.AddVertexElement(ParticleVertexElements.Color);
                vertexBuilder.AddVertexElement(ParticleVertexElements.TexCoord[0]);
            } // Part of the graphics improvement XK-3052

        }