| 50 | }; |
| 51 | |
| 52 | void FluidRenderer::Init(ID3D11Device* device, ID3D11DeviceContext* context, int width, int height) |
| 53 | { |
| 54 | mSceneWidth = width; |
| 55 | mSceneHeight = height; |
| 56 | |
| 57 | mDepthTex.Init(device, width, height); |
| 58 | mDepthSmoothTex.Init(device, width, height, false); |
| 59 | |
| 60 | m_device = device; |
| 61 | m_deviceContext = context; |
| 62 | |
| 63 | // create the input layout |
| 64 | { |
| 65 | D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = |
| 66 | { |
| 67 | { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 68 | { "U", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 69 | { "V", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 70 | { "W", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 3, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 71 | }; |
| 72 | |
| 73 | m_device->CreateInputLayout(inputElementDescs, 4, g_ellipsoidDepthVS, sizeof(g_ellipsoidDepthVS), &m_ellipsoidDepthLayout); |
| 74 | } |
| 75 | |
| 76 | // create the shaders |
| 77 | m_device->CreateVertexShader(g_ellipsoidDepthVS, sizeof(g_ellipsoidDepthVS), nullptr, &m_ellipsoidDepthVS); |
| 78 | m_device->CreateGeometryShader(g_ellipsoidDepthGS, sizeof(g_ellipsoidDepthGS), nullptr, &m_ellipsoidDepthGS); |
| 79 | m_device->CreatePixelShader(g_ellipsoidDepthPS, sizeof(g_ellipsoidDepthPS), nullptr, &m_ellipsoidDepthPS); |
| 80 | |
| 81 | // create the input layout |
| 82 | { |
| 83 | D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = |
| 84 | { |
| 85 | { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 86 | { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 87 | }; |
| 88 | |
| 89 | m_device->CreateInputLayout(inputElementDescs, 2, g_passThroughVS, sizeof(g_passThroughVS), &m_passThroughLayout); |
| 90 | } |
| 91 | |
| 92 | // pass through shader |
| 93 | m_device->CreateVertexShader(g_passThroughVS, sizeof(g_passThroughVS), nullptr, &m_passThroughVS); |
| 94 | |
| 95 | // full screen pixel shaders |
| 96 | m_device->CreatePixelShader(g_blurDepthPS, sizeof(g_blurDepthPS), nullptr, &m_blurDepthPS); |
| 97 | m_device->CreatePixelShader(g_compositePS, sizeof(g_compositePS), nullptr, &m_compositePS); |
| 98 | |
| 99 | // create a constant buffer |
| 100 | { |
| 101 | D3D11_BUFFER_DESC bufDesc; |
| 102 | bufDesc.ByteWidth = sizeof(FluidShaderConst); // 64 * sizeof(float); |
| 103 | bufDesc.Usage = D3D11_USAGE_DYNAMIC; |
| 104 | bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; |
| 105 | bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; |
| 106 | bufDesc.MiscFlags = 0; |
| 107 | |
| 108 | m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); |
| 109 | } |
nothing calls this directly
no outgoing calls
no test coverage detected