Пример #1
0
            public static SkinShaderMaterialReference FromMaterial(Material material)
            {
                var materialRef = new SkinShaderMaterialReference();

                materialRef.material            = material;
                materialRef.originalShader      = material.shader;
                materialRef.originalAlphaAdjust = material.GetFloat("_AlphaAdjust");
                materialRef.originalColorAlpha  = material.GetColor("_Color").a;
                materialRef.originalSpecColor   = material.GetColor("_SpecColor");
                return(materialRef);
            }
Пример #2
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);
        }