Beispiel #1
0
        // TODO : split this function into buildActiveFields and buildHLSLTypeDeclaration functions
        public static void Generate(
            ShaderGenerator codeResult,
            ShaderGenerator graphInputsResult,
            ShaderGraphRequirements graphRequirements,
            List <string> passRequiredFields,            // fields the pass requires
            CoordinateSpace preferedCoordinateSpace,
            HashSet <string> activeFields)
        {
            if (preferedCoordinateSpace == CoordinateSpace.Tangent)
            {
                preferedCoordinateSpace = CoordinateSpace.World;
            }

            // build initial requirements
            AddActiveFieldsFromGraphRequirements(activeFields, graphRequirements);
            if (passRequiredFields != null)
            {
                foreach (var requiredField in passRequiredFields)
                {
                    activeFields.Add(requiredField);
                }
            }

            // propagate requirements using dependencies
            {
                ShaderSpliceUtil.ApplyDependencies(
                    activeFields,
                    new List <Dependency[]>()
                {
                    FragInputs.dependencies,
                    VaryingsMeshToPS.standardDependencies,
                    SurfaceDescriptionInputs.dependencies,
                });
            }

            // generate code based on requirements
            ShaderSpliceUtil.BuildType(typeof(AttributesMesh), activeFields, codeResult);
            ShaderSpliceUtil.BuildType(typeof(VaryingsMeshToPS), activeFields, codeResult);
            ShaderSpliceUtil.BuildType(typeof(VaryingsMeshToDS), activeFields, codeResult);
            ShaderSpliceUtil.BuildPackedType(typeof(VaryingsMeshToPS), activeFields, codeResult);
            ShaderSpliceUtil.BuildPackedType(typeof(VaryingsMeshToDS), activeFields, codeResult);
            ShaderSpliceUtil.BuildType(typeof(SurfaceDescriptionInputs), activeFields, graphInputsResult);
        }
Beispiel #2
0
        public static void Generate(
            ShaderGenerator codeResult,
            HashSet <string> activeFields)
        {
            // propagate requirements using dependencies
            {
                ShaderSpliceUtil.ApplyDependencies(
                    activeFields,
                    new List <Dependency[]>()
                {
                    FragInputs.dependencies,
                    VaryingsMeshToPS.standardDependencies,
                    SurfaceDescriptionInputs.dependencies,
                    VertexDescriptionInputs.dependencies
                });
            }

            // generate code based on requirements
            ShaderSpliceUtil.BuildType(typeof(AttributesMesh), activeFields, codeResult);
            ShaderSpliceUtil.BuildType(typeof(VaryingsMeshToPS), activeFields, codeResult);
            ShaderSpliceUtil.BuildType(typeof(VaryingsMeshToDS), activeFields, codeResult);
            ShaderSpliceUtil.BuildPackedType(typeof(VaryingsMeshToPS), activeFields, codeResult);
            ShaderSpliceUtil.BuildPackedType(typeof(VaryingsMeshToDS), activeFields, codeResult);
        }