locked
change shader parameters, Invert filter demo from Windows RT sample

    Question

  • Hi

    I can see the follwoing code that used shaders (original code from demo):

        // Pixel Shader
        {
            static
    #       include "PixelShader.hps"
            if(m_pPixelShader == nullptr)
            {
                hr = pDevice->CreatePixelShader(g_psshader, sizeof(g_psshader), NULL, &m_pPixelShader);
    			if(FAILED(hr))
    			{
    				goto done;
    			}
    
            }
        }
    
        // Vertex Shader
        {
            static
    #       include "VertexShader.hvs"
            if( m_pVertexShader == nullptr )
            {
                const D3D11_INPUT_ELEMENT_DESC quadlayout[] =
                {
                    { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
                    { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,       0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
                };
                hr = pDevice->CreateVertexShader(g_vsshader, sizeof(g_vsshader), NULL, &m_pVertexShader);
    			if(FAILED(hr))
    			{
    				goto done;
    			}
    
                hr = pDevice->CreateInputLayout(quadlayout, 2, g_vsshader, sizeof(g_vsshader), &m_spQuadLayout);
    			if(FAILED(hr))
    			{
    				goto done;
    			}
            }
        }
    

    shader code:

    struct VSOutput
    {
        float4 Pos : SV_POSITION;              
        float2 Tex : TEXCOORD0;
    };
    
    SamplerState samp : register( s0 );
    Texture2D<float4> Input : register( t0 );
    
    float4 PSMain( VSOutput Index ) : SV_Target0
    {
        float4 color = Input.Sample(samp,Index.Tex);
        color.rgb += 0.7;
        return color;
    }

    I want to add parameters to shader to change brightness for example. I'm not sure how to pass parameter to the shader...

    Thank you!


    Roman

    Monday, January 21, 2013 3:47 PM

Answers