コード例 #1
0
        /// <summary>
        /// Loads the resource.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="resources">Parent ResourceDictionary.</param>
        protected override void LoadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            base.LoadResourceInternal(device, resources);

            // Load graphics resources
            m_pixelShaderBlur = resources.GetResourceAndEnsureLoaded(
                RES_KEY_PIXEL_SHADER_BLUR,
                () => GraphicsHelper.GetPixelShaderResource(device, "Postprocessing", "PostprocessBlur"));
            m_singleForcedColor = resources.GetResourceAndEnsureLoaded <SingleForcedColorMaterialResource>(
                KEY_MATERIAL,
                () => new SingleForcedColorMaterialResource()
            {
                FadeIntensity = m_fadeIntensity
            });
            m_renderTarget = resources.GetResourceAndEnsureLoaded <RenderTargetTextureResource>(
                KEY_RENDER_TARGET,
                () => new RenderTargetTextureResource(RenderTargetCreationMode.Color));
            m_defaultResources = resources.DefaultResources;

            // Load constant buffers
            m_cbFirstPass = resources.GetResourceAndEnsureLoaded <TypeSafeConstantBufferResource <CBPerObject> >(
                KEY_CB_PASS_01,
                () => new TypeSafeConstantBufferResource <CBPerObject>(new CBPerObject()
            {
                BlurIntensity = 0.0f,
                BlurOpacity   = 0.1f
            }));
            m_cbSecondPass = resources.GetResourceAndEnsureLoaded <TypeSafeConstantBufferResource <CBPerObject> >(
                KEY_CB_PASS_02,
                () => new TypeSafeConstantBufferResource <CBPerObject>(new CBPerObject()
            {
                BlurIntensity = 0.8f,
                BlurOpacity   = 0.5f
            }));
        }
コード例 #2
0
 /// <summary>
 /// Unloads the resource.
 /// </summary>
 protected override void UnloadResourceInternal(EngineDevice device, ResourceDictionary resources)
 {
     m_vertexShader    = null;
     m_pixelShader     = null;
     m_textureResource = null;
     m_cbPerMaterial   = null;
 }
コード例 #3
0
        /// <summary>
        /// Unloads the resource.
        /// </summary>
        protected override void UnloadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            GraphicsHelper.SafeDispose(ref m_inputLayout);

            m_vertexShader   = null;
            m_pixelShader    = null;
            m_constantBuffer = null;
        }
コード例 #4
0
        /// <summary>
        /// Unloads the resource.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="resources">Parent ResourceDictionary.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected override void UnloadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            base.UnloadResourceInternal(device, resources);

            m_pixelShaderBlur  = null;
            m_renderTarget     = null;
            m_defaultResources = null;
            m_constantBuffer   = null;
        }
コード例 #5
0
        /// <summary>
        /// Unloads the resource.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="resources">Parent ResourceDictionary.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected override void UnloadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            base.UnloadResourceInternal(device, resources);

            m_pixelShaderBlur   = null;
            m_singleForcedColor = null;
            m_renderTarget      = null;
            m_defaultResources  = null;
            m_cbFirstPass       = null;
            m_cbSecondPass      = null;
        }
コード例 #6
0
        /// <summary>
        /// Loads the resource.
        /// </summary>
        protected override void LoadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            // Load all required shaders and constant buffers
            m_vertexShader = resources.GetResourceAndEnsureLoaded(
                RES_KEY_VERTEX_SHADER,
                () => GraphicsHelper.GetVertexShaderResource(device, "Common", "SingleForcedColorVertexShader"));
            m_pixelShader = resources.GetResourceAndEnsureLoaded(
                RES_KEY_PIXEL_SHADER,
                () => GraphicsHelper.GetPixelShaderResource(device, "Common", "SingleForcedColorPixelShader"));

            m_cbPerMaterial = resources.GetResourceAndEnsureLoaded(
                KEY_CONSTANT_BUFFER,
                () => new TypeSafeConstantBufferResource <CBPerMaterial>());
            m_cbPerMaterialDataChanged = true;
        }
