コード例 #1
0
        public GlslUnifiedShaderFactory(ResourceManager liveResourceManager, NormaMapReadMode normalMapReadMode, bool separateOpacityMap)
            : base(liveResourceManager, normalMapReadMode, separateOpacityMap)
        {
            var packProgram = HighLevelGpuProgramManager.Instance.createProgram("Pack_VP_GLSL", ResourceGroupName, "glsl", GpuProgramType.GPT_VERTEX_PROGRAM);

            packProgram.Value.SourceFile = UnifiedShaderBase + "Pack.glsl";
            packProgram.Value.load();
            localPrograms.Add(packProgram);

            var lightingProgram = HighLevelGpuProgramManager.Instance.createProgram("Lighting_FP_GLSL", ResourceGroupName, "glsl", GpuProgramType.GPT_FRAGMENT_PROGRAM);

            lightingProgram.Value.SourceFile = UnifiedShaderBase + "Lighting.glsl";
            lightingProgram.Value.load();
            localPrograms.Add(lightingProgram);

            var unpackProgram = HighLevelGpuProgramManager.Instance.createProgram("Unpack_FP_GLSL", ResourceGroupName, "glsl", GpuProgramType.GPT_FRAGMENT_PROGRAM);

            unpackProgram.Value.SourceFile = UnifiedShaderBase + "Unpack.glsl";
            unpackProgram.Value.load();
            localPrograms.Add(unpackProgram);

            var texMipLevelProgram = HighLevelGpuProgramManager.Instance.createProgram("VirtualTextureFuncs_GLSL", ResourceGroupName, "glsl", GpuProgramType.GPT_FRAGMENT_PROGRAM);

            texMipLevelProgram.Value.SourceFile = UnifiedShaderBase + "VirtualTextureFuncs.glsl";
            texMipLevelProgram.Value.load();
            localPrograms.Add(texMipLevelProgram);
        }
コード例 #2
0
        public UnifiedShaderFactory(ResourceManager liveResourceManager, NormaMapReadMode normalMapReadMode, bool separateOpacityMap)
        {
            this.normalMapReadMode  = normalMapReadMode;
            this.separateOpacityMap = separateOpacityMap;

            var rendererResources = liveResourceManager.getSubsystemResource("Ogre");

            shaderResourceGroup = rendererResources.addResourceGroup("UnifiedShaderFactory");
            shaderResourceGroup.addResource(GetType().AssemblyQualifiedName, "EmbeddedResource", true);

            liveResourceManager.initializeResources();

            enableIntelFix = true;// OgreInterface.Instance.ChosenRenderSystem == RenderSystemType.D3D11 && OgreInterface.Instance.GpuVendor == GPUVendor.GPU_INTEL;
        }
コード例 #3
0
 public HlslUnifiedShaderFactory(ResourceManager liveResourceManager, NormaMapReadMode normalMapReadMode, bool separateOpacityMap)
     : base(liveResourceManager, normalMapReadMode, separateOpacityMap)
 {
 }
コード例 #4
0
        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));
        }