Пример #1
0
        public unsafe void analyzeBuffer()
        {
            float u, v;
            byte  m, t;

            for (int slId = 0; slId < fullBitmap.Height; ++slId)
            {
                var       scanline = fullBitmap.GetScanline <RGBQUAD>(slId);
                RGBQUAD[] slData   = scanline.Data;
                for (int pxId = 0; pxId < scanline.Count; ++pxId)
                {
                    var px = slData[pxId];
                    t = px.rgbReserved; //There is a change of this changing to the wrong texture id, but who knows if would happen (precision issues)

                    IndirectionTexture indirectionTexture;
                    if (t != 255 && virtualTextureManager.getIndirectionTexture(t, out indirectionTexture))
                    {
                        //Here the uvs are crushed to 8 bit, but should be ok since we are just detecting pages
                        //with this number this allows 255 pages to be decenly processsed above that data might be lost.
                        u = px.rgbRed / 255.0f;
                        v = px.rgbGreen / 255.0f;
                        m = px.rgbBlue;
                        indirectionTexture.processPage(u, v, m);
                    }
                }
            }
        }
Пример #2
0
        private bool loadPage(VTexPage page, StagingBufferSet stagingBuffers)
        {
            bool added = false;

            try
            {
                //First see if we still have that page in our virtual texture pool, possible optimization to sort these to the front of the list
                if (physicalPageQueue.Count > 0)              //Do we have pages available
                {
                    PTexPage pTexPage = physicalPageQueue[0]; //The physical page candidate, do not modify before usedPhysicalPages if statement below
                    if (loadImages(page, pTexPage, stagingBuffers))
                    {
                        //Alert old texture of removal if there was one, Do not modify pTexPage above this if block, we need the old data
                        IndirectionTexture oldIndirectionTexture = null;
                        if (pTexPage.VirtualTexturePage != null)
                        {
                            if (virtualTextureManager.getIndirectionTexture(pTexPage.VirtualTexturePage.indirectionTexId, out oldIndirectionTexture))
                            {
                                oldIndirectionTexture.removePhysicalPage(pTexPage);
                            }

                            physicalPagePool.Remove(pTexPage.VirtualTexturePage); //Be sure to remove the page from the pool if it was used previously
                        }

                        physicalPageQueue.RemoveAt(0);
                        pTexPage.VirtualTexturePage = page;
                        usedPhysicalPages.Add(page, pTexPage);

                        //Add to new indirection texture
                        IndirectionTexture newIndirectionTex;
                        if (virtualTextureManager.getIndirectionTexture(page.indirectionTexId, out newIndirectionTex))
                        {
                            newIndirectionTex.addPhysicalPage(pTexPage);
                            stagingBuffers.setIndirectionTextures(oldIndirectionTexture, newIndirectionTex);
                        }
                        added = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.Log.Debug("{0} loading page {1}. Message: {2}", ex.GetType().Name, page.ToString(), ex.Message);
            }
            return(added);
        }