Exemplo n.º 1
0
 public void addedPhysicalTexture(PhysicalTexture physicalTexture)
 {
     foreach (var buffer in stagingBufferSets)
     {
         buffer.addedPhysicalTexture(physicalTexture, textelsPerPhysicalPage);
     }
 }
Exemplo n.º 2
0
 public void copyToGpu(IntRect destination)
 {
     if (physicalTexture != null)
     {
         physicalTexture.addPage(pixelBox, destination);
         physicalTexture = null;
     }
 }
Exemplo n.º 3
0
        public void setData(PixelBox sourceBox, PhysicalTexture physicalTexture, int padding)
        {
            if (sourceBox.getWidth() == pixelBox.getWidth())
            {
                PixelBox.BulkPixelConversion(sourceBox, pixelBox);
            }
            else
            {
                //source is too small, pad it out
                IntRect sourceRect = sourceBox.Rect;
                using (PixelBox partialPixels = texture.getPixelBox())
                {
                    //Center
                    partialPixels.Rect = new IntRect(padding, padding, sourceRect.Width, sourceRect.Height);
                    PixelBox.BulkPixelConversion(sourceBox, partialPixels);

                    ////Left
                    partialPixels.Rect = new IntRect(0, padding, padding, sourceRect.Height);
                    sourceBox.Rect     = new IntRect(sourceRect.Left, sourceRect.Top, padding, sourceRect.Height);
                    PixelBox.BulkPixelConversion(sourceBox, partialPixels);

                    ////Top
                    partialPixels.Rect = new IntRect(padding, 0, sourceRect.Width, padding);
                    sourceBox.Rect     = new IntRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, padding);
                    PixelBox.BulkPixelConversion(sourceBox, partialPixels);

                    ////Right
                    partialPixels.Rect = new IntRect(sourceRect.Width + padding, padding, padding, sourceRect.Height);
                    sourceBox.Rect     = new IntRect(sourceRect.Right - padding, sourceRect.Top, padding, sourceRect.Height);
                    PixelBox.BulkPixelConversion(sourceBox, partialPixels);

                    ////Bottom
                    partialPixels.Rect = new IntRect(padding, sourceRect.Height + padding, sourceRect.Width, padding);
                    sourceBox.Rect     = new IntRect(sourceRect.Left, sourceRect.Bottom - padding, sourceRect.Width, padding);
                    PixelBox.BulkPixelConversion(sourceBox, partialPixels);
                }
            }
            this.physicalTexture = physicalTexture;
        }
        public UnifiedMaterialBuilder(VirtualTextureManager virtualTextureManager, CompressedTextureSupport textureFormat, ResourceManager liveResourceManager)
        {
            PixelFormat      otherFormat;
            PixelFormat      normalFormat;
            NormaMapReadMode normalMapReadMode = NormaMapReadMode.RG;

            switch (textureFormat)
            {
            case CompressedTextureSupport.DXT_BC4_BC5:
                textureFormatExtension       = ".dds";
                normalTextureFormatExtension = "_bc5.dds";
                normalMapReadMode            = NormaMapReadMode.RG;
                createOpacityTexture         = true;
                otherFormat  = PixelFormat.PF_DXT5;
                normalFormat = PixelFormat.PF_BC5_UNORM;
                break;

            case CompressedTextureSupport.DXT:
                textureFormatExtension       = ".dds";
                normalTextureFormatExtension = ".dds";
                normalMapReadMode            = NormaMapReadMode.AG;
                createOpacityTexture         = true;
                otherFormat  = PixelFormat.PF_DXT5;
                normalFormat = PixelFormat.PF_DXT5;
                break;

            default:
            case CompressedTextureSupport.None:
                textureFormatExtension       = PagedImage.FileExtension;
                normalTextureFormatExtension = PagedImage.FileExtension;
                normalMapReadMode            = NormaMapReadMode.RG;
                createOpacityTexture         = false;
                otherFormat  = PixelFormat.PF_A8R8G8B8;
                normalFormat = PixelFormat.PF_A8R8G8B8;
                break;
            }

            this.virtualTextureManager = virtualTextureManager;

            if (OgreInterface.Instance.RenderSystem.isShaderProfileSupported("hlsl"))
            {
                shaderFactory = new HlslUnifiedShaderFactory(liveResourceManager, normalMapReadMode, createOpacityTexture);
            }
            else if (OgreInterface.Instance.RenderSystem.isShaderProfileSupported("glsl"))
            {
                shaderFactory = new GlslUnifiedShaderFactory(liveResourceManager, normalMapReadMode, createOpacityTexture);
            }
            else if (OgreInterface.Instance.RenderSystem.isShaderProfileSupported("glsles"))
            {
                shaderFactory = new GlslesUnifiedShaderFactory(liveResourceManager, normalMapReadMode, createOpacityTexture);
            }
            else
            {
                throw new OgreException("Cannot create Unified Material Builder, device must support shader profiles hlsl, glsl, or glsles.");
            }

            diffuseTexture  = virtualTextureManager.createPhysicalTexture("Diffuse", otherFormat);
            normalTexture   = virtualTextureManager.createPhysicalTexture("NormalMap", normalFormat);
            specularTexture = virtualTextureManager.createPhysicalTexture("Specular", otherFormat);

            if (createOpacityTexture)
            {
                opacityTexture = virtualTextureManager.createPhysicalTexture("Opacity", otherFormat);
            }

            specialMaterialFuncs.Add("EyeOuter", createEyeOuterMaterial);
            specialMaterialFuncs.Add("ColorVertex", createColorVertexMaterial);

            OgreResourceGroupManager.getInstance().createResourceGroup(GroupName);

            MaterialPtr hiddenMaterial = MaterialManager.getInstance().create("HiddenMaterial", GroupName, false, null);

            setupHiddenMaterialPass(hiddenMaterial.Value.getTechnique(0).getPass(0), false, false);
            createdMaterials.Add(hiddenMaterial.Value, new MaterialInfo(hiddenMaterial.Value, null));
            builtInMaterials.Add(hiddenMaterial);

            //Delete stock resources
            MaterialManager.getInstance().remove("BaseWhite");
            MaterialManager.getInstance().remove("BaseWhiteNoLighting");
            MaterialManager.getInstance().remove("Ogre/Debug/AxesMat");

            //Rebuild with our materials
            var baseWhite = createFromDescription(new MaterialDescription()
            {
                Name = "BaseWhite"
            }, false);

            builtInMaterials.Add(baseWhite);

            var baseWhiteNoLighting = createFromDescription(new MaterialDescription()
            {
                Name = "BaseWhiteNoLighting"
            }, false);

            builtInMaterials.Add(baseWhiteNoLighting);

            MaterialPtr axesMat = MaterialManager.getInstance().create("Ogre/Debug/AxesMat", GroupName, false, null);

            axesMat.Value.setLightingEnabled(false);
            axesMat.Value.setSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            axesMat.Value.setCullingMode(CullingMode.CULL_NONE);
            axesMat.Value.setDepthWriteEnabled(false);
            axesMat.Value.setDepthCheckEnabled(false);
            builtInMaterials.Add(axesMat);
            createdMaterials.Add(axesMat.Value, new MaterialInfo(axesMat.Value, null));
        }
Exemplo n.º 5
0
 internal bool tryGetPhysicalTexture(string name, out PhysicalTexture physicalTexture)
 {
     return(physicalTextures.TryGetValue(name, out physicalTexture));
 }
Exemplo n.º 6
0
 internal void setPhysicalPage(PixelBox sourceBox, PhysicalTexture physicalTexture, int padding)
 {
     stagingPhysicalPages[physicalTexture.Index].setData(sourceBox, physicalTexture, padding);
 }
Exemplo n.º 7
0
 public void addedPhysicalTexture(PhysicalTexture physicalTexture, int textelsPerPhysicalPage)
 {
     stagingPhysicalPages[physicalTexture.Index] = new StagingPhysicalPage(textelsPerPhysicalPage, physicalTexture.TextureFormat);
 }