Beispiel #1
0
        private AnimatedEffect _CreateUnlitEffect(MaterialContentConverter srcMaterial)
        {
            var ueffect = new UnlitEffect(this.Device);

            srcMaterial.CopyToEffect(ueffect.BaseColorMap, "BaseColor", XNAV4.One);
            srcMaterial.CopyToEffect(ueffect.EmissiveMap, "Emissive", XNAV3.Zero);
            srcMaterial.CopyToEffect(ueffect.OcclusionMap, "Occlusion", 0);
            if (ueffect.OcclusionMap.Texture == null)
            {
                ueffect.OcclusionMap.Scale = 0;
            }

            return(ueffect);
        }
Beispiel #2
0
        private AnimatedEffect _CreatePBREffect(MaterialContentConverter srcMaterial)
        {
            if (srcMaterial.PreferredShading == "Unlit")
            {
                throw new ArgumentException(nameof(srcMaterial));
            }

            PBREffect effect;

            if (srcMaterial.PreferredShading == "SpecularGlossiness")
            {
                var xeffect = new PBRSpecularGlossinessEffect(this.Device);
                effect = xeffect;

                srcMaterial.CopyToEffect(xeffect.DiffuseMap, "Diffuse", XNAV4.One);
                srcMaterial.CopyToEffect(xeffect.SpecularGlossinessMap, "SpecularGlossiness", XNAV4.Zero);
            }
            else
            {
                var xeffect = new PBRMetallicRoughnessEffect(this.Device);
                effect = xeffect;

                srcMaterial.CopyToEffect(xeffect.BaseColorMap, "BaseColor", XNAV4.One);
                srcMaterial.CopyToEffect(xeffect.MetalRoughnessMap, "MetallicRoughness", XNAV2.One);
            }

            srcMaterial.CopyToEffect(effect.NormalMap, "Normal", 1);
            srcMaterial.CopyToEffect(effect.EmissiveMap, "Emissive", XNAV3.Zero);
            srcMaterial.CopyToEffect(effect.OcclusionMap, "Occlusion", 0);
            if (effect.OcclusionMap.Texture == null)
            {
                effect.OcclusionMap.Scale = 0;
            }

            return(effect);
        }