Beispiel #1
0
        internal CclShader RecreateMaterialShader(CyclesShader shader, CclShader existing)
        {
            CclShader sh = null;

            if (shader.DisplayMaterial && shader.ValidDisplayMaterial)
            {
                sh = RecreateCyclesShaderFromRhinoV6BasicMat(shader, existing);
            }
            else
            {
                switch (shader.Front.CyclesMaterialType)
                {
                case ShaderBody.CyclesMaterial.Xml:
                case ShaderBody.CyclesMaterial.FlakedCarPaint:
                    sh = RecreateCyclesShaderFromXml(shader.Front, existing);
                    break;

                default:
                    sh = RecreateCyclesShaderFromRhinoV6BasicMat(shader, existing);
                    break;
                }
            }

            return(sh);
        }
Beispiel #2
0
 public XmlReadState(Scene scene, Transform transform, bool smooth, Shader shader, string basePath, float dicingRate, bool silent)
 {
     Scene = scene;
     Transform = transform;
     Smooth = smooth;
     Shader = shader;
     BasePath = basePath;
     DicingRate = dicingRate;
     Silent = silent;
 }
Beispiel #3
0
        internal CclShader CreateCyclesShaderFromXml(ShaderBody shader)
        {
            var sh = new CclShader(Client, CclShader.ShaderType.Material)
            {
                UseMis = true,
                UseTransparentShadow = true,
                HeterogeneousVolume  = false,
                Name = shader.Name ?? $"V6 Basic Material {shader.Id}"
            };

            CclShader.ShaderFromXml(ref sh, shader.Crm.MaterialXml);

            return(sh);
        }
Beispiel #4
0
        public static Shader create_some_setup_shader()
        {
            var some_setup = new Shader(Client, Shader.ShaderType.Material)
            {
                Name = "some_setup ",
                UseMis = false,
                UseTransparentShadow = true,
                HeterogeneousVolume = false
            };

            var brick_texture = new BrickTexture();
            brick_texture.ins.Vector.Value = new float4(0.000f, 0.000f, 0.000f);
            brick_texture.ins.Color1.Value = new float4(0.800f, 0.800f, 0.800f);
            brick_texture.ins.Color2.Value = new float4(0.200f, 0.200f, 0.200f);
            brick_texture.ins.Mortar.Value = new float4(0.000f, 0.000f, 0.000f);
            brick_texture.ins.Scale.Value = 1.000f;
            brick_texture.ins.MortarSize.Value = 0.020f;
            brick_texture.ins.Bias.Value = 0.000f;
            brick_texture.ins.BrickWidth.Value = 0.500f;
            brick_texture.ins.RowHeight.Value = 0.250f;

            var checker_texture = new CheckerTexture();
            checker_texture.ins.Vector.Value = new float4(0.000f, 0.000f, 0.000f);
            checker_texture.ins.Color1.Value = new float4(0.000f, 0.004f, 0.800f);
            checker_texture.ins.Color2.Value = new float4(0.200f, 0.000f, 0.007f);
            checker_texture.ins.Scale.Value = 5.000f;

            var diffuse_bsdf = new DiffuseBsdfNode();
            diffuse_bsdf.ins.Color.Value = new float4(0.800f, 0.800f, 0.800f);
            diffuse_bsdf.ins.Roughness.Value = 0.000f;
            diffuse_bsdf.ins.Normal.Value = new float4(0.000f, 0.000f, 0.000f);

            var texture_coordinate = new TextureCoordinateNode();

            some_setup.AddNode(brick_texture);
            some_setup.AddNode(checker_texture);
            some_setup.AddNode(diffuse_bsdf);
            some_setup.AddNode(texture_coordinate);

            brick_texture.outs.Color.Connect(diffuse_bsdf.ins.Color);
            checker_texture.outs.Color.Connect(brick_texture.ins.Mortar);
            texture_coordinate.outs.Normal.Connect(checker_texture.ins.Vector);
            texture_coordinate.outs.UV.Connect(brick_texture.ins.Vector);

            diffuse_bsdf.outs.BSDF.Connect(some_setup.Output.ins.Surface);

            some_setup.FinalizeGraph();

            return some_setup;
        }
