Exemple #1
0
        public static ResourceSet GenerateTextureResourceSetForCubeMapping <T>(ModelRuntimeDescriptor <T> modelRuntimeState, int meshIndex, DisposeCollectorResourceFactory factory, GraphicsDevice graphicsDevice) where T : struct, VertexLocateable
        {
            RealtimeMaterial material = modelRuntimeState.Model.GetMaterial(meshIndex);

            Image <Rgba32> front  = Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, modelRuntimeState.Model.BaseDir, material.cubeMapFront));
            Image <Rgba32> back   = Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, modelRuntimeState.Model.BaseDir, material.cubeMapBack));
            Image <Rgba32> left   = Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, modelRuntimeState.Model.BaseDir, material.cubeMapLeft));
            Image <Rgba32> right  = Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, modelRuntimeState.Model.BaseDir, material.cubeMapRight));
            Image <Rgba32> top    = Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, modelRuntimeState.Model.BaseDir, material.cubeMapTop));
            Image <Rgba32> bottom = Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, modelRuntimeState.Model.BaseDir, material.cubeMapBottom));

            TextureView cubeMapTextureView = ResourceGenerator.CreateCubeMapTextureViewFromImages(front,
                                                                                                  back,
                                                                                                  left,
                                                                                                  right,
                                                                                                  top,
                                                                                                  bottom,
                                                                                                  factory,
                                                                                                  graphicsDevice);



            return(factory.CreateResourceSet(new ResourceSetDescription(
                                                 modelRuntimeState.TextureResourceLayout,
                                                 cubeMapTextureView,
                                                 modelRuntimeState.TextureSampler
                                                 )));
        }
Exemple #2
0
        public static ResourceSet GenerateResourceSetForShadowMapping(ResourceLayout textureLayout, TextureView shadowMapTexView, DisposeCollectorResourceFactory factory)
        {
            var sampler = ResourceGenerator.GenerateBiLinearSampler_Border(factory);

            return(factory.CreateResourceSet(new ResourceSetDescription(
                                                 textureLayout,
                                                 shadowMapTexView,
                                                 sampler
                                                 )));
        }
Exemple #3
0
        public static ResourceSet GenerateTextureResourceSetForDiffuseMapping <T>(ModelRuntimeDescriptor <T> modelRuntimeState, int meshIndex, DisposeCollectorResourceFactory factory, GraphicsDevice graphicsDevice) where T : struct, VertexLocateable
        {
            RealtimeMaterial material = modelRuntimeState.Model.GetMaterial(meshIndex);

            ImageSharpTexture diffuseTextureIS   = new ImageSharpTexture(Path.Combine(AppContext.BaseDirectory, modelRuntimeState.Model.BaseDir, material.textureDiffuse));
            Texture           diffuseTexture     = diffuseTextureIS.CreateDeviceTexture(graphicsDevice, factory);
            TextureView       diffuseTextureView = factory.CreateTextureView(diffuseTexture);

            return(factory.CreateResourceSet(new ResourceSetDescription(
                                                 modelRuntimeState.TextureResourceLayout,
                                                 diffuseTextureView,
                                                 modelRuntimeState.TextureSampler
                                                 )));
        }
Exemple #4
0
        public static ResourceSet GenrateResourceSet(DisposeCollectorResourceFactory factory, ResourceLayout resourceLayout, BindableResource[] bindableResources)
        {
            ResourceSetDescription resourceSetDescription = new ResourceSetDescription(resourceLayout, bindableResources);

            return(factory.CreateResourceSet(resourceSetDescription));
        }