Esempio n. 1
0
        /// <summary>
        /// Set the RenderEnvironment for usage
        /// </summary>
        /// <param name="environment"></param>
        /// <param name="usage"></param>
        public void SetBackground(RenderEnvironment environment, RenderEnvironment.Usage usage)
        {
            switch (usage)
            {
            case RenderEnvironment.Usage.Background:
                if (environment?.RenderHash == _cqBackground.BackgroundEnvironment?.RenderHash)
                {
                    return;
                }
                _cqBackground.Xml = "";
                var xmlenv = (environment?.TopLevelParent as Materials.ICyclesMaterial);
                if (xmlenv?.MaterialType == RhinoCyclesCore.ShaderBody.CyclesMaterial.XmlEnvironment || xmlenv?.MaterialType == RhinoCyclesCore.ShaderBody.CyclesMaterial.SimpleNoiseEnvironment)
                {
                    xmlenv.BakeParameters();
                    _cqBackground.Xml = xmlenv.MaterialXml;
                }
                _cqBackground.BackgroundEnvironment = environment;
                if (environment != null)
                {
                    var s    = environment.GetParameter("background-projection") as IConvertible;
                    var proj = Convert.ToString(s, CultureInfo.InvariantCulture);
                    _cqBackground.PlanarProjection = proj.Equals("planar");
                }
                else
                {
                    _cqBackground.PlanarProjection = false;
                }
                break;

            case RenderEnvironment.Usage.Skylighting:
                _cqBackground.SkylightEnvironment = environment;
                break;

            case RenderEnvironment.Usage.ReflectionAndRefraction:
                _cqBackground.ReflectionEnvironment = environment;
                break;
            }
            _cqBackground.Modified = true;
        }
Esempio n. 2
0
        static private TextureEnvironmentMappingMode get_environment_mapping(RenderEnvironment rm, RenderTexture renderTexture)
        {
            var s    = rm.GetParameter("background-projection") as IConvertible;
            var proj = Convert.ToString(s, CultureInfo.InvariantCulture);

            switch (proj)
            {
            case "automatic":
                return(renderTexture.GetEnvironmentMappingMode());

            case "box":
                return(TextureEnvironmentMappingMode.Box);

            case "cubemap":
                return(TextureEnvironmentMappingMode.Cube);

            case "emap":
                return(TextureEnvironmentMappingMode.EnvironmentMap);

            case "horizontal-cross-cubemap":
                return(TextureEnvironmentMappingMode.HorizontalCrossCube);

            case "vertical-cross-cubemap":
                return(TextureEnvironmentMappingMode.VerticalCrossCube);

            case "hemispherical":
                return(TextureEnvironmentMappingMode.Hemispherical);

            case "lightprobe":
                return(TextureEnvironmentMappingMode.LightProbe);

            case "spherical":
                return(TextureEnvironmentMappingMode.Spherical);

            default:                     // default (non existing planar)
                return((TextureEnvironmentMappingMode)4);
            }
        }