bool initializeRenderingResources(Renderer* pRenderer, RenderTarget* pRenderTarget) { // SHADER //---------------------------------------------------------------------------------------------------------------- ShaderLoadDesc paniniPass = {}; paniniPass.mStages[0] = { "panini_projection.vert", NULL, 0, FSR_SrcShaders_Common }; paniniPass.mStages[1] = { "panini_projection.frag", NULL, 0, FSR_SrcShaders_Common }; addShader(pRenderer, &paniniPass, &pShaderPanini); // SAMPLERS & STATES //---------------------------------------------------------------------------------------------------------------- addSampler(pRenderer, &pSamplerTrilinearAniso, FILTER_TRILINEAR_ANISO, FILTER_BILINEAR, MIPMAP_MODE_LINEAR, ADDRESS_MODE_REPEAT, ADDRESS_MODE_REPEAT, ADDRESS_MODE_REPEAT, 0.0f, 8.0f); addRasterizerState(&pRasterizerStateCullNone, CULL_MODE_NONE); addDepthState(pRenderer, &pDepthStateDisable, false, false); // ROOT SIGNATURE //---------------------------------------------------------------------------------------------------------------- RootSignatureDesc paninniRootDesc = {}; paninniRootDesc.mStaticSamplers["uSampler"] = pSamplerTrilinearAniso; addRootSignature(pRenderer, 1, &pShaderPanini, &pRootSignaturePaniniPostProcess, &paninniRootDesc); // PIPELINE //---------------------------------------------------------------------------------------------------------------- VertexLayout vertexLayoutPanini = {}; vertexLayoutPanini.mAttribCount = 1; vertexLayoutPanini.mAttribs[0].mSemantic = SEMANTIC_POSITION; vertexLayoutPanini.mAttribs[0].mFormat = ImageFormat::RGBA32F; vertexLayoutPanini.mAttribs[0].mBinding = 0; vertexLayoutPanini.mAttribs[0].mLocation = 0; vertexLayoutPanini.mAttribs[0].mOffset = 0; GraphicsPipelineDesc pipelineSettings = { 0 }; pipelineSettings.mPrimitiveTopo = PRIMITIVE_TOPO_TRI_LIST; pipelineSettings.mRenderTargetCount = 1; pipelineSettings.pDepthState = pDepthStateDisable; pipelineSettings.pColorFormats = &pRenderTarget->mDesc.mFormat; pipelineSettings.pSrgbValues = &pRenderTarget->mDesc.mSrgb; pipelineSettings.mSampleCount = pRenderTarget->mDesc.mSampleCount; pipelineSettings.mSampleQuality = pRenderTarget->mDesc.mSampleQuality; pipelineSettings.pRasterizerState = pRasterizerStateCullNone; pipelineSettings.pRootSignature = pRootSignaturePaniniPostProcess; pipelineSettings.pShaderProgram = pShaderPanini; pipelineSettings.pVertexLayout = &vertexLayoutPanini; addPipeline(pRenderer, &pipelineSettings, &pPipielinePaniniPostProcess); createTessellatedQuadBuffers(&pVertexBufferTessellatedQuad, &pIndexBufferTessellatedQuad, gPaniniDistortionTessellation[0], gPaniniDistortionTessellation[1]); #if USE_DEDICATED_COMMAND_LIST // COMMAND LIST //---------------------------------------------------------------------------------------------------------------- addCmdPool(pRenderer, pGraphicsQueue, false, &pPaniniCmdPool); addCmd_n(pPaniniCmdPool, false, imageCount, &ppPaniniCmds); #endif return true; }
bool MeshRenderer::init() { auto device = Sly::display->getDevice(); addConstantBuffer(device, "material", sizeof(MaterialCB), 3); //Set samplerstate D3D11_SAMPLER_DESC sampDesc; ZeroMemory( &sampDesc, sizeof(sampDesc) ); sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER; sampDesc.MinLOD = 0; sampDesc.MaxLOD = D3D11_FLOAT32_MAX; addSamplerState(device, "linear", &sampDesc, 0); //Set blendstate D3D11_BLEND_DESC blendDesc; ZeroMemory( &blendDesc, sizeof(blendDesc)); blendDesc.AlphaToCoverageEnable = false; blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blendDesc.RenderTarget[0].BlendEnable = false; blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].RenderTargetWriteMask = 0x0F; const float factor[4] = { 0.0f, 0.0f, 0.0f, 0.0f}; addBlendState(device, "mesh", &blendDesc, factor, 0xFFFFFFFF); //Set depth stencil state D3D11_DEPTH_STENCIL_DESC depthDesc; ZeroMemory( &depthDesc, sizeof(depthDesc)); depthDesc.DepthEnable = true; depthDesc.DepthFunc = D3D11_COMPARISON_LESS; depthDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; addDepthStencilState(device, "mesh", &depthDesc, 0); //Set rasterizer state D3D11_RASTERIZER_DESC rasterizerDesc; ZeroMemory( &rasterizerDesc, sizeof(rasterizerDesc)); rasterizerDesc.CullMode = D3D11_CULL_BACK; rasterizerDesc.FillMode = D3D11_FILL_SOLID; rasterizerDesc.DepthClipEnable = true; addRasterizerState(device, "mesh", &rasterizerDesc); D3D11_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; Shader::createVertexShaderAndInputLayout(device, vertexShaderFilename_, &vertexShader_, &inputLayout_, layout,3); Shader::createPixelShader(device, pixelShaderFilename_, &pixelShader_); setInitialised(true); return true; }