Beispiel #5
0
 public RhinoLight(Client client, CyclesLight intermediate, Shader existing, string name)
     : base(client, intermediate)
 {
     if (existing != null)
     {
         m_shader = existing;
         m_shader.Recreate();
     }
     else
     {
         m_shader = new Shader(m_client, Shader.ShaderType.Material)
         {
             UseMis = true,
             UseTransparentShadow = true,
             HeterogeneousVolume = false,
             Name = name
         };
     }
 }
 /// <summary>
 /// Create a new shader, with name overriding intermediate.Name
 /// </summary>
 /// <param name="client"></param>
 /// <param name="intermediate"></param>
 /// <param name="name"></param>
 public RhinoNotYetImplemented(Client client, CyclesShader intermediate, string name)
     : base(client, intermediate)
 {
     m_shader = new Shader(m_client, Shader.ShaderType.Material)
     {
         UseMis = true,
         UseTransparentShadow = true,
         HeterogeneousVolume = false,
         Name = name
     };
 }
Beispiel #7
0
        /// <summary>
        /// Static constructor for wrapping default background shader created by Cycles shader manager.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static Shader WrapDefaultBackgroundShader(Client client)
        {
            var shader = new Shader(client, ShaderType.World, CSycles.DEFAULT_BACKGROUND_SHADER) {Name = "default_background"};

            return shader;
        }
        internal CclShader CreateCyclesShaderFromXml(CyclesShader shader)
        {
            var sh = new CclShader(Client, CclShader.ShaderType.Material)
            {
                UseMis = true,
                UseTransparentShadow = true,
                HeterogeneousVolume = false,
                Name = shader.Name ?? $"V6 Basic Material {shader.Id}"
            };

            CclShader.ShaderFromXml(ref sh, shader.Crm.MaterialXml);

            return sh;
        }
        /// <summary>
        /// create a ccl.Scene
        /// </summary>
        /// <param name="client">Client to create scene for</param>
        /// <param name="render_device">Render device to use</param>
        /// <param name="cycles_engine">Engine instance to create for</param>
        /// <returns></returns>
        protected static Scene CreateScene(Client client, Device render_device,
			RenderEngine cycles_engine)
        {
            #region set up scene parameters
            var scene_params = new SceneParameters(client, ShadingSystem.SVM, BvhType.Dynamic, false, false, false);
            #endregion

            #region create scene
            var scene = new Scene(client, scene_params, render_device)
            {
                #region integrator settings
                Integrator =
                {
                    MaxBounce = cycles_engine.Settings.MaxBounce,
                    MinBounce = cycles_engine.Settings.MinBounce,
                    TransparentMinBounce = cycles_engine.Settings.TransparentMinBounce,
                    TransparentMaxBounce = cycles_engine.Settings.TransparentMaxBounce,
                    MaxDiffuseBounce = cycles_engine.Settings.MaxDiffuseBounce,
                    MaxGlossyBounce = cycles_engine.Settings.MaxGlossyBounce,
                    MaxTransmissionBounce = cycles_engine.Settings.MaxTransmissionBounce,
                    MaxVolumeBounce = cycles_engine.Settings.MaxVolumeBounce,
                    NoCaustics = cycles_engine.Settings.NoCaustics,
                    TransparentShadows = cycles_engine.Settings.TransparentShadows,
                    DiffuseSamples = cycles_engine.Settings.DiffuseSamples,
                    GlossySamples = cycles_engine.Settings.GlossySamples,
                    TransmissionSamples = cycles_engine.Settings.TransmissionSamples,
                    AoSamples = cycles_engine.Settings.AoSamples,
                    MeshLightSamples = cycles_engine.Settings.MeshLightSamples,
                    SubsurfaceSamples = cycles_engine.Settings.SubsurfaceSamples,
                    VolumeSamples = cycles_engine.Settings.VolumeSamples,
                    AaSamples = cycles_engine.Settings.AaSamples,
                    FilterGlossy = cycles_engine.Settings.FilterGlossy,
                    IntegratorMethod = cycles_engine.Settings.IntegratorMethod,
                    SampleAllLightsDirect = cycles_engine.Settings.SampleAllLights,
                    SampleAllLightsIndirect = cycles_engine.Settings.SampleAllLightsIndirect,
                    SampleClampDirect = cycles_engine.Settings.SampleClampDirect,
                    SampleClampIndirect = cycles_engine.Settings.SampleClampIndirect,
                    SamplingPattern = SamplingPattern.CMJ,
                    Seed = cycles_engine.Settings.Seed
                }
                #endregion
            };

            scene.Film.SetFilter(FilterType.Gaussian, 1.5f);
            scene.Film.Exposure = 1.0f;
            scene.Film.Update();

            #endregion

            #region background shader

            // we add here a simple background shader. This will be repopulated with
            // other nodes whenever background changes are detected.
            var background_shader = new Shader(client, Shader.ShaderType.World)
            {
                Name = "Rhino Background"
            };

            var bgnode = new BackgroundNode("orig bg");
            bgnode.ins.Color.Value = new float4(0.7f);
            bgnode.ins.Strength.Value = 1.0f;

            background_shader.AddNode(bgnode);
            bgnode.outs.Background.Connect(background_shader.Output.ins.Surface);
            background_shader.FinalizeGraph();

            scene.AddShader(background_shader);

            scene.Background.Shader = background_shader;
            scene.Background.AoDistance = 0.0f;
            scene.Background.AoFactor = 0.0f;
            scene.Background.Visibility = PathRay.AllVisibility;

            #endregion

            return scene;
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            var file = "";
            if (args.Length < 1 || args.Length > 2)
            {
                Console.WriteLine("Wrong count parameter: csycles_tester [--quiet] file.xml");
                return;
            }

            var s = args[args.Length-1];
            if (!File.Exists(s))
            {
                Console.WriteLine("File {0} doesn't exist.", s);
                return;
            }

            var silent = args.Length == 2 && "--quiet".Equals(args[0]);

            file = Path.GetFullPath(s);
            Console.WriteLine("We get file path: {0}", file);

            var path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) ?? "";
            var userpath = Path.Combine(path, "userpath");

            CSycles.path_init(path, userpath);
            CSycles.initialise();

            const uint samples = 50;
            g_update_callback = StatusUpdateCallback;
            g_update_render_tile_callback = UpdateRenderTileCallback;
            g_write_render_tile_callback = WriteRenderTileCallback;
            g_logger_callback = LoggerCallback;

            var client = new Client();
            Client = client;
            if (!silent)
            {
                CSycles.set_logger(client.Id, g_logger_callback);
            }

            foreach (var adev in Device.Devices)
            {
                Console.WriteLine("{0}", adev);
            }

            Console.WriteLine("All device capabilities: {0}", Device.Capabilities);

            var dev = Device.FirstCuda;
            Console.WriteLine("Using device {0} {1}", dev.Name, dev.Description);

            var scene_params = new SceneParameters(client, ShadingSystem.SVM, BvhType.Static, false, false, false, false);
            var scene = new Scene(client, scene_params, dev);

            Console.WriteLine("Default surface shader {0}", scene.DefaultSurface.Name);

            #region background shader
            var background_shader = new Shader(client, Shader.ShaderType.World)
            {
                Name = "Background shader"
            };

            var bgnode = new BackgroundNode();
            bgnode.ins.Color.Value = new float4(0.7f);
            bgnode.ins.Strength.Value = 1.0f;

            background_shader.AddNode(bgnode);
            bgnode.outs.Background.Connect(background_shader.Output.ins.Surface);
            background_shader.FinalizeGraph();

            scene.AddShader(background_shader);

            scene.Background.Shader = background_shader;
            scene.Background.AoDistance = 0.0f;
            scene.Background.AoFactor = 0.0f;
            scene.Background.Visibility = PathRay.AllVisibility;
            #endregion
            #region diffuse shader

            var diffuse_shader = create_some_setup_shader();
            scene.AddShader(diffuse_shader);
            scene.DefaultSurface = diffuse_shader;
            #endregion

            #region point light shader

            var light_shader = new Shader(client, Shader.ShaderType.Material)
            {
                Name = "Tester light shader"
            };

            var emission_node = new EmissionNode();
            emission_node.ins.Color.Value = new float4(0.8f);
            emission_node.ins.Strength.Value = 10.0f;

            light_shader.AddNode(emission_node);
            emission_node.outs.Emission.Connect(light_shader.Output.ins.Surface);
            light_shader.FinalizeGraph();
            scene.AddShader(light_shader);
            #endregion

            var xml = new XmlReader(client, file);
            xml.Parse(silent);
            var width = (uint)scene.Camera.Size.Width;
            var height = (uint)scene.Camera.Size.Height;

            var session_params = new SessionParameters(client, dev)
            {
                Experimental = false,
                Samples = (int) samples,
                TileSize = new Size(64, 64),
                StartResolution = 64,
                Threads = 0,
                ShadingSystem = ShadingSystem.SVM,
                Background = true,
                ProgressiveRefine = false
            };
            Session = new Session(client, session_params, scene);
            Session.Reset(width, height, samples);

            /*if (!silent)
            {
                Session.UpdateCallback = g_update_callback;
                Session.UpdateTileCallback = g_update_render_tile_callback;
                Session.WriteTileCallback = g_write_render_tile_callback;
            }*/

            Session.Start();
            Session.Wait();

            uint bufsize;
            uint bufstride;
            CSycles.session_get_buffer_info(client.Id, Session.Id, out bufsize, out bufstride);
            var pixels = CSycles.session_copy_buffer(client.Id, Session.Id, bufsize);

            var bmp = new Bitmap((int)width, (int)height);
            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    var i = y * (int)width * 4 + x * 4;
                    var r = ColorClamp((int)(pixels[i] * 255.0f));
                    var g = ColorClamp((int)(pixels[i + 1] * 255.0f));
                    var b = ColorClamp((int)(pixels[i + 2] * 255.0f));
                    var a = ColorClamp((int)(pixels[i + 3] * 255.0f));
                    bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
                }
            }
            bmp.Save("test.png", ImageFormat.Png);

            Console.WriteLine("Cleaning up :)");

            CSycles.shutdown();

            Console.WriteLine("Done");
        }
Beispiel #11
0
 public RhinoBackground(Client client, CyclesBackground intermediate, Shader existing)
     : this(client, intermediate, existing, "background")
 {
 }
Beispiel #12
0
        internal CclShader ReCreateSimpleEmissionShader(CyclesLight light, CclShader emission_shader)
        {
            var rhinolight = RhinoShader.CreateRhinoLightShader(Client, light, emission_shader);

            return(rhinolight.GetShader());
        }
Beispiel #13
0
        public static RhinoShader RecreateRhinoMaterialShader(Client client, CyclesShader intermediate, Shader existing)
        {
            RhinoShader theShader = new RhinoFullNxt(client, intermediate, existing);

            return theShader;
        }
Beispiel #14
0
        public void ReadShader(ref XmlReadState state, System.Xml.XmlReader node)
        {
            node.Read();
            var name = node.GetAttribute("name");
            if(!state.Silent) Console.WriteLine("Shader: {0}", node.GetAttribute("name"));
            if (string.IsNullOrEmpty(name)) return;

            var shader = new Shader(Client, Shader.ShaderType.Material) {Name = name};

            Utilities.Instance.ReadNodeGraph(ref shader, node.ReadSubtree());

            state.Scene.AddShader(shader);
        }
Beispiel #15
0
 public static RhinoShader CreateRhinoBackgroundShader(Client client, CyclesBackground intermediateBackground, Shader existingShader)
 {
     RhinoShader theShader = new RhinoBackground(client, intermediateBackground, existingShader);
     return theShader;
 }
Beispiel #16
0
 public static RhinoShader CreateRhinoLightShader(Client client, CyclesLight intermediateLight, Shader existingShader)
 {
     RhinoShader shader = new RhinoLight(client, intermediateLight, existingShader);
     return shader;
 }
Beispiel #17
0
        /// <summary>
        /// Static constructor for wrapping default surface shader created by Cycles shader manager.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static Shader WrapDefaultSurfaceShader(Client client)
        {
            var shader = new Shader(client, ShaderType.Material, CSycles.DEFAULT_SURFACE_SHADER) {Name = "default_surface"};

            // just add nodes so we have local node presentation, but no need to actually finalise
            // since it already exists in Cycles.
            var diffuse_bsdf = new DiffuseBsdfNode();
            diffuse_bsdf.ins.Color.Value = new float4(0.8f);

            shader.AddNode(diffuse_bsdf);

            diffuse_bsdf.outs.BSDF.Connect(shader.Output.ins.Surface);

            return shader;
        }
Beispiel #18
0
        /// <summary>
        /// Static constructor for wrapping default light shader created by Cycles shader manager.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static Shader WrapDefaultLightShader(Client client)
        {
            var shader = new Shader(client, ShaderType.Material, CSycles.DEFAULT_LIGHT_SHADER) {Name = "default_light"};

            // just add nodes so we have local node presentation, but no need to actually finalise
            // since it already exists in Cycles.
            var emission_node = new EmissionNode();
            emission_node.ins.Color.Value = new float4(0.8f);
            emission_node.ins.Strength.Value = 0.0f;

            shader.AddNode(emission_node);

            emission_node.outs.Emission.Connect(shader.Output.ins.Surface);

            return shader;
        }
Beispiel #19
0
        /// <summary>
        /// Static constructor for wrapping default empty shader created by Cycles shader manager.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static Shader WrapDefaultEmptyShader(Client client)
        {
            var shader = new Shader(client, ShaderType.Material, CSycles.DEFAULT_EMPTY_SHADER) {Name = "default_empty"};

            return shader;
        }
Beispiel #20
0
 public RhinoFullNxt(Client client, CyclesShader intermediate, Shader existing)
     : this(client, intermediate, existing, intermediate.Name)
 {
 }
Beispiel #21
0
        private void ReadBackground(ref XmlReadState state, System.Xml.XmlReader node)
        {
            node.Read();
            if(!state.Silent) Console.WriteLine("Background shader");

            var shader = new Shader(Client, Shader.ShaderType.World) {Name = Guid.NewGuid().ToString()};

            Utilities.Instance.ReadNodeGraph(ref shader, node.ReadSubtree());

            state.Scene.AddShader(shader);
            state.Scene.Background.Shader = shader;
        }
Beispiel #22
0
        public void ReadNodeGraph(ref Shader shader, XmlReader xmlNode)
        {
            var nodes = new Dictionary<string, ShaderNode> {{"output", shader.Output}};

            while (xmlNode.Read())
            {
                ShaderNode shader_node = null;
                if (!xmlNode.IsStartElement()) continue;
                var nodename = xmlNode.GetAttribute("name");
                if (string.IsNullOrEmpty(nodename) && xmlNode.Name != "connect") continue;

                if (string.IsNullOrEmpty(nodename)) nodename = "";

                switch (xmlNode.Name)
                {
                    case "connect":
                        var fromstring = xmlNode.GetAttribute("from");
                        var tostring = xmlNode.GetAttribute("to");
                        if (fromstring != null && tostring != null)
                        {
                            var from = fromstring.Split(' ');
                            var to = tostring.Split(' ');

                            if (!nodes.ContainsKey(from[0]))
                                throw new KeyNotFoundException(string.Format("'from' node [{0}] not defined prior to connection.", from[0]));
                            var fromnode = nodes[from[0]];
                            var fromsocket = fromnode.outputs.Socket(from[1]);

                            if (!nodes.ContainsKey(to[0]))
                                throw new KeyNotFoundException(string.Format("'to' node [{0}] not defined prior to connection.", to[0]));
                            var tonode = nodes[to[0]];
                            var tosocket = tonode.inputs.Socket(to[1]);

                            fromsocket.Connect(tosocket);
                        }
                        break;
                    default:
                        shader_node = CSycles.CreateShaderNode(xmlNode.Name, nodename);
                        break;
                }
                if (shader_node != null)
                {
                    shader_node.ParseXml(xmlNode);
                    nodes.Add(nodename, shader_node);
                    shader.AddNode(shader_node);
                }
            }

            shader.FinalizeGraph();
        }
Beispiel #23
0
 /// <summary>
 /// Add a Shader to Scene, assigning it a scene specific ID.
 /// </summary>
 /// <param name="shader">The Shader to add to the Scene</param>
 /// <returns>Scene-specific ID for the Shader</returns>
 public uint AddShader(Shader shader)
 {
     var shader_in_scene_id = CSycles.scene_add_shader(Client.Id, Id, shader.Id);
     m_shader_in_scene_ids.Add(shader, shader_in_scene_id);
     return shader_in_scene_id;
 }
Beispiel #24
0
        internal CclShader RecreateCyclesShaderFromRhinoV6BasicMat(CyclesShader shader, CclShader existing)
        {
            var v6 = RhinoShader.RecreateRhinoMaterialShader(Client, shader, existing);

            return(v6.GetShader());
        }
Beispiel #25
0
 public RhinoLight(Client client, CyclesLight intermediate, Shader existing)
     : this(client, intermediate, existing, "light")
 {
 }
        /// <summary>
        /// Set image texture node and link up with correct TextureCoordinateNode output based on
        /// texture ProjectionMode.
        /// 
        /// This may add new nodes to the shader!
        /// </summary>
        /// <param name="shader"></param>
        /// <param name="texture"></param>
        /// <param name="image_node"></param>
        /// <param name="texture_coordinates"></param>
        public static void SetProjectionMode(Shader shader, CyclesTextureImage texture, ImageTextureNode image_node,
			TextureCoordinateNode texture_coordinates)
        {
            if (!texture.HasTextureImage) return;

            Guid g = Guid.NewGuid();

            texture_coordinates.UseTransform = false;

            var tfm = new MatrixMathNode("texture transform" + g.ToString())
            {
                Transform = texture.Transform
            };
            shader.AddNode(tfm);

            image_node.Projection = TextureNode.TextureProjection.Flat;

            if (texture.ProjectionMode == TextureProjectionMode.WcsBox)
            {
                texture_coordinates.UseTransform = true;
                texture_coordinates.outs.WcsBox.Connect(tfm.ins.Vector);
                tfm.outs.Vector.Connect(image_node.ins.Vector);
            }
            else if (texture.ProjectionMode == TextureProjectionMode.Wcs)
            {
                texture_coordinates.UseTransform = true;
                texture_coordinates.outs.Object.Connect(tfm.ins.Vector);
                tfm.outs.Vector.Connect(image_node.ins.Vector);
            }
            else if (texture.ProjectionMode == TextureProjectionMode.Screen)
            {
                SeparateXyzNode sepvec = new SeparateXyzNode();
                CombineXyzNode combvec = new CombineXyzNode();
                MathNode inverty = new MathNode {Operation = MathNode.Operations.Subtract};
                inverty.ins.Value1.Value = 1.0f;
                shader.AddNode(sepvec);
                shader.AddNode(combvec);
                shader.AddNode(inverty);

                texture_coordinates.outs.Window.Connect(sepvec.ins.Vector);

                sepvec.outs.Y.Connect(inverty.ins.Value2);

                sepvec.outs.X.Connect(combvec.ins.X);
                inverty.outs.Value.Connect(combvec.ins.Y);
                sepvec.outs.Z.Connect(combvec.ins.Z);

                combvec.outs.Vector.Connect(tfm.ins.Vector);

                tfm.Transform = tfm.Transform;
                tfm.outs.Vector.Connect(image_node.ins.Vector);
            }
            else if (texture.ProjectionMode == TextureProjectionMode.View)
            {
                texture_coordinates.outs.Camera.Connect(tfm.ins.Vector);
                tfm.outs.Vector.Connect(image_node.ins.Vector);
            }
            else if (texture.ProjectionMode == TextureProjectionMode.EnvironmentMap)
            {
                texture_coordinates.UseTransform = false;
                switch (texture.EnvProjectionMode)
                {
                    case TextureEnvironmentMappingMode.Spherical:
                        texture_coordinates.outs.EnvSpherical.Connect(image_node.ins.Vector);
                        break;
                    case TextureEnvironmentMappingMode.EnvironmentMap:
                        texture_coordinates.outs.EnvEmap.Connect(image_node.ins.Vector);
                        break;
                    case TextureEnvironmentMappingMode.Box:
                        texture_coordinates.outs.EnvBox.Connect(image_node.ins.Vector);
                        break;
                    case TextureEnvironmentMappingMode.LightProbe:
                        texture_coordinates.outs.EnvLightProbe.Connect(image_node.ins.Vector);
                        break;
                    case TextureEnvironmentMappingMode.Cube:
                        texture_coordinates.outs.EnvCubemap.Connect(image_node.ins.Vector);
                        break;
                    case TextureEnvironmentMappingMode.VerticalCrossCube:
                        texture_coordinates.outs.EnvCubemapVerticalCross.Connect(image_node.ins.Vector);
                        break;
                    case TextureEnvironmentMappingMode.HorizontalCrossCube:
                        texture_coordinates.outs.EnvCubemapHorizontalCross.Connect(image_node.ins.Vector);
                        break;
                    case TextureEnvironmentMappingMode.Hemispherical:
                        texture_coordinates.outs.EnvHemispherical.Connect(image_node.ins.Vector);
                        break;
                    default:
                        texture_coordinates.outs.EnvLightProbe.Connect(image_node.ins.Vector);
                        break;
                }
            }
            else
            {
                texture_coordinates.outs.UV.Connect(tfm.ins.Vector);
                tfm.outs.Vector.Connect(image_node.ins.Vector);
            }
        }
Beispiel #27
0
 internal void TriggerMaterialShaderChanged(CyclesShader rcShader, Shader cclShader)
 {
     MaterialShaderChanged?.Invoke(this, new MaterialShaderUpdatedEventArgs(rcShader, cclShader));
 }
Beispiel #28
0
 internal CclShader RecreateCyclesShaderFromXml(ShaderBody shader, CclShader existing)
 {
     existing.Recreate();
     CclShader.ShaderFromXml(ref existing, shader.Crm.MaterialXml);
     return(existing);
 }
        internal CclShader ReCreateSimpleEmissionShader(CyclesLight light, CclShader emission_shader)
        {
            var rhinolight = RhinoShader.CreateRhinoLightShader(Client, light, emission_shader);

            return rhinolight.GetShader();
        }
        internal CclShader RecreateCyclesShaderFromRhinoV6BasicMat(CyclesShader shader, CclShader existing)
        {
            var v6 = RhinoShader.RecreateRhinoMaterialShader(Client, shader, existing);

            return v6.GetShader();
        }
Beispiel #31
0
 /// <summary>
 /// Create node graph in the given shader from the passed XML
 /// </summary>
 /// <param name="shader"></param>
 /// <param name="shaderXml"></param>
 /// <returns></returns>
 public static void ShaderFromXml(ref Shader shader, string shaderXml)
 {
     var xmlmem = Encoding.UTF8.GetBytes(shaderXml);
     using (var xmlstream = new MemoryStream(xmlmem))
     {
         var settings = new XmlReaderSettings
         {
             ConformanceLevel = ConformanceLevel.Fragment,
             IgnoreComments = true,
             IgnoreProcessingInstructions = true,
             IgnoreWhitespace = true
         };
         var reader = XmlReader.Create(xmlstream, settings);
         Utilities.Instance.ReadNodeGraph(ref shader, reader);
     }
 }
Beispiel #32
0
 /// <summary>
 /// Get the scene-specific Id for Shader
 /// </summary>
 /// <param name="shader">Shader to query for</param>
 /// <returns>Scene-specific Id</returns>
 public uint GetShaderSceneId(Shader shader)
 {
     return m_shader_in_scene_ids[shader];
 }
        internal CclShader RecreateCyclesShaderFromXml(CyclesShader shader, CclShader existing)
        {
            existing.Recreate();
            CclShader.ShaderFromXml(ref existing, shader.Crm.MaterialXml);

            return existing;
        }
        internal CclShader RecreateMaterialShader(CyclesShader shader, CclShader existing)
        {
            CclShader sh = null;
            switch (shader.CyclesMaterialType)
            {
                case CyclesShader.CyclesMaterial.Xml:
                    sh = RecreateCyclesShaderFromXml(shader, existing);
                    break;
                default:
                    sh = RecreateCyclesShaderFromRhinoV6BasicMat(shader, existing);
                    break;
            }

            return sh;
        }
Beispiel #35
0
 internal void TriggerLightShaderChanged(CyclesLight rcLightShader, Shader cclShader)
 {
     LightShaderChanged?.Invoke(this, new LightShaderUpdatedEventArgs(rcLightShader, cclShader));
 }