| 32 | |
| 33 | |
| 34 | void DiffuseRenderer::Init(ID3D11Device* device, ID3D11DeviceContext* context) |
| 35 | { |
| 36 | m_device = device; |
| 37 | m_deviceContext = context; |
| 38 | |
| 39 | // create the input layout |
| 40 | { |
| 41 | D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = |
| 42 | { |
| 43 | { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 44 | { "VELOCITY", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 45 | }; |
| 46 | |
| 47 | m_device->CreateInputLayout(inputElementDescs, 2, g_diffuseVS, sizeof(g_diffuseVS), &m_inputLayout); |
| 48 | } |
| 49 | |
| 50 | // create the shaders |
| 51 | m_device->CreateVertexShader(g_diffuseVS, sizeof(g_diffuseVS), nullptr, &m_diffuseVS); |
| 52 | m_device->CreateGeometryShader(g_diffuseGS, sizeof(g_diffuseGS), nullptr, &m_diffuseGS); |
| 53 | m_device->CreatePixelShader(g_diffusePS, sizeof(g_diffusePS), nullptr, &m_diffusePS); |
| 54 | |
| 55 | { |
| 56 | D3D11_BLEND_DESC blendDesc = {}; |
| 57 | blendDesc.AlphaToCoverageEnable = false; |
| 58 | blendDesc.IndependentBlendEnable = false; |
| 59 | blendDesc.RenderTarget[0].BlendEnable = true; |
| 60 | blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; |
| 61 | blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; |
| 62 | blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; |
| 63 | blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; |
| 64 | blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; |
| 65 | blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; |
| 66 | blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; |
| 67 | |
| 68 | m_device->CreateBlendState(&blendDesc, &m_blendState); |
| 69 | } |
| 70 | |
| 71 | { |
| 72 | D3D11_DEPTH_STENCIL_DESC depthStateDesc = {}; |
| 73 | depthStateDesc.DepthEnable = TRUE; |
| 74 | depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; |
| 75 | depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; |
| 76 | |
| 77 | device->CreateDepthStencilState(&depthStateDesc, &m_depthStencilState); |
| 78 | } |
| 79 | |
| 80 | // create a constant buffer |
| 81 | { |
| 82 | D3D11_BUFFER_DESC bufDesc; |
| 83 | bufDesc.ByteWidth = sizeof(DiffuseShaderConst); // 64 * sizeof(float); |
| 84 | bufDesc.Usage = D3D11_USAGE_DYNAMIC; |
| 85 | bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; |
| 86 | bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; |
| 87 | bufDesc.MiscFlags = 0; |
| 88 | |
| 89 | m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); |
| 90 | } |
| 91 |
nothing calls this directly
no outgoing calls
no test coverage detected