/// <summary> /// Create a CyclesShader based on given Material m /// </summary> /// <param name="rm">Material to convert to CyclesShader</param> /// <param name="gamma">gamma to use for this shader</param> /// <returns>The CyclesShader</returns> internal CyclesShader CreateCyclesShader(RenderMaterial rm, float gamma) { var mid = rm.RenderHash; var shader = new CyclesShader(mid); shader.Type = CyclesShader.Shader.Diffuse; RenderMaterial front; if (rm.TypeId.Equals(realtimDisplaMaterialId)) { if (rm.FirstChild?.ChildSlotName?.Equals("front") ?? false) { front = rm.FirstChild as RenderMaterial; shader.CreateFrontShader(front, gamma); } if (rm.FirstChild?.NextSibling?.ChildSlotName?.Equals("back") ?? false) { var back = rm.FirstChild.NextSibling as RenderMaterial; shader.CreateBackShader(back, gamma); } } else { front = rm; shader.CreateFrontShader(front, gamma); } return(shader); }
/// <summary> /// Add a CyclesShader to the list of shaders that will have to be committed to Cycles. /// </summary> /// <param name="shader"></param> public void AddShader(CyclesShader shader) { if (!_rhCclShaders.ContainsKey(shader.Id) && !_cqShaders.Contains(shader)) { _cqShaders.Add(shader); //_allShaders.Add(shader); } }
/// <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 }; }
protected RhinoShader(Client client, CyclesShader intermediate, string name, Shader existing) { m_client = client; m_original = intermediate; if (m_original.Front != null) { m_original.Front.Gamma = m_original.Gamma; } if (m_original.Back != null) { m_original.Back.Gamma = m_original.Gamma; } InitShader(name, existing, Shader.ShaderType.Material); }
public RhinoFullNxt(Client client, CyclesShader 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 bool GetShader(Shader sh, bool finalize) { blendit = new ccl.ShaderNodes.MixClosureNode($"blendit{Serial}"); sh.AddNode(blendit); RhinoCyclesCore.Converters.ShaderConverter sconv = new RhinoCyclesCore.Converters.ShaderConverter(); CyclesShader mat1sh = null; CyclesShader mat2sh = null; ICyclesMaterial crm1 = null; ICyclesMaterial crm2 = null; ClosureSocket crm1closure = null; ClosureSocket crm2closure = null; if (Mat1Rm != null) { if (Mat1Rm is ICyclesMaterial) { crm1 = Mat1Rm as ICyclesMaterial; crm1.Gamma = Gamma; crm1.GetShader(sh, false); crm1closure = crm1.GetClosureSocket(sh); } else { mat1sh = sconv.CreateCyclesShader(Mat1Rm, Gamma); mat1sh.Gamma = Gamma; RhinoCyclesCore.Converters.BitmapConverter.ReloadTextures(mat1sh); } } if (Mat2Rm != null) { if (Mat2Rm is ICyclesMaterial) { crm2 = Mat2Rm as ICyclesMaterial; crm2.Gamma = Gamma; crm2.GetShader(sh, false); crm2closure = crm2.GetClosureSocket(sh); } else { mat2sh = sconv.CreateCyclesShader(Mat2Rm, Gamma); mat2sh.Gamma = Gamma; RhinoCyclesCore.Converters.BitmapConverter.ReloadTextures(mat2sh); } } RhinoCyclesCore.Shaders.RhinoFullNxt fnMat1 = null; ClosureSocket fnMat1Closure = null; if (mat1sh != null) { fnMat1 = new RhinoCyclesCore.Shaders.RhinoFullNxt(null, mat1sh, sh, false); fnMat1Closure = fnMat1.GetClosureSocket(); } RhinoCyclesCore.Shaders.RhinoFullNxt fnMat2 = null; ClosureSocket fnMat2Closure = null; if (mat2sh != null) { fnMat2 = new RhinoCyclesCore.Shaders.RhinoFullNxt(null, mat2sh, sh, false); fnMat2Closure = fnMat2.GetClosureSocket(); } ccl.ShaderNodes.TextureCoordinateNode texco = new ccl.ShaderNodes.TextureCoordinateNode($"texcos{Serial}"); sh.AddNode(texco); ccl.ShaderNodes.DiffuseBsdfNode diffuse1Bsdf = new ccl.ShaderNodes.DiffuseBsdfNode(); diffuse1Bsdf.ins.Color.Value = Mat1; ccl.ShaderNodes.DiffuseBsdfNode diffuse2Bsdf = new ccl.ShaderNodes.DiffuseBsdfNode(); diffuse2Bsdf.ins.Color.Value = Mat2; sh.AddNode(diffuse1Bsdf); sh.AddNode(diffuse2Bsdf); blendit.ins.Fac.Value = Blend; GraphForSlot(sh, BlendTexOn, BlendTex, blendit.ins.Fac, texco, true); var sock1 = fnMat1Closure ?? crm1closure ?? diffuse1Bsdf.outs.BSDF; sock1.Connect(blendit.ins.Closure1); var sock2 = fnMat2Closure ?? crm2closure ?? diffuse2Bsdf.outs.BSDF; sock2.Connect(blendit.ins.Closure2); blendit.outs.Closure.Connect(sh.Output.ins.Surface); if (finalize) { sh.FinalizeGraph(); } return(true); }
public MaterialShaderUpdatedEventArgs(CyclesShader rcShader, CclShader cclShader) { RcShader = rcShader; CclShader = cclShader; }
/// <summary> /// Create a CyclesShader based on given Material m /// </summary> /// <param name="rm">Material to convert to CyclesShader</param> /// <param name="gamma">gamma to use for this shader</param> /// <returns>The CyclesShader</returns> internal CyclesShader CreateCyclesShader(RenderMaterial rm, float gamma) { var mid = rm.RenderHash; CyclesShader shader = null; var crm = rm as ICyclesMaterial; CyclesShader.CyclesMaterial mattype = CyclesShader.CyclesMaterial.No; if (crm == null) { // always simulate material, need to know now myself // what to read out from the simulated material to // populate my own material descriptions. var m = rm.SimulateMaterial(true); // figure out what type of material we are. //var probemat = GuessMaterialFromSmell(rm); var probemat = WhatMaterial(rm, m); rm.BeginChange(RenderContent.ChangeContexts.Ignore); var dcl = m.DiffuseColor; var scl = m.SpecularColor; var rcl = m.ReflectionColor; var rfcl = m.TransparentColor; var emcl = m.EmissionColor; var polish = (float)m.ReflectionGlossiness; var reflectivity = (float)m.Reflectivity; var metalic = 0f; var shine = (float)(m.Shine / Material.MaxShine); switch (probemat) { case ProbableMaterial.Plaster: mattype = CyclesShader.CyclesMaterial.Diffuse; break; case ProbableMaterial.Glass: case ProbableMaterial.Gem: metalic = 0f; mattype = CyclesShader.CyclesMaterial.Glass; break; case ProbableMaterial.Metal: metalic = 1.0f; mattype = CyclesShader.CyclesMaterial.SimpleMetal; break; case ProbableMaterial.Plastic: polish = reflectivity; shine = polish; reflectivity = 0f; metalic = 0f; mattype = CyclesShader.CyclesMaterial.SimplePlastic; break; case ProbableMaterial.Paint: mattype = CyclesShader.CyclesMaterial.Paint; break; case ProbableMaterial.Custom: metalic = m.FresnelReflections ? 0.0f : reflectivity; break; } var difftexAlpha = m.AlphaTransparency; var col = RenderEngine.CreateFloat4(dcl.R, dcl.G, dcl.B, 255); var spec = RenderEngine.CreateFloat4(scl.R, scl.G, scl.B, 255); var refl = RenderEngine.CreateFloat4(rcl.R, rcl.G, rcl.B, 255); var transp = RenderEngine.CreateFloat4(rfcl.R, rfcl.G, rfcl.B, 255); var refr = RenderEngine.CreateFloat4(rfcl.R, rfcl.G, rfcl.B, 255); var emis = RenderEngine.CreateFloat4(emcl.R, emcl.G, emcl.B, 255); shader = new CyclesShader { Id = mid, Type = CyclesShader.Shader.Diffuse, CyclesMaterialType = mattype, Shadeless = m.DisableLighting, DiffuseColor = col, SpecularColor = spec, ReflectionColor = refl, ReflectionRoughness = polish, RefractionColor = refr, RefractionRoughness = (float)m.RefractionGlossiness, TransparencyColor = transp, EmissionColor = emis, FresnelIOR = (float)m.FresnelIndexOfRefraction, IOR = (float)m.IndexOfRefraction, Roughness = (float)m.ReflectionGlossiness, Reflectivity = reflectivity, Metalic = metalic, Transparency = (float)m.Transparency, Shine = shine, Gloss = metalic > 0.0f ? polish : 0.0f, FresnelReflections = m.FresnelReflections, Gamma = gamma, Name = m.Name ?? "" }; shader.DiffuseTexture.Amount = 0.0f; shader.BumpTexture.Amount = 0.0f; shader.TransparencyTexture.Amount = 0.0f; shader.EnvironmentTexture.Amount = 0.0f; if (rm.GetTextureOnFromUsage(RenderMaterial.StandardChildSlots.Diffuse)) { var difftex = rm.GetTextureFromUsage(RenderMaterial.StandardChildSlots.Diffuse); BitmapConverter.MaterialBitmapFromEvaluator(ref shader, rm, difftex, RenderMaterial.StandardChildSlots.Diffuse); if (shader.HasDiffuseTexture) { shader.DiffuseTexture.UseAlpha = difftexAlpha; shader.DiffuseTexture.Amount = (float)Math.Min(rm.GetTextureAmountFromUsage(RenderMaterial.StandardChildSlots.Diffuse) / 100.0f, 1.0f); } } if (rm.GetTextureOnFromUsage(RenderMaterial.StandardChildSlots.Bump)) { var bumptex = rm.GetTextureFromUsage(RenderMaterial.StandardChildSlots.Bump); BitmapConverter.MaterialBitmapFromEvaluator(ref shader, rm, bumptex, RenderMaterial.StandardChildSlots.Bump); if (shader.HasBumpTexture) { shader.BumpTexture.Amount = (float)Math.Min(rm.GetTextureAmountFromUsage(RenderMaterial.StandardChildSlots.Bump) / 100.0f, 1.0f); } } if (rm.GetTextureOnFromUsage(RenderMaterial.StandardChildSlots.Transparency)) { var transtex = rm.GetTextureFromUsage(RenderMaterial.StandardChildSlots.Transparency); BitmapConverter.MaterialBitmapFromEvaluator(ref shader, rm, transtex, RenderMaterial.StandardChildSlots.Transparency); if (shader.HasTransparencyTexture) { shader.TransparencyTexture.Amount = (float)Math.Min(rm.GetTextureAmountFromUsage(RenderMaterial.StandardChildSlots.Transparency) / 100.0f, 1.0f); } } if (rm.GetTextureOnFromUsage(RenderMaterial.StandardChildSlots.Environment)) { var envtex = rm.GetTextureFromUsage(RenderMaterial.StandardChildSlots.Environment); BitmapConverter.MaterialBitmapFromEvaluator(ref shader, rm, envtex, RenderMaterial.StandardChildSlots.Environment); if (shader.HasEnvironmentTexture) { shader.EnvironmentTexture.Amount = (float)Math.Min(rm.GetTextureAmountFromUsage(RenderMaterial.StandardChildSlots.Environment) / 100.0f, 1.0f); } } rm.EndChange(); } if (crm != null) { shader = new CyclesShader { Id = mid, CyclesMaterialType = crm.MaterialType, Gamma = gamma, Crm = crm }; } shader.Gamma = gamma; return shader; }
public RhinoFullNxt(Client client, CyclesShader intermediate, Shader existing, string name) : base(client, intermediate, name, existing) { }
public RhinoFullNxt(Client client, CyclesShader intermediate) : this(client, intermediate, null, intermediate.Front.Name) { }
/// <summary> /// Add a CyclesShader and its shader /// </summary> /// <param name="s"></param> /// <param name="shader"></param> public void Add(CyclesShader s, CclShader shader) { _allShaders.Add(new Tuple <object, CclShader>(s, shader)); }
/// <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) { }
public static RhinoShader RecreateRhinoMaterialShader(Client client, CyclesShader intermediate, Shader existing) { RhinoShader theShader = new RhinoFullNxt(client, intermediate, existing); return(theShader); }
public static RhinoShader CreateRhinoMaterialShader(Client client, CyclesShader intermediate) { RhinoShader theShader = new RhinoFullNxt(client, intermediate); return(theShader); }
private static void InternalMaterialBitmapFromEvaluator(CyclesShader shader, RenderTexture renderTexture, RenderMaterial.StandardChildSlots textureType, Rhino.Geometry.Transform rhinotfm, uint rId, TextureEvaluator actualEvaluator, TextureProjectionMode projectionMode, TextureEnvironmentMappingMode envProjectionMode) { int pheight; int pwidth; try { int u, v, w; renderTexture.PixelSize(out u, out v, out w); pheight = u; pwidth = v; } catch (Exception) { pheight = 1024; pwidth = 1024; } if (pheight == 0 || pwidth == 0) { pheight = 1024; pwidth = 1024; } Transform t = new Transform( rhinotfm.ToFloatArray(true) ); var isFloat = renderTexture.IsHdrCapable(); var isLinear = renderTexture.IsLinear(); if (isFloat) { var img = RetrieveFloatsImg(rId, pwidth, pheight, actualEvaluator, false, false, isLinear); img.ApplyGamma(shader.Gamma); switch (textureType) { case RenderMaterial.StandardChildSlots.Diffuse: shader.DiffuseTexture.IsLinear = isLinear; shader.DiffuseTexture.TexFloat = img.Data; shader.DiffuseTexture.TexByte = null; break; case RenderMaterial.StandardChildSlots.Bump: shader.BumpTexture.IsLinear = isLinear; shader.BumpTexture.TexFloat = img.Data; shader.BumpTexture.TexByte = null; break; case RenderMaterial.StandardChildSlots.Transparency: shader.TransparencyTexture.IsLinear = isLinear; shader.TransparencyTexture.TexFloat = img.Data; shader.TransparencyTexture.TexByte = null; break; case RenderMaterial.StandardChildSlots.Environment: shader.EnvironmentTexture.IsLinear = isLinear; shader.EnvironmentTexture.TexFloat = img.Data; shader.EnvironmentTexture.TexByte = null; break; } } else { var img = RetrieveBytesImg(rId, pwidth, pheight, actualEvaluator, false, false, isLinear); img.ApplyGamma(shader.Gamma); switch (textureType) { case RenderMaterial.StandardChildSlots.Diffuse: shader.DiffuseTexture.IsLinear = isLinear; shader.DiffuseTexture.TexFloat = null; shader.DiffuseTexture.TexByte = img.Data; break; case RenderMaterial.StandardChildSlots.Bump: shader.BumpTexture.IsLinear = isLinear; shader.BumpTexture.TexFloat = null; shader.BumpTexture.TexByte = img.Data; break; case RenderMaterial.StandardChildSlots.Transparency: shader.TransparencyTexture.IsLinear = isLinear; shader.TransparencyTexture.TexFloat = null; shader.TransparencyTexture.TexByte = img.Data; break; case RenderMaterial.StandardChildSlots.Environment: shader.EnvironmentTexture.IsLinear = isLinear; shader.EnvironmentTexture.TexFloat = null; shader.EnvironmentTexture.TexByte = img.Data; break; } } switch (textureType) { case RenderMaterial.StandardChildSlots.Diffuse: shader.DiffuseTexture.TexWidth = pwidth; shader.DiffuseTexture.TexHeight = pheight; shader.DiffuseTexture.ProjectionMode = projectionMode; shader.DiffuseTexture.EnvProjectionMode = envProjectionMode; shader.DiffuseTexture.Transform = t; shader.DiffuseTexture.Name = rId.ToString(CultureInfo.InvariantCulture); break; case RenderMaterial.StandardChildSlots.Bump: shader.BumpTexture.TexWidth = pwidth; shader.BumpTexture.TexHeight = pheight; shader.BumpTexture.ProjectionMode = projectionMode; shader.BumpTexture.EnvProjectionMode = envProjectionMode; shader.BumpTexture.Transform = t; shader.BumpTexture.Name = rId.ToString(CultureInfo.InvariantCulture); break; case RenderMaterial.StandardChildSlots.Transparency: shader.TransparencyTexture.TexWidth = pwidth; shader.TransparencyTexture.TexHeight = pheight; shader.TransparencyTexture.ProjectionMode = projectionMode; shader.TransparencyTexture.EnvProjectionMode = envProjectionMode; shader.TransparencyTexture.Transform = t; shader.TransparencyTexture.Name = rId.ToString(CultureInfo.InvariantCulture); break; case RenderMaterial.StandardChildSlots.Environment: shader.EnvironmentTexture.TexWidth = pwidth; shader.EnvironmentTexture.TexHeight = pheight; // special texture, always set to Environment/Emap shader.EnvironmentTexture.ProjectionMode = TextureProjectionMode.EnvironmentMap; shader.EnvironmentTexture.EnvProjectionMode = TextureEnvironmentMappingMode.EnvironmentMap; shader.EnvironmentTexture.Transform = t; shader.EnvironmentTexture.Name = rId.ToString(CultureInfo.InvariantCulture); break; } }
/// <summary> /// Get material bitmap from texture evaluator /// </summary> /// <param name="shader"></param> /// <param name="rm"></param> /// <param name="renderTexture"></param> /// <param name="textureType"></param> internal static void MaterialBitmapFromEvaluator(ref CyclesShader shader, RenderMaterial rm, RenderTexture renderTexture, RenderMaterial.StandardChildSlots textureType) { if (renderTexture == null) return; var rId = renderTexture.RenderHashWithoutLocalMapping; var rhinotfm = renderTexture.LocalMappingTransform; var projectionMode = renderTexture.GetProjectionMode(); var envProjectionMode = renderTexture.GetInternalEnvironmentMappingMode(); using (var textureEvaluator = renderTexture.CreateEvaluator(RenderTexture.TextureEvaluatorFlags.DisableLocalMapping)) { SimulatedTexture st = textureEvaluator == null ? renderTexture.SimulatedTexture(RenderTexture.TextureGeneration.Disallow) : null; using ( var actualEvaluator = textureEvaluator ?? RenderTexture.NewBitmapTexture(st).CreateEvaluator(RenderTexture.TextureEvaluatorFlags.Normal)) { InternalMaterialBitmapFromEvaluator(shader, renderTexture, textureType, rhinotfm, rId, actualEvaluator, projectionMode, envProjectionMode); } } }
/// <summary> /// Add a CyclesShader and its shader /// </summary> /// <param name="s"></param> /// <param name="shader"></param> public void Add(CyclesShader s, CclShader shader) { _allShaders.Add(new Tuple<object, CclShader>(s, shader)); }
/// <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.Front.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, name, null) { }
public RhinoFullNxt(Client client, CyclesShader intermediate) : this(client, intermediate, null, intermediate.Name) { }
protected RhinoShader(Client client, CyclesShader intermediate) { m_client = client; m_original = intermediate; }
/// <summary> /// Add a CyclesShader to the list of shaders that will have to be committed to Cycles. /// </summary> /// <param name="shader"></param> public void AddShader(CyclesShader shader) { if (!_rhCclShaders.ContainsKey(shader.Id) && !_cqShaders.Contains(shader)) { _cqShaders.Add(shader); //_allShaders.Add(shader); } }
public RhinoFullNxt(Client client, CyclesShader intermediate, Shader existing) : this(client, intermediate, existing, intermediate.Name) { }
public static RhinoShader CreateRhinoMaterialShader(Client client, CyclesShader intermediate) { RhinoShader theShader = new RhinoFullNxt(client, intermediate); return theShader; }
public MaterialShaderUpdatedEventArgs(CyclesShader rcShader, CclShader cclShader) { RcShader = rcShader; CclShader = cclShader; }
public static RhinoShader RecreateRhinoMaterialShader(Client client, CyclesShader intermediate, Shader existing) { RhinoShader theShader = new RhinoFullNxt(client, intermediate, existing); return theShader; }
public RhinoFullNxt(Client client, CyclesShader intermediate, Shader existing) : this(client, intermediate, existing, intermediate.Front.Name) { }
public static void ReloadTextures(CyclesShader shader) { shader.ReloadTextures(ByteImagesNew, FloatImagesNew); }
public bool GetShader(Shader sh, bool finalize) { blendit = new ccl.ShaderNodes.MixClosureNode($"blendit{Serial}"); sh.AddNode(blendit); LinearWorkflow linearWorkflow = new LinearWorkflow(); linearWorkflow.PostProcessGamma = Gamma; linearWorkflow.PreProcessGamma = Gamma; linearWorkflow.PostProcessGammaOn = Gamma != 1.0f; linearWorkflow.PreProcessColors = linearWorkflow.PreProcessTextures = linearWorkflow.PostProcessGammaOn; RhinoCyclesCore.Converters.ShaderConverter sconv = new RhinoCyclesCore.Converters.ShaderConverter(); CyclesShader mat1sh = null; CyclesShader mat2sh = null; ICyclesMaterial crm1 = null; ICyclesMaterial crm2 = null; ClosureSocket crm1closure = null; ClosureSocket crm2closure = null; if (Mat1Rm != null) { if (Mat1Rm is ICyclesMaterial) { crm1 = Mat1Rm as ICyclesMaterial; crm1.Gamma = Gamma; crm1.GetShader(sh, false); crm1closure = crm1.GetClosureSocket(sh); } else { mat1sh = sconv.CreateCyclesShader(Mat1Rm, linearWorkflow, Mat1Rm.RenderHashExclude(CrcRenderHashFlags.ExcludeLinearWorkflow, "", linearWorkflow), BitmapConverter, null); mat1sh.Gamma = Gamma; BitmapConverter.ReloadTextures(mat1sh); } } if (Mat2Rm != null) { if (Mat2Rm is ICyclesMaterial) { crm2 = Mat2Rm as ICyclesMaterial; crm2.Gamma = Gamma; crm2.GetShader(sh, false); crm2closure = crm2.GetClosureSocket(sh); } else { mat2sh = sconv.CreateCyclesShader(Mat2Rm, linearWorkflow, Mat2Rm.RenderHashExclude(CrcRenderHashFlags.ExcludeLinearWorkflow, "", linearWorkflow), BitmapConverter, null); mat2sh.Gamma = Gamma; BitmapConverter.ReloadTextures(mat2sh); } } RhinoCyclesCore.Shaders.RhinoFullNxt fnMat1 = null; ClosureSocket fnMat1Closure = null; if (mat1sh != null) { fnMat1 = new RhinoCyclesCore.Shaders.RhinoFullNxt(null, mat1sh, sh, false); fnMat1Closure = fnMat1.GetClosureSocket(); } RhinoCyclesCore.Shaders.RhinoFullNxt fnMat2 = null; ClosureSocket fnMat2Closure = null; if (mat2sh != null) { fnMat2 = new RhinoCyclesCore.Shaders.RhinoFullNxt(null, mat2sh, sh, false); fnMat2Closure = fnMat2.GetClosureSocket(); } ccl.ShaderNodes.TextureCoordinateNode texco = new ccl.ShaderNodes.TextureCoordinateNode($"texcos{Serial}"); sh.AddNode(texco); ccl.ShaderNodes.DiffuseBsdfNode diffuse1Bsdf = new ccl.ShaderNodes.DiffuseBsdfNode(); diffuse1Bsdf.ins.Color.Value = Mat1; ccl.ShaderNodes.DiffuseBsdfNode diffuse2Bsdf = new ccl.ShaderNodes.DiffuseBsdfNode(); diffuse2Bsdf.ins.Color.Value = Mat2; sh.AddNode(diffuse1Bsdf); sh.AddNode(diffuse2Bsdf); blendit.ins.Fac.Value = Blend.Amount; ccl.ShaderNodes.ValueNode blendValue = new ccl.ShaderNodes.ValueNode("blendValue"); sh.AddNode(blendValue); blendValue.Value = Blend.Amount; GraphForSlot(sh, blendValue.outs.Value, Blend.On, Blend.Amount, BlendTex, blendit.ins.Fac.ToList(), texco, true); var sock1 = fnMat1Closure ?? crm1closure ?? diffuse1Bsdf.outs.BSDF; sock1.Connect(blendit.ins.Closure1); var sock2 = fnMat2Closure ?? crm2closure ?? diffuse2Bsdf.outs.BSDF; sock2.Connect(blendit.ins.Closure2); blendit.outs.Closure.Connect(sh.Output.ins.Surface); if (finalize) { sh.FinalizeGraph(); } return(true); }
internal void TriggerMaterialShaderChanged(CyclesShader rcShader, Shader cclShader) { MaterialShaderChanged?.Invoke(this, new MaterialShaderUpdatedEventArgs(rcShader, cclShader)); }