コード例 #7
0
        /// <summary>
        /// Loads the resource.
        /// </summary>
        protected override void LoadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            m_vertexShader = resources.GetResourceAndEnsureLoaded(
                KEY_VERTEX_SHADER,
                () => GraphicsHelper.GetVertexShaderResource(device, "LineRendering", "LineVertexShader"));
            m_pixelShader = resources.GetResourceAndEnsureLoaded(
                KEY_PIXEL_SHADER,
                () => GraphicsHelper.GetPixelShaderResource(device, "LineRendering", "LinePixelShader"));
            m_constantBuffer = resources.GetResourceAndEnsureLoaded(
                KEY_CONSTANT_BUFFER,
                () => new TypeSafeConstantBufferResource <ConstantBufferData>());

            m_inputLayout = new D3D11.InputLayout(
                device.DeviceD3D11_1,
                m_vertexShader.ShaderBytecode,
                LineVertex.InputElements);
        }
コード例 #8
0
        /// <summary>
        /// Loads the resource.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="resources">Parent ResourceDictionary.</param>
        protected override void LoadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            base.LoadResourceInternal(device, resources);

            // Load graphics resources
            m_pixelShaderBlur = resources.GetResourceAndEnsureLoaded(
                RES_KEY_PIXEL_SHADER_BLUR,
                () => GraphicsHelper.GetPixelShaderResource(device, "Postprocessing", "PostprocessEdgeDetect"));
            m_renderTarget = resources.GetResourceAndEnsureLoaded <RenderTargetTextureResource>(
                KEY_RENDER_TARGET,
                () => new RenderTargetTextureResource(RenderTargetCreationMode.Color));
            m_defaultResources = resources.DefaultResources;

            // Load constant buffer
            m_constantBufferData = new CBPerObject();
            m_constantBuffer     = resources.GetResourceAndEnsureLoaded <TypeSafeConstantBufferResource <CBPerObject> >(
                KEY_CONSTANT_BUFFER,
                () => new TypeSafeConstantBufferResource <CBPerObject>(m_constantBufferData));
        }
コード例 #9
0
        /// <summary>
        /// Loads the resource.
        /// </summary>
        protected override void LoadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            //Load all required shaders and constant buffers
            m_vertexShader = resources.GetResourceAndEnsureLoaded(
                RES_KEY_VERTEX_SHADER,
                () => GraphicsHelper.GetVertexShaderResource(device, "Sprite", "SpriteVertexShader"));
            m_pixelShader = resources.GetResourceAndEnsureLoaded(
                RES_KEY_PIXEL_SHADER,
                () => GraphicsHelper.GetPixelShaderResource(device, "Sprite", "SpritePixelShader"));

            // Get a reference to default resource object
            m_defaultResources = resources.GetResourceAndEnsureLoaded <DefaultResources>(DefaultResources.RESOURCE_KEY);

            //Load the texture if any configured.
            if (!m_textureKey.IsEmpty)
            {
                //Get texture resource
                m_textureResource = resources.GetResourceAndEnsureLoaded <TextureResource>(m_textureKey);
            }
        }
コード例 #10
0
        /// <summary>
        /// Loads the resource.
        /// </summary>
        protected override void LoadResourceInternal(EngineDevice device, ResourceDictionary resources)
        {
            // Load all required shaders and constant buffers
            m_vertexShader = resources.GetResourceAndEnsureLoaded(
                RES_KEY_VERTEX_SHADER,
                () => GraphicsHelper.GetVertexShaderResource(device, "Common", "CommonVertexShader"));
            m_pixelShader = resources.GetResourceAndEnsureLoaded(
                RES_KEY_PIXEL_SHADER,
                () => GraphicsHelper.GetPixelShaderResource(device, "Common", "CommonPixelShader"));
            m_cbPerMaterial = resources.GetResourceAndEnsureLoaded(
                KEY_CONSTANT_BUFFER,
                () => new TypeSafeConstantBufferResource <CBPerMaterial>());
            m_cbPerMaterialDataChanged = true;

            // Get a reference to default resource object
            m_defaultResources = resources.GetResourceAndEnsureLoaded <DefaultResources>(DefaultResources.RESOURCE_KEY);

            //Load the texture if any configured.
            if (!m_textureKey.IsEmpty)
            {
                //Get texture resource
                m_textureResource = resources.GetResourceAndEnsureLoaded <TextureResource>(m_textureKey);
            }
        }