Example #1
0
        public async Task ReloadDefalutResources(ProcessingList processingList, MiscProcessContext miscProcessContext)
        {
            for (int i = 0; i < CameraDataBuffers.Length; i++)
            {
                CameraDataBuffers[i].Reload(deviceResources, c_presentDataSize);
            }
            for (int i = 0; i < LightCameraDataBuffers.Length; i++)
            {
                LightCameraDataBuffers[i].Reload(deviceResources, c_presentDataSize);
            }
            HighResolutionShadowNow = true;
            ChangeShadowMapsQuality(processingList, false);

            Uploader upTexLoading = new Uploader();
            Uploader upTexError   = new Uploader();

            upTexLoading.Texture2DPure(1, 1, new Vector4(0, 1, 1, 1));
            upTexError.Texture2DPure(1, 1, new Vector4(1, 0, 1, 1));;
            processingList.AddObject(new Texture2DUploadPack(TextureLoading, upTexLoading));
            processingList.AddObject(new Texture2DUploadPack(TextureError, upTexError));
            Uploader upTexPostprocessBackground = new Uploader();

            upTexPostprocessBackground.Texture2DPure(64, 64, new Vector4(1, 1, 1, 0));
            processingList.AddObject(new Texture2DUploadPack(postProcessBackground, upTexPostprocessBackground));

            Uploader upTexEnvCube = new Uploader();

            upTexEnvCube.TextureCubePure(32, 32, new Vector4[] { new Vector4(0.2f, 0.16f, 0.16f, 1), new Vector4(0.16f, 0.2f, 0.16f, 1), new Vector4(0.2f, 0.2f, 0.2f, 1), new Vector4(0.16f, 0.2f, 0.2f, 1), new Vector4(0.2f, 0.2f, 0.16f, 1), new Vector4(0.16f, 0.16f, 0.2f, 1) });

            IrradianceMap.ReloadAsRTVUAV(32, 32, 1, DxgiFormat.DXGI_FORMAT_R32G32B32A32_FLOAT);
            EnvironmentMap.ReloadAsRTVUAV(1024, 1024, 7, DxgiFormat.DXGI_FORMAT_R16G16B16A16_FLOAT);
            miscProcessContext.Add(new P_Env_Data()
            {
                source = SkyBox, IrradianceMap = IrradianceMap, EnvMap = EnvironmentMap, Level = 16
            });
            processingList.AddObject(new TextureCubeUploadPack(SkyBox, upTexEnvCube));
            processingList.AddObject(IrradianceMap);
            processingList.AddObject(EnvironmentMap);

            ndcQuadMesh.ReloadNDCQuad();
            ndcQuadMeshIndexCount = ndcQuadMesh.m_indexCount;
            processingList.AddObject(ndcQuadMesh);

            cubeMesh.ReloadCube();
            cubeMeshIndexCount = cubeMesh.m_indexCount;
            processingList.AddObject(cubeMesh);

            cubeWireMesh.ReloadCubeWire();
            cubeWireMeshIndexCount = cubeWireMesh.m_indexCount;
            processingList.AddObject(cubeWireMesh);

            await ReloadTexture2DNoMip(BRDFLut, processingList, "ms-appx:///Assets/Textures/brdflut.png");
            await ReloadTexture2DNoMip(UI1Texture, processingList, "ms-appx:///Assets/Textures/UI_1.png");

            Initilized = true;
        }
Example #2
0
        private async Task ReloadTexture2DNoMip(Texture2D texture2D, ProcessingList processingList, string uri)
        {
            Uploader uploader = new Uploader();

            uploader.Texture2D(await FileIO.ReadBufferAsync(await StorageFile.GetFileFromApplicationUriAsync(new Uri(uri))), false, false);
            processingList.AddObject(new Texture2DUploadPack(texture2D, uploader));
        }
Example #3
0
        public void ReloadTextures(ProcessingList processingList, Action _RequireRender)
        {
            if (textureTaskLocker.GetLocker())
            {
                List <Texture2DPack> packs = new List <Texture2DPack>();
                lock (TextureCaches)
                    foreach (var texturePack in TextureCaches.Values)
                    {
                        packs.Add(texturePack);
                    }

                for (int i = 0; i < packs.Count; i++)
                {
                    var tex = packs[i];
                    if (tex.loadLocker.GetLocker())
                    {
                        Task.Factory.StartNew(async(object a) =>
                        {
                            Texture2DPack texturePack1 = (Texture2DPack)a;
                            try
                            {
                                var file = await texturePack1.folder.GetFileAsync(texturePack1.relativePath);
                                var attr = await file.GetBasicPropertiesAsync();
                                if (attr.DateModified != texturePack1.lastModifiedTime || texturePack1.texture2D.Status != GraphicsObjectStatus.loaded)
                                {
                                    Uploader uploader = new Uploader();
                                    if (await texturePack1.ReloadTexture(file, uploader))
                                    {
                                        processingList.AddObject(new Texture2DUploadPack(texturePack1.texture2D, uploader));
                                    }
                                    _RequireRender();
                                    texturePack1.lastModifiedTime = attr.DateModified;
                                }
                            }
                            catch
                            {
                                texturePack1.Mark(GraphicsObjectStatus.error);
                                _RequireRender();
                            }
                            finally
                            {
                                texturePack1.loadLocker.FreeLocker();
                            }
                        }, tex);
                    }
                }
                textureTaskLocker.FreeLocker();
            }
        }