/// <summary> /// Create a new scene with the given SceneParameters and Device /// </summary> /// <param name="client">The client from C[CS]ycles API</param> /// <param name="sceneParams">The SceneParameters to create scene with</param> /// <param name="device">The Device to create scene for</param> public Scene(Client client, SceneParameters sceneParams, Device device) { Client = client; Id = CSycles.scene_create(Client.Id, sceneParams.Id, device.Id); Background = new Background(this); Camera = new Camera(this); Integrator = new Integrator(this); Film = new Film(this); Device = device; /* add simple wrappers for shadermanager created default shaders */ var surface = Shader.WrapDefaultSurfaceShader(client); var light = Shader.WrapDefaultLightShader(client); var background = Shader.WrapDefaultBackgroundShader(client); var empty = Shader.WrapDefaultEmptyShader(client); /* register the wrapped shaders with scene */ m_shader_in_scene_ids.Add(surface, surface.Id); m_shader_in_scene_ids.Add(background, background.Id); m_shader_in_scene_ids.Add(light, light.Id); m_shader_in_scene_ids.Add(empty, empty.Id); DefaultSurface = surface; // set ourself to client as reference client.Scene = this; }
/// <summary> /// Create a new shader for client. /// </summary> /// <param name="client">Client ID for C[CS]ycles API.</param> /// <param name="type">The type of shader to create</param> public Shader(Client client, ShaderType type) { Client = client; Type = type; Id = CSycles.create_shader(Client.Id); Output = new OutputNode(); AddNode(Output); created_in_cycles = false; Verbose = false; }
/// <summary> /// Create front for existing shader. Note that /// functionality through this can be limited. /// Generally used only for interal matters /// </summary> /// <param name="client"></param> /// <param name="type"></param> /// <param name="id"></param> internal Shader(Client client, ShaderType type, uint id) { Client = client; Type = type; Id = id; Output = new OutputNode(); AddNode(Output); created_in_cycles = true; Verbose = false; }
/// <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 }; }
/// <summary> /// Construct a render engine for preview rendering /// </summary> /// <param name="createPreviewEventArgs"></param> /// <param name="pluginId">Id of the plugin for which the render engine is created</param> public PreviewRenderEngine(CreatePreviewEventArgs createPreviewEventArgs, Guid pluginId) : base(pluginId, createPreviewEventArgs, false) { Client = new Client(); State = State.Rendering; #region create callbacks for Cycles m_update_callback = UpdateCallback; m_update_render_tile_callback = PreviewRendererUpdateRenderTileCallback; m_write_render_tile_callback = PreviewRendererWriteRenderTileCallback; m_test_cancel_callback = TestCancel; CSycles.log_to_stdout(false); #endregion }
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 }; } }
public ViewportRenderEngine(uint docRuntimeSerialNumber, Guid pluginId, ViewInfo view) : base(pluginId, docRuntimeSerialNumber, view, null, true) { Client = new Client(); State = State.Rendering; Database.ViewChanged += Database_ViewChanged; ChangesReady += ViewportRenderEngine_ChangesReady; #region create callbacks for Cycles m_update_callback = UpdateCallback; m_update_render_tile_callback = null; m_write_render_tile_callback = null; m_test_cancel_callback = null; m_display_update_callback = DisplayUpdateHandler; CSycles.log_to_stdout(false); #endregion }
public XmlReader(Client client, string path) { Client = client; Path = path; NumberFormatInfo = NumberFormatInfo.InvariantInfo; }
public static RhinoShader RecreateRhinoMaterialShader(Client client, CyclesShader intermediate, Shader existing) { RhinoShader theShader = new RhinoFullNxt(client, intermediate, existing); return theShader; }
private void ModalRenderEngineCommonConstruct() { Client = new Client(); State = State.Rendering; Database.ViewChanged += MRE_Database_ViewChanged; #region create callbacks for Cycles m_update_callback = UpdateCallback; m_update_render_tile_callback = null; m_write_render_tile_callback = null; m_test_cancel_callback = null; m_display_update_callback = DisplayUpdateHandler; CSycles.log_to_stdout(false); #endregion }
public RhinoBackground(Client client, CyclesBackground intermediate, Shader existing) : this(client, intermediate, existing, "background") { }
public RhinoFullNxt(Client client, CyclesShader intermediate) : this(client, intermediate, null, intermediate.Name) { }
/// <summary> /// Create a new shader, using intermediate.Name as name /// </summary> /// <param name="client"></param> /// <param name="intermediate"></param> public RhinoNotYetImplemented(Client client, CyclesShader intermediate) : this(client, intermediate, intermediate.Name) { }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
protected RhinoShader(Client client, CyclesShader intermediate) { m_client = client; m_original = intermediate; }
protected RhinoShader(Client client, CyclesBackground intermediateBackground) { m_client = client; m_original_background = intermediateBackground; }
public RhinoFullNxt(Client client, CyclesShader intermediate, Shader existing) : this(client, intermediate, existing, intermediate.Name) { }
protected RhinoShader(Client client, CyclesLight intermediateLight) { m_client = client; m_original_light = intermediateLight; }
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"); }
public static RhinoShader CreateRhinoBackgroundShader(Client client, CyclesBackground intermediateBackground, Shader existingShader) { RhinoShader theShader = new RhinoBackground(client, intermediateBackground, existingShader); return theShader; }
public RhinoLight(Client client, CyclesLight intermediate, Shader existing) : this(client, intermediate, existing, "light") { }
public static RhinoShader CreateRhinoLightShader(Client client, CyclesLight intermediateLight, Shader existingShader) { RhinoShader shader = new RhinoLight(client, intermediateLight, existingShader); return shader; }
public RendererModel() { Client = new Client(); }
public static RhinoShader CreateRhinoMaterialShader(Client client, CyclesShader intermediate) { RhinoShader theShader = new RhinoFullNxt(client, intermediate); return theShader; }
/// <summary> /// Create session parameters using <c>Device</c> /// </summary> /// <param name="dev">The device to create session parameters for</param> public SessionParameters(Client client, Device dev) { Client = client; _device = dev; Id = CSycles.session_params_create(Client.Id, (uint)dev.Id); }
/// <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; }