static void CreateMeshScene(Scene <PositionNormalCoordinate, Material> scene) { string rugose_texture_t = "texture.jpg"; Texture2D rugose_texture = Texture2DFunctions.LoadTextureFromJPG(rugose_texture_t); Texture2D tableTexture = new Texture2D(1, 1); tableTexture.Write(0, 0, float4(1f, 1f, 0.8f, 1)); scene.Add(Raycasting.PlaneXZ.AttributesMap(a => new PositionNormalCoordinate { Position = a, Coordinates = float2(a.x, a.z), Normal = float3(0, 1, 0) }), new Material { Diffuse = tableTexture, TextureSampler = new Sampler { Wrap = WrapMode.Repeat }, Specular = float3(1, 1, 1), SpecularPower = 50, Glossyness = 0.2f }, Transforms.Identity); //Table Texture2D wallTexture = new Texture2D(1, 1); wallTexture.Write(0, 0, float4(0.86f, 0.76f, 0.75f, 1)); scene.Add(Raycasting.PlaneYZ.AttributesMap(a => new PositionNormalCoordinate { Position = a, Coordinates = float2(a.y, a.z), Normal = float3(-1, 0, 0) }), new Material { Diffuse = wallTexture, TextureSampler = new Sampler { Wrap = WrapMode.Repeat } }, mul(Transforms.Translate(10f, 0, 0), Transforms.Identity)); //Wall CoffeeMakerModel <PositionNormalCoordinate> CoffeeMaker = new CoffeeMakerModel <PositionNormalCoordinate>(); Mesh <PositionNormalCoordinate> plastic_model = CoffeeMaker.GetPlasticMesh(); plastic_model.ComputeNormals(); Mesh <PositionNormalCoordinate> metal_model = CoffeeMaker.GetMetalMesh(); metal_model.ComputeNormals(); Texture2D plasticTexture = new Texture2D(1, 1); plasticTexture.Write(0, 0, float4(0.1f, 0.1f, 0.1f, 1)); Texture2D metalTexture = new Texture2D(1, 1); metalTexture.Write(0, 0, float4(1f, 1f, 1f, 1)); scene.Add(plastic_model.AsRaycast(), new Material { Diffuse = plasticTexture, TextureSampler = new Sampler { Wrap = WrapMode.Repeat } }, Transforms.Identity); scene.Add(metal_model.AsRaycast(), new Material { Diffuse = rugose_texture, TextureSampler = new Sampler { Wrap = WrapMode.Repeat }, Specular = float3(0.5f, 0.5f, 0.5f), SpecularPower = 1f, Glossyness = 0.95f }, Transforms.Identity); }
static void CreateMeshScene(Scene <PositionNormalCoordinate, Material> scene) { string wood_texture_t = "wood.jpeg"; Texture2D wood_texture = Texture2DFunctions.LoadFromFile(wood_texture_t); scene.Add(Raycasting.PlaneXZ.AttributesMap(a => new PositionNormalCoordinate { Position = a, Coordinates = float2(a.z * 0.1f, a.x * 0.1f), Normal = float3(0, 1, 0) }), new Material { DiffuseMap = wood_texture, Diffuse = float3(1, 1, 1), TextureSampler = new Sampler { Wrap = WrapMode.Repeat }, Specular = float3(1, 1, 1), SpecularPower = 50, WeightGlossy = 0.2f }, Transforms.Identity); //Table Texture2D wallTexture = new Texture2D(1, 1); wallTexture.Write(0, 0, float4(0.86f, 0.76f, 0.75f, 1)); scene.Add(Raycasting.PlaneYZ.AttributesMap(a => new PositionNormalCoordinate { Position = a, Coordinates = float2(a.y, a.z), Normal = float3(-1, 0, 0) }), new Material { DiffuseMap = wallTexture, Diffuse = float3(1, 1, 1), TextureSampler = new Sampler { Wrap = WrapMode.Repeat } }, mul(Transforms.Translate(10f, 0, 0), Transforms.Identity)); //Wall CoffeeMakerModel <PositionNormalCoordinate> CoffeeMaker = new CoffeeMakerModel <PositionNormalCoordinate>(); Mesh <PositionNormalCoordinate> plastic_model = CoffeeMaker.GetPlasticMesh(); plastic_model.ComputeNormals(); Mesh <PositionNormalCoordinate> metal_model = CoffeeMaker.GetMetalMesh(); metal_model.ComputeNormals(); Mesh <PositionNormalCoordinate> valve_model = CoffeeMaker.GetValveMesh(); valve_model.ComputeNormals(); Texture2D plasticTexture = new Texture2D(1, 1); plasticTexture.Write(0, 0, float4(0.1f, 0.1f, 0.1f, 1)); Texture2D metalTexture = new Texture2D(1, 1); metalTexture.Write(0, 0, float4(1f, 1f, 1f, 1)); string rugose_texture_t = "texture.jpeg"; Texture2D rugose_texture = Texture2DFunctions.LoadFromFile(rugose_texture_t); string golden_texture_t = "valve.jpg"; Texture2D golden_texture = Texture2DFunctions.LoadFromFile(golden_texture_t); scene.Add(plastic_model.AsRaycast(), new Material { DiffuseMap = plasticTexture, Diffuse = float3(1, 1, 1), TextureSampler = new Sampler { Wrap = WrapMode.Repeat }, Specular = float3(1f, 1f, 1f), WeightGlossy = 0.05f }, Transforms.Identity); scene.Add(metal_model.AsRaycast(), new Material { DiffuseMap = rugose_texture, Diffuse = float3(0.4f, 0.4f, 0.4f), TextureSampler = new Sampler { Wrap = WrapMode.Repeat }, Specular = float3(1f, 1f, 1f), SpecularPower = 10f, WeightMirror = 0.02f, WeightGlossy = 0.2f }, Transforms.Identity); scene.Add(valve_model.AsRaycast(), new Material { DiffuseMap = golden_texture, Diffuse = float3(0.4f, 0.4f, 0.4f), TextureSampler = new Sampler { Wrap = WrapMode.Repeat }, Specular = float3(1f, 1f, 1f), SpecularPower = 1f, WeightMirror = 0.02f, WeightGlossy = 0.3f }, Transforms.Identity); var sphereModel = Raycasting.UnitarySphere.AttributesMap(a => new PositionNormalCoordinate { Position = a, Coordinates = float2(atan2(a.z, a.x) * 0.5f / pi + 0.5f, a.y), Normal = normalize(a) }); // Light sources foreach (var light in Lights) { scene.Add(sphereModel, new Material { Emissive = LightIntensityPath / (4 * pi), // power per unit area WeightDiffuse = 0, WeightFresnel = 1.0f, // Glass sphere RefractionIndex = 1.0f }, mul(Transforms.Scale(10f, 10f, 10f), Transforms.Translate(light))); } }