public static int GetNumCompressedTexturesNeeded(CompressedTextureSupport textureFormat)
        {
            switch (textureFormat)
            {
            case CompressedTextureSupport.None:
                return(3);

            default:
                return(4);
            }
        }
Example #2
0
        public VirtualTextureSceneViewLink(OgreModelEditorController controller)
        {
            this.controller = controller;

            cameraLink = new CameraLink(controller.SceneViewController);

            CompressedTextureSupport textureFormat = OgreInterface.Instance.SelectedTextureFormat;

            virtualTextureManager = new VirtualTextureManager(UnifiedMaterialBuilder.GetNumCompressedTexturesNeeded(textureFormat), new IntSize2(4096, 4096), 128, 4096, textureFormat, 10, new IntSize2(256, 128), 100 * 1024 * 1024, UnifiedMaterialBuilder.AreTexturesPagedOnDisk(textureFormat));

            materialBuilder = new UnifiedMaterialBuilder(virtualTextureManager, OgreInterface.Instance.SelectedTextureFormat, controller.PluginManager.createLiveResourceManager("UnifiedShaders"));
            OgreInterface.Instance.MaterialParser.addMaterialBuilder(materialBuilder);
        }
Example #3
0
        public VirtualTextureManager(int numPhysicalTextures, IntSize2 physicalTextureSize, int texelsPerPage, int largestRealTextureSize, CompressedTextureSupport textureFormat, int stagingBufferCount, IntSize2 feedbackBufferSize, ulong maxCacheSizeBytes, bool texturesArePagedOnDisk)
        {
            uploadedIndirectionTextures = new HashSet <byte>();
            toUploadList = new List <StagingBufferSet>(stagingBufferCount);

            this.physicalTextureSize = physicalTextureSize;
            this.texelsPerPage       = texelsPerPage;
            this.pageSizeLog2        = (float)Math.Log(texelsPerPage, 2.0);
            if (!OgreResourceGroupManager.getInstance().resourceGroupExists(VirtualTextureManager.ResourceGroup))
            {
                OgreResourceGroupManager.getInstance().createResourceGroup(VirtualTextureManager.ResourceGroup);
            }

            //Determine actual runtime texture formats by just creating a simple one quickly.
            testTexture = TextureManager.getInstance().createManual("TestTexture__VTRESERVED", VirtualTextureManager.ResourceGroup, TextureType.TEX_TYPE_2D, 1, 1, 1, 0, PixelFormat.PF_A8R8G8B8, TextureUsage.TU_STATIC, null, false, 0);
            IndirectionTexture.BufferFormat = testTexture.Value.Format;

            switch (textureFormat)
            {
            case CompressedTextureSupport.DXT_BC4_BC5:
            case CompressedTextureSupport.DXT:
                padding = 4;
                break;

            default:
                padding = 1;
                break;
            }
            this.textureFormat = textureFormat;

            opaqueFeedbackBuffer      = new FeedbackBuffer(this, feedbackBufferSize, 0, 0x1);
            transparentFeedbackBuffer = new FeedbackBuffer(this, feedbackBufferSize, 1, 0x2);
            int highestMip = 0;

            for (highestMip = 0; largestRealTextureSize >> highestMip >= texelsPerPage; ++highestMip)
            {
            }
            textureLoader = new TextureLoader(this, physicalTextureSize, texelsPerPage, padding, stagingBufferCount, numPhysicalTextures, highestMip, maxCacheSizeBytes, texturesArePagedOnDisk);

            sharedFeedbackParameters = GpuProgramManager.Instance.createSharedParameters("__VirtualTexturingFeedbackSharedParams");
            sharedFeedbackParameters.Value.addNamedConstant("mipSampleBias", GpuConstantType.GCT_FLOAT1);

            PerformanceMonitor.addValueProvider("NumTexturePageUploads", () => lastNumTexturesUploaded.ToString());
        }
Example #4
0
        public VirtualTextureSceneViewLink(SceneController sceneController, SceneViewController sceneViewController, PluginManager pluginManager, UpdateTimer timer)
        {
            this.timer = timer;
            timer.addUpdateListener(updateListener);

            this.sceneController = sceneController;

            sceneController.OnSceneLoaded    += SceneController_OnSceneLoaded;
            sceneController.OnSceneUnloading += SceneController_OnSceneUnloading;

            cameraLink = new CameraLink(sceneViewController);

            CompressedTextureSupport textureFormat = OgreInterface.Instance.SelectedTextureFormat;

            virtualTextureManager = new VirtualTextureManager(UnifiedMaterialBuilder.GetNumCompressedTexturesNeeded(textureFormat), new IntSize2(4096, 4096), 128, 4096, textureFormat, 10, new IntSize2(256, 128), 100 * 1024 * 1024, UnifiedMaterialBuilder.AreTexturesPagedOnDisk(textureFormat));

            materialBuilder = new UnifiedMaterialBuilder(virtualTextureManager, OgreInterface.Instance.SelectedTextureFormat, pluginManager.createLiveResourceManager("UnifiedShaders"));
            OgreInterface.Instance.MaterialParser.addMaterialBuilder(materialBuilder);
        }
Example #5
0
        public VirtualTextureSceneViewLink(StandaloneController standaloneController)
        {
            this.standaloneController            = standaloneController;
            standaloneController.SceneLoaded    += standaloneController_SceneLoaded;
            standaloneController.SceneUnloading += standaloneController_SceneUnloading;

            cameraLink = new CameraLink(standaloneController.SceneViewController);

            CompressedTextureSupport textureFormat = OgreInterface.Instance.SelectedTextureFormat;

            virtualTextureManager = new VirtualTextureManager(UnifiedMaterialBuilder.GetNumCompressedTexturesNeeded(textureFormat), MedicalConfig.PhysicalTextureSize, MedicalConfig.PageSize, 4096, textureFormat, MedicalConfig.VirtualTextureStagingBufferCount, MedicalConfig.FeedbackBufferSize, MedicalConfig.TextureCacheSize, UnifiedMaterialBuilder.AreTexturesPagedOnDisk(textureFormat));
            virtualTextureManager.MaxStagingUploadPerFrame = MedicalConfig.MaxStagingVirtualTextureUploadsPerFrame;
            virtualTextureManager.TransparentFeedbackBufferVisibilityMask = TransparencyController.TransparentVisibilityMask;
            virtualTextureManager.OpaqueFeedbackBufferVisibilityMask      = TransparencyController.OpaqueVisibilityMask;
            virtualTextureManager.MipSampleBias      = -3;
            virtualTextureManager.AutoAdjustMipLevel = false;

            materialBuilder = new UnifiedMaterialBuilder(virtualTextureManager, OgreInterface.Instance.SelectedTextureFormat, standaloneController.MedicalController.PluginManager.createLiveResourceManager("UnifiedShaders"));
            OgreInterface.Instance.MaterialParser.addMaterialBuilder(materialBuilder);
            TransparencyController.initialize(materialBuilder);

            standaloneController.MainWindow.DestroyInternalResources += MainWindow_DestroyInternalResources;
            standaloneController.MainWindow.CreateInternalResources  += MainWindow_CreateInternalResources;
        }
        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));
        }
 public static bool AreTexturesPagedOnDisk(CompressedTextureSupport textureFormat)
 {
     return(textureFormat == CompressedTextureSupport.None);
 }
Example #8
0
 private static extern CompressedTextureSupport OgreInterface_SetupVaryingCompressedTextures(CompressedTextureSupport compressedTextures);