Exemplo n.º 1
0
        public bool Prepare()
        {
            _materialRefs = new List <SkinShaderMaterialSnapshot>();

            foreach (var material in GetMaterialsToHide())
            {
                var materialInfo = SkinShaderMaterialSnapshot.FromMaterial(material);

                Shader shader;
                if (!ReplacementShaders.ShadersMap.TryGetValue(material.shader.name, out shader))
                {
                    SuperController.LogError("Missing replacement shader: '" + material.shader.name + $"' ({material.name} will not be hidden)");
                }

                if (shader != null)
                {
                    material.shader = shader;
                    materialInfo.alphaAdjustSupport = material.HasProperty("_AlphaAdjust");
                    materialInfo.alphaCutoffSupport = material.HasProperty("_Cutoff");
                    materialInfo.specColorSupport   = material.HasProperty("_SpecColor");
                }
                else
                {
                    materialInfo.alphaAdjustSupport = materialInfo.originalAlphaAdjustSupport;
                    materialInfo.alphaCutoffSupport = materialInfo.originalAlphaCutoffSupport;
                    materialInfo.specColorSupport   = materialInfo.originalSpecColorSupport;
                }

                _materialRefs.Add(materialInfo);
            }

            // This is a hack to force a refresh of the shaders cache
            _skin.BroadcastMessage("OnApplicationFocus", true);
            return(true);
        }
Exemplo n.º 2
0
        public bool Prepare()
        {
            _materialRefs = new List <SkinShaderMaterialSnapshot>();

            foreach (var material in KnownMaterials.GetMaterialsToHide(_skin))
            {
                var materialInfo = SkinShaderMaterialSnapshot.FromMaterial(material);

                Shader shader;
                if (!ReplacementShaders.ShadersMap.TryGetValue(material.shader.name, out shader))
                {
                    SuperController.LogError("Missing replacement shader: '" + material.shader.name + "'");
                }

                if (shader != null)
                {
                    material.shader = shader;
                }

                _materialRefs.Add(materialInfo);
            }

            // This is a hack to force a refresh of the shaders cache
            _skin.BroadcastMessage("OnApplicationFocus", true);
            return(true);
        }
Exemplo n.º 3
0
        public void Restore()
        {
            foreach (var material in _materialRefs)
            {
                material.material.shader = material.originalShader;
            }

            _materialRefs = null;

            // This is a hack to force a refresh of the shaders cache
            _skin.BroadcastMessage("OnApplicationFocus", true);
        }
Exemplo n.º 4
0
        public int Configure(DAZSkinV2 skin)
        {
            _skin         = skin;
            _materialRefs = new List <SkinShaderMaterialReference>();

            foreach (var material in GetMaterialsToHide(skin))
            {
#if (IMPROVED_POV)
                if (material == null)
                {
                    throw new InvalidOperationException("Attempts to apply the shader strategy on a destroyed material.");
                }

                if (material.GetInt(SkinShaderMaterialReference.ImprovedPovEnabledShaderKey) == 1)
                {
                    throw new InvalidOperationException("Attempts to apply the shader strategy on a skin that already has the plugin enabled (shader key).");
                }
#endif

                var materialInfo = SkinShaderMaterialReference.FromMaterial(material);

                Shader shader;
                if (!ReplacementShaders.TryGetValue(material.shader.name, out shader))
                {
                    SuperController.LogError("Missing replacement shader: '" + material.shader.name + "'");
                }

                if (shader != null)
                {
                    material.shader = shader;
                }

                _materialRefs.Add(materialInfo);
            }

            // This is a hack to force a refresh of the shaders cache
            skin.BroadcastMessage("OnApplicationFocus", true);
            return(HandlerConfigurationResult.Success);
        }