public static EnergyWindowMaterialGlazing ToLadybugTools(this TransparentMaterial transparentMaterial, double thickness) { if (transparentMaterial == null || string.IsNullOrEmpty(transparentMaterial.Name)) { return(null); } return(new EnergyWindowMaterialGlazing( identifier: transparentMaterial.Name, displayName: transparentMaterial.DisplayName, userData: null, thickness: thickness, solarTransmittance: transparentMaterial.GetValue <double>(TransparentMaterialParameter.SolarTransmittance), solarReflectance: transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalSolarReflectance), solarReflectanceBack: transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalSolarReflectance), visibleTransmittance: transparentMaterial.GetValue <double>(TransparentMaterialParameter.LightTransmittance), visibleReflectance: transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalLightReflectance), visibleReflectanceBack: transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalLightReflectance), infraredTransmittance: 0, emissivity: transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalEmissivity), emissivityBack: transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalEmissivity), conductivity: transparentMaterial.ThermalConductivity, dirtCorrection: 1, solarDiffusing: false)); }
public static bool UpdateMaterial(this TBD.material material, TransparentMaterial transparentMaterial) { if (!string.IsNullOrWhiteSpace(transparentMaterial.Name) && !transparentMaterial.Name.Equals(material.name)) { material.name = transparentMaterial.Name; } material.type = (int)TBD.MaterialTypes.tcdTransparentLayer; material.description = transparentMaterial.Description; material.width = System.Convert.ToSingle(transparentMaterial.GetValue <double>(MaterialParameter.DefaultThickness)); material.conductivity = System.Convert.ToSingle(transparentMaterial.ThermalConductivity); material.vapourDiffusionFactor = System.Convert.ToSingle(transparentMaterial.GetValue <double>(MaterialParameter.VapourDiffusionFactor)); material.solarTransmittance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.SolarTransmittance)); material.externalSolarReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalSolarReflectance)); material.internalSolarReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalSolarReflectance)); material.lightTransmittance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.LightTransmittance)); material.externalLightReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalLightReflectance)); material.internalLightReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalLightReflectance)); material.externalEmissivity = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalEmissivity)); material.internalEmissivity = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalEmissivity)); if (transparentMaterial.GetValue <bool>(TransparentMaterialParameter.IsBlind)) { material.isBlind = 1; } else { material.isBlind = 0; } return(true); }
private void CreateMaterial(string name, Texture2D texture) { Material material = null; if (name.Contains("_alpha")) { material = new TransparentMaterial(this, name.Replace("_alpha", "")); } else { material = new StandardMaterial(this, name); } material.Texture = texture; }
public ForwardTransparent(TransparentMaterial material) { _material = material; }
public static Material ToSAM(this Autodesk.Revit.DB.Material material, ConvertSettings convertSettings) { if (material == null) { return(null); } Material result = convertSettings?.GetObject <Material>(material.Id); if (result != null) { return(result); } Document document = material.Document; double density = double.NaN; double thermalConductivity = double.NaN; ThermalMaterialType thermalMaterialType = ThermalMaterialType.Undefined; bool transmitsLight = false; ElementId elementId = material.ThermalAssetId; if (elementId != null && elementId != ElementId.InvalidElementId) { PropertySetElement propertySetElement = document.GetElement(elementId) as PropertySetElement; if (propertySetElement != null) { ThermalAsset thermalAsset = propertySetElement.GetThermalAsset(); if (thermalAsset != null) { density = thermalAsset.Density; thermalConductivity = thermalAsset.ThermalConductivity; thermalMaterialType = thermalAsset.ThermalMaterialType; transmitsLight = thermalAsset.TransmitsLight; } } } string description = material.get_Parameter(BuiltInParameter.ALL_MODEL_DESCRIPTION)?.AsString(); if (thermalMaterialType != ThermalMaterialType.Undefined) { switch (thermalMaterialType) { case ThermalMaterialType.Gas: result = new GasMaterial(System.Guid.NewGuid(), material.Name, material.Name, description, thermalConductivity, density, double.NaN, double.NaN); break; case ThermalMaterialType.Liquid: result = new LiquidMaterial(System.Guid.NewGuid(), material.Name, material.Name, description, thermalConductivity, density, double.NaN, double.NaN); break; case ThermalMaterialType.Solid: if (transmitsLight) { result = new TransparentMaterial(material.Name, null, material.Name, description, thermalConductivity, double.NaN, density); } else { result = new OpaqueMaterial(material.Name, null, material.Name, description, thermalConductivity, double.NaN, density); } break; } } if (result == null) { string materialClass = material.MaterialClass?.Trim(); if (string.IsNullOrWhiteSpace(materialClass)) { switch (materialClass.ToLower()) { case "glass": result = new TransparentMaterial(material.Name, materialClass, material.Name, description, thermalConductivity, double.NaN, density); break; case "gas": result = new GasMaterial(System.Guid.NewGuid(), material.Name, material.Name, description, thermalConductivity, density, double.NaN, double.NaN); break; case "ceramic": case "earth": case "brass": case "metal": case "wood": case "concrete": case "masonry": case "paint": case "paint/coating": case "plastic": case "stone": case "textile": result = new OpaqueMaterial(material.Name, materialClass, material.Name, description, thermalConductivity, double.NaN, density); break; case "liquid": result = new LiquidMaterial(System.Guid.NewGuid(), material.Name, material.Name, description, thermalConductivity, density, double.NaN, double.NaN); break; } } } if (result == null) { int transparency = material.Transparency; if (transparency < 10) { result = new OpaqueMaterial(material.Name, null, material.Name, description, thermalConductivity, double.NaN, density); } else if (transparency < 100) { result = new TransparentMaterial(material.Name, null, material.Name, description, thermalConductivity, double.NaN, density); } else { result = new GasMaterial(System.Guid.NewGuid(), material.Name, material.Name, description, thermalConductivity, double.NaN, density, double.NaN); } } if (result != null) { convertSettings?.Add(material.Id, result); } return(result); }
public DeferredTransparent(TransparentMaterial material) : base(material) { }
public void CreateScene(int width, int height, FloatColor color, bool useAntialiasing) { var renderTarget = new Framebuffer(width, height); var reflectiveFloor = new ReflectiveMaterial(FloatColor.White, 0.4f, 1, 300, 0.5f); var crystalMaterial = new PbrMaterial(FloatColor.White, Texture.LoadFrom(@"_Resources/Textures/crystal-green.png").ToInfo(1), Texture.LoadFrom(@"_Resources/Textures/crystal-green.png").ToInfo(1), Texture.LoadFrom(@"_Resources/Textures/crystal-roughness.png").ToInfo(1), Texture.LoadFrom(@"_Resources/Textures/crystal-normals.png").ToInfo(1)) { EmissionFactor = 1, DiffuseCoefficient = 1, Specular = 10, SpecularExponent = 50, AmbientPower = 1 }; var reflectiveCrystal = new ReflectiveMaterial(FloatColor.White, 0.7f, 0.5f, 1000, 0.6f); var transparentCrystal = new TransparentMaterial(FloatColor.White, 0.1f, 0, 0.3f, 1.05f, 0.9f); var transparentSphere = new TransparentMaterial(FloatColor.White, 0.1f, 0, 0.3f, 1.05f, 0.9f); var crystal = Model.LoadFromFile("_Resources/Models/crystal.obj", crystalMaterial, 1.5f); var crystal2 = Model.LoadFromFile("_Resources/Models/crystal.obj", reflectiveCrystal, 1.5f, Vector3.Left * 1.5f, Vector3.Forward, 45); var crystal3 = Model.LoadFromFile("_Resources/Models/crystal.obj", transparentCrystal, 1.5f, Vector3.Right * 1.5f, Vector3.Forward, -45); renderTarget.Clear(color); var objects = new List <IHittable> { new Plane(new Vector3(-2, 0, 0), new Vector3(1, 0, 0), reflectiveFloor), new Plane(new Vector3(2, 0, 0), new Vector3(-1, 0, 0), reflectiveFloor), new Plane(new Vector3(5, -2f, 0), new Vector3(0, 1, 0), reflectiveFloor), new Plane(new Vector3(5, 2f, 0), new Vector3(0, -1, 0), reflectiveFloor), new Plane(new Vector3(0, 2, 6), new Vector3(0, 0, -1), reflectiveFloor), new Plane(new Vector3(0, 2, -8), new Vector3(0, 0, 1), reflectiveFloor), new Sphere(Vector3.Zero, 1, transparentSphere) }; objects.Add(crystal); objects.Add(crystal2); objects.Add(crystal3); var sampler = new Sampler(new RegularGenerator(), new SquareDistributor(), 25, 1); var camera = new PerspectiveCamera(renderTarget, new Vector3(0f, 0, -5), Vector3.Forward, Vector3.Up) { Sampler = sampler, MaxDepth = 5, }; Scene = new Scene(objects, camera, new List <Light> { new PointLight { Position = new Vector3(0, 0, 5), Color = FloatColor.White, Intensity = 1 } }, FloatColor.Black); }
public void CreateScene(int width, int height, FloatColor color, bool useAntialiasing) { var renderTarget = new Framebuffer(width, height); renderTarget.Clear(color); var objects = new List <IHittable>(); var sierpinsky = Texture.CreateFrom(FractalGenerator.SierpinskyCarpet(100, 100, Color.White, Color.Black)) .ToInfo(); var reflectiveMaterial = new ReflectiveMaterial(FloatColor.White, 0.4f, 1, 300, 1f, sierpinsky); var transparentMaterial = new TransparentMaterial(FloatColor.White, 0.1f, 0, 0.3f, 1.05f, 0.9f); var circuitryMaterial = new PbrMaterial(FloatColor.White, Texture.LoadFrom(@"_Resources/Textures/circuitry-albedo.png").ToInfo(0.25f), Texture.LoadFrom(@"_Resources/Textures/circuitry-emission.png").ToInfo(0.25f), Texture.LoadFrom(@"_Resources/Textures/circuitry-smoothness.png").ToInfo(0.25f), Texture.LoadFrom(@"_Resources/Textures/circuitry-normals.png").ToInfo(0.25f)) { EmissionFactor = 2, DiffuseCoefficient = 1, Specular = 10, SpecularExponent = 50, AmbientPower = 1 }; var greenLavaMaterial = new PbrMaterial(FloatColor.White, Texture.LoadFrom(@"_Resources/Textures/lava-albedo-smoothness-green.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/lava-emission-green.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/lava-albedo-smoothness.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/lava-normals.png").ToInfo(3)) { EmissionFactor = 4, DiffuseCoefficient = 1, Specular = 10, SpecularExponent = 50, AmbientPower = 1 }; var reflectiveSphere = new Sphere(new Vector3(2f, -1f, 4), 1f, reflectiveMaterial); var transparentSphere = new Sphere(new Vector3(0f, -1f, 2), 1f, transparentMaterial); var textureSphere = new Sphere(new Vector3(-1.5f, -1.5f, 3), 0.5f, greenLavaMaterial); objects.Add(reflectiveSphere); objects.Add(transparentSphere); objects.Add(textureSphere); objects.Add(new Plane(new Vector3(5, -2f, 0), new Vector3(0, 1, 0), circuitryMaterial)); var sampler = new Sampler(new JitteredGenerator(0), new SquareDistributor(), 16, 32); var camera = new PerspectiveCamera(renderTarget, new Vector3(0f, 0, -5), Vector3.Forward, Vector3.Up) { Sampler = sampler, MaxDepth = 6, }; Scene = new Scene(objects, camera, new List <Light> { new PointLight { Position = new Vector3(1, 1, 0), Color = FloatColor.White, }, new PointLight { Position = new Vector3(-1, 1, 0), Color = FloatColor.White, }, new PointLight { Position = new Vector3(-2, 2, 15), Color = FloatColor.White, Intensity = 1 }, new PointLight { Position = new Vector3(1, 1f, 0), Color = FloatColor.Green, }, new PointLight { Position = new Vector3(-2, -1f, 0), Color = FloatColor.Red, }, }, FloatColor.Black); }
public void CreateScene(int width, int height, FloatColor color, bool useAntialiasing) { var renderTarget = new Framebuffer(width, height); renderTarget.Clear(color); var objects = new List <IHittable>(); var reflectiveMaterial = new ReflectiveMaterial(FloatColor.White, 0.4f, 1, 300, 1f); var transparentMaterial = new TransparentMaterial(FloatColor.White, 0.1f, 0, 1, 3, 1); var reflectiveFloor = new ReflectiveMaterial(FloatColor.White, 0.4f, 1, 300, 0.5f); var circuitryMaterial = new PbrMaterial(FloatColor.White, Texture.LoadFrom(@"_Resources/Textures/circuitry-albedo.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/circuitry-emission.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/circuitry-smoothness.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/circuitry-normals.png").ToInfo(3)) { EmissionFactor = 2, DiffuseCoefficient = 1, Specular = 10, SpecularExponent = 50, AmbientPower = 1 }; var sphereTextureMaterial = new PbrMaterial(FloatColor.White, Texture.LoadFrom(@"_Resources/Textures/lava-albedo-smoothness-green.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/lava-emission-green.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/lava-albedo-smoothness.png").ToInfo(3), Texture.LoadFrom(@"_Resources/Textures/lava-normals.png").ToInfo(3)) { EmissionFactor = 4, DiffuseCoefficient = 1, Specular = 10, SpecularExponent = 50, AmbientPower = 1 }; var reflectiveSphere = new Sphere(new Vector3(-0.5f, -1.5f, 3), 0.5f, reflectiveMaterial); var transparentSphere = new Sphere(new Vector3(0.5f, -1.5f, 3), 0.5f, transparentMaterial); var textureSphere = new Sphere(new Vector3(-1.5f, -1.5f, 3), 0.5f, sphereTextureMaterial); var specialSphere = new Sphere(new Vector3(1.5f, -1.5f, 3), 0.5f, circuitryMaterial); var reflectiveSphere1 = new Sphere(new Vector3(1.5f, -0.5f, 3), 0.5f, reflectiveMaterial); var transparentSphere1 = new Sphere(new Vector3(-1.5f, -0.5f, 3), 0.5f, transparentMaterial); var textureSphere1 = new Sphere(new Vector3(-0.5f, -0.5f, 3), 0.5f, sphereTextureMaterial); var specialSphere1 = new Sphere(new Vector3(0.5f, -0.5f, 3), 0.5f, circuitryMaterial); var reflectiveSphere2 = new Sphere(new Vector3(-1.5f, 0.5f, 3), 0.5f, reflectiveMaterial); var transparentSphere2 = new Sphere(new Vector3(1.5f, 0.5f, 3), 0.5f, transparentMaterial); var textureSphere2 = new Sphere(new Vector3(0.5f, 0.5f, 3), 0.5f, sphereTextureMaterial); var specialSphere2 = new Sphere(new Vector3(-0.5f, 0.5f, 3), 0.5f, circuitryMaterial); var reflectiveSphere3 = new Sphere(new Vector3(0.5f, 1.5f, 3), 0.5f, reflectiveMaterial); var transparentSphere3 = new Sphere(new Vector3(-0.5f, 1.5f, 3), 0.5f, transparentMaterial); var textureSphere3 = new Sphere(new Vector3(1.5f, 1.5f, 3), 0.5f, sphereTextureMaterial); var specialSphere3 = new Sphere(new Vector3(-1.5f, 1.5f, 3), 0.5f, circuitryMaterial); objects.Add(new Plane(new Vector3(-2, 0, 0), new Vector3(1, 0, 0), reflectiveFloor)); objects.Add(new Plane(new Vector3(2, 0, 0), new Vector3(-1, 0, 0), reflectiveFloor)); objects.Add(new Plane(new Vector3(5, -2f, 0), new Vector3(0, 1, 0), reflectiveFloor)); objects.Add(new Plane(new Vector3(5, 2f, 0), new Vector3(0, -1, 0), reflectiveFloor)); objects.Add(new Plane(new Vector3(0, 2, 6), new Vector3(0, 0, -1), reflectiveFloor)); objects.Add(new Plane(new Vector3(0, 2, -8), new Vector3(0, 0, 1), reflectiveFloor)); objects.Add(reflectiveSphere); objects.Add(transparentSphere); objects.Add(textureSphere); objects.Add(specialSphere); objects.Add(reflectiveSphere1); objects.Add(transparentSphere1); objects.Add(textureSphere1); objects.Add(specialSphere1); objects.Add(reflectiveSphere2); objects.Add(transparentSphere2); objects.Add(textureSphere2); objects.Add(specialSphere2); objects.Add(reflectiveSphere3); objects.Add(transparentSphere3); objects.Add(textureSphere3); objects.Add(specialSphere3); var sampler = new Sampler(new JitteredGenerator(0), new SquareDistributor(), 16, 32); var camera = new PerspectiveCamera(renderTarget, new Vector3(0f, 0, -5), Vector3.Forward, Vector3.Up) { Sampler = sampler, MaxDepth = 4 }; Scene = new Scene(objects, camera, new List <Light> { new PointLight { Position = new Vector3(0, 0, 3), Color = FloatColor.White, Sampler = sampler }, new PointLight { Position = new Vector3(0, 0, 0), Color = FloatColor.White / 2, Sampler = sampler }, // new PointLight // { // Position = new Vector3(1, 1f, 0), // Color = FloatColor.Purple, // // Sampler = sampler // }, // new PointLight // { // Position = new Vector3(-2, -1f, 0), // Color = FloatColor.Green, // // Sampler = sampler // }, }, FloatColor.Black); }
public void CreateScene(int width, int height, FloatColor color, bool useAntialiasing) { var renderTarget = new Framebuffer(width, height); renderTarget.Clear(color); var objects = new List <IHittable>(); var reflectiveMaterial = new ReflectiveMaterial(FloatColor.White, 0.4f, 1, 300, 1f); var transparentMaterial = new TransparentMaterial(FloatColor.White, 0.1f, 0, 1, 3, 1); var whiteWallMaterial = new PhongMaterial(FloatColor.White, 1, 0, 50, 1); var reflectiveSphere = new Sphere(new Vector3(-1.25f, 0, 3), 1f, reflectiveMaterial); var transparentSphere = new Sphere(new Vector3(1.25f, 0, -1), 1f, transparentMaterial); objects.Add(new Plane(new Vector3(-4, 0, 0), new Vector3(1, 0, 0), whiteWallMaterial)); objects.Add(new Plane(new Vector3(4, 0, 0), new Vector3(-1, 0, 0), whiteWallMaterial)); objects.Add(new Plane(new Vector3(5, -2, 0), new Vector3(0, 1, 0), whiteWallMaterial)); objects.Add(new Plane(new Vector3(5, 2, 0), new Vector3(0, -1, 0), whiteWallMaterial)); objects.Add(new Plane(new Vector3(0, 2, 6), new Vector3(0, 0, -1), whiteWallMaterial)); objects.Add(new Plane(new Vector3(0, 2, -8), new Vector3(0, 0, 1), whiteWallMaterial)); objects.Add(reflectiveSphere); objects.Add(transparentSphere); var crystalMaterial = new PbrMaterial(FloatColor.White, Texture.LoadFrom(@"_Resources/Textures/crystal.png").ToInfo(), Texture.LoadFrom(@"_Resources/Textures/crystal.png").ToInfo(), null, Texture.LoadFrom(@"_Resources/Textures/crystal-normals.png").ToInfo()); var crystal = Model.LoadFromFile("_Resources/Models/crystal.obj", crystalMaterial, 2f, Vector3.Zero); objects.Add(crystal); var sampler = new Sampler(new JitteredGenerator(0), new SquareDistributor(), 64, 64); var camera = new PerspectiveCamera(renderTarget, new Vector3(0f, 0, -6), Vector3.Forward, Vector3.Up) { Sampler = sampler, MaxDepth = 4 }; Scene = new Scene(objects, camera, new List <Light> { new PointLight { Position = new Vector3(-1, 0f, 0), Color = FloatColor.Blue, Sampler = sampler }, new PointLight { Position = new Vector3(1, 1f, 0), Color = FloatColor.Purple, Sampler = sampler }, new PointLight { Position = new Vector3(-2, -1f, 0), Color = FloatColor.Green, Sampler = sampler }, }, FloatColor.Black); }