public DiffuseMaterial(DiffuseMaterialCore core) : base(core) { DiffuseColor = core.DiffuseColor; DiffuseMap = core.DiffuseMap; UVTransform = core.UVTransform; DiffuseMapSampler = core.DiffuseMapSampler; EnableUnLit = core.EnableUnLit; }
public DiffuseMaterial(DiffuseMaterialCore core) : base(core) { DiffuseColor = core.DiffuseColor; DiffuseMap = core.DiffuseMap; UVTransform = core.UVTransform; DiffuseMapSampler = core.DiffuseMapSampler; EnableUnLit = core.EnableUnLit; EnableFlatShading = core.EnableFlatShading; VertexColorBlendingFactor = core.VertexColorBlendingFactor; }
/// <summary> /// Initializes a new instance of the <see cref="DiffuseMaterialVariables"/> class. /// </summary> /// <param name="manager">The manager.</param> /// <param name="technique">The technique.</param> /// <param name="materialCore">The material core.</param> /// <param name="materialPassName">Name of the material pass.</param> /// <param name="wireframePassName">Name of the wireframe pass.</param> /// <param name="materialOITPassName">Name of the material oit pass.</param> /// <param name="wireframeOITPassName">Name of the wireframe oit pass.</param> /// <param name="shadowPassName">Name of the shadow pass.</param> private DiffuseMaterialVariables(IEffectsManager manager, IRenderTechnique technique, DiffuseMaterialCore materialCore, string materialPassName = DefaultPassNames.Default, string wireframePassName = DefaultPassNames.Wireframe, string materialOITPassName = DefaultPassNames.OITPass, string wireframeOITPassName = DefaultPassNames.OITPass, string shadowPassName = DefaultPassNames.ShadowPass) : base(manager, technique, DefaultMeshConstantBufferDesc, materialCore) { this.material = materialCore; texDiffuseSlot = -1; samplerDiffuseSlot = samplerShadowSlot = -1; textureManager = manager.MaterialTextureManager; statePoolManager = manager.StateManager; MaterialPass = technique[materialPassName]; TransparentPass = technique[materialOITPassName]; ShadowPass = technique[shadowPassName]; WireframePass = technique[wireframePassName]; WireframeOITPass = technique[wireframeOITPassName]; UpdateMappings(MaterialPass); CreateTextureViews(); CreateSamplers(); }
/// <summary> /// Initializes a new instance of the <see cref="DiffuseMaterialVariables"/> class. /// </summary> /// <param name="manager">The manager.</param> /// <param name="technique">The technique.</param> /// <param name="materialCore">The material core.</param> /// <param name="defaultPassName"></param> private DiffuseMaterialVariables(IEffectsManager manager, IRenderTechnique technique, DiffuseMaterialCore materialCore, string defaultPassName = DefaultPassNames.Default) : base(manager, technique, DefaultMeshConstantBufferDesc, materialCore) { this.material = materialCore; texDiffuseSlot = -1; samplerDiffuseSlot = samplerShadowSlot = -1; textureManager = manager.MaterialTextureManager; statePoolManager = manager.StateManager; MaterialPass = technique[defaultPassName]; OITPass = technique[DefaultPassNames.DiffuseOIT]; OITDepthPeelingInit = technique[DefaultPassNames.OITDepthPeelingInit]; OITDepthPeeling = technique[DefaultPassNames.DiffuseOITDP]; ShadowPass = technique[DefaultPassNames.ShadowPass]; WireframePass = technique[DefaultPassNames.Wireframe]; WireframeOITPass = technique[DefaultPassNames.WireframeOITPass]; WireframeOITDPPass = technique[DefaultPassNames.WireframeOITDPPass]; DepthPass = technique[DefaultPassNames.DepthPrepass]; UpdateMappings(MaterialPass); CreateTextureViews(); CreateSamplers(); }
/// <summary> /// To the helix material. /// </summary> /// <param name="material">The material.</param> /// <returns></returns> /// <exception cref="System.NotSupportedException">Shading Mode {material.ShadingMode}</exception> protected virtual KeyValuePair <global::Assimp.Material, MaterialCore> OnCreateHelixMaterial(global::Assimp.Material material) { MaterialCore core = null; if (!material.HasShadingMode) { if (material.HasNonTextureProperty(GLTFMatKeys.AI_MATKEY_GLTF_METALLIC_FACTOR) || material.HasNonTextureProperty(GLTFMatKeys.AI_MATKEY_GLTF_ROUGHNESS_FACTOR) || material.HasNonTextureProperty(GLTFMatKeys.AI_MATKEY_GLTF_BASECOLOR_FACTOR)) { material.ShadingMode = ShadingMode.Fresnel; } else if (material.HasColorSpecular || material.HasColorDiffuse || material.HasTextureDiffuse) { material.ShadingMode = ShadingMode.Blinn; } else { material.ShadingMode = ShadingMode.Gouraud; } } var mode = material.ShadingMode; if (Configuration.ImportMaterialType != MaterialType.Auto) { switch (Configuration.ImportMaterialType) { case MaterialType.BlinnPhong: mode = ShadingMode.Blinn; break; case MaterialType.Diffuse: mode = ShadingMode.Gouraud; break; case MaterialType.PBR: mode = ShadingMode.Fresnel; break; case MaterialType.VertexColor: core = new ColorMaterialCore(); break; case MaterialType.Normal: core = new NormalMaterialCore(); break; case MaterialType.Position: core = new PositionMaterialCore(); break; } } if (core == null) { switch (mode) { case ShadingMode.Blinn: case ShadingMode.Phong: case ShadingMode.None: core = OnCreatePhongMaterial(material); break; case ShadingMode.CookTorrance: case ShadingMode.Fresnel: case ShadingMode.OrenNayar: core = OnCreatePBRMaterial(material); break; case ShadingMode.Gouraud: var diffuse = new DiffuseMaterialCore { DiffuseColor = material.ColorDiffuse.ToSharpDXColor4() }; if (material.HasOpacity) { var c = diffuse.DiffuseColor; c.Alpha = material.Opacity; diffuse.DiffuseColor = c; } if (material.HasTextureDiffuse) { diffuse.DiffuseMap = LoadTexture(material.TextureDiffuse.FilePath); diffuse.DiffuseMapFilePath = material.TextureDiffuse.FilePath; } if (material.ShadingMode == ShadingMode.Flat) { diffuse.EnableFlatShading = true; } core = diffuse; break; case ShadingMode.Flat: core = OnCreatePhongMaterial(material); if (core is PhongMaterialCore p) { p.EnableFlatShading = true; } break; default: switch (Configuration.ImportMaterialType) { case MaterialType.Position: core = new PositionMaterialCore(); break; case MaterialType.Normal: core = new NormalMaterialCore(); break; default: Log(HelixToolkit.Logger.LogLevel.Warning, $"Shading Mode is not supported:{material.ShadingMode}"); core = new DiffuseMaterialCore() { DiffuseColor = Color.Red, EnableUnLit = true }; break; } break; } } if (core != null) { core.Name = string.IsNullOrEmpty(material.Name) ? $"Material_{Interlocked.Increment(ref MaterialIndexForNoName)}" : material.Name; } return(new KeyValuePair <global::Assimp.Material, MaterialCore>(material, core)); }
/// <summary> /// Initializes a new instance of the <see cref="DiffuseMaterialVariables"/> class. This construct will be using the PassName pass into constructor only. /// </summary> /// <param name="passName">Name of the pass.</param> /// <param name="manager">The manager.</param> /// <param name="technique"></param> /// <param name="material">The material.</param> public DiffuseMaterialVariables(string passName, IEffectsManager manager, IRenderTechnique technique, DiffuseMaterialCore material) : this(manager, technique, material) { MaterialPass = technique[passName]; }
/// <summary> /// Adds the properties. /// </summary> /// <param name="diffuse">The diffuse.</param> /// <param name="assimpMaterial">The assimp material.</param> protected virtual void AddProperties(DiffuseMaterialCore diffuse, global::Assimp.Material assimpMaterial) { assimpMaterial.ShadingMode = ShadingMode.Gouraud; assimpMaterial.AddProperty(new MaterialProperty(AiMatKeys.COLOR_DIFFUSE_BASE, diffuse.DiffuseColor.ToAssimpColor4D())); }