private void InitBRDFxResources() { AssetsManagerInstance AM = AssetsManagerInstance.GetManager(); AssetsMeta.ShaderAsset meta = AM.LoadAsset <AssetsMeta.ShaderAsset>("IBL_PR_SphereToCubeMapPS"); meta = AM.LoadAsset <AssetsMeta.ShaderAsset>("IBL_PR_IntegrateBRDFxPS"); ShaderBytecode shaderBytecode = new ShaderBytecode(meta.Bytecode); IntegrateBRDFxPS = ToDispose(new PixelShader(m_Device, shaderBytecode)); IntegrateBRDFxPS.DebugName = "IntegrateBRDFxPS"; meta = AM.LoadAsset <AssetsMeta.ShaderAsset>("IBL_PR_IntegrateQuadVS"); shaderBytecode = new ShaderBytecode(meta.Bytecode); IntegrateQuadVS = ToDispose(new VertexShader(m_Device, shaderBytecode)); IntegrateQuadVS.DebugName = "IntegrateQuadVS"; if (CustomInputLayout == null) { CustomInputLayout = ToDispose(new InputLayout(m_Device, ShaderSignature.GetInputSignature(shaderBytecode), new InputElement[] { new InputElement("SV_VertexID", 0, Format.R32G32B32_Float, 0, 0), })); } if (ConstantsBuffer == null) { // Create the per environment map buffer ViewProjection matrices ConstantsBuffer = ToDispose(new Buffer( m_Device, Utilities.SizeOf <Matrix>() * 2, ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0) ); ConstantsBuffer.DebugName = "ConstantsBuffer"; } IntegrateBRDFxMap = ToDispose(new Texture2D(m_Device, new Texture2DDescription() { Width = BRDFxMapSize, Height = BRDFxMapSize, Format = Format.R16G16_Float, //R8G8B8A8_UNorm for debug ArraySize = 1, MipLevels = 1, SampleDescription = new SampleDescription(1, 0), BindFlags = BindFlags.RenderTarget, Usage = ResourceUsage.Default, OptionFlags = ResourceOptionFlags.None, CpuAccessFlags = CpuAccessFlags.None, })); IntegrateBRDFxRTV = ToDispose(new RenderTargetView(m_Device, IntegrateBRDFxMap, new RenderTargetViewDescription() { Dimension = RenderTargetViewDimension.Texture2D, Format = IntegrateBRDFxMap.Description.Format, Texture2D = new RenderTargetViewDescription.Texture2DResource() { MipSlice = 0, } })); }
void SetupShadersAndBuffers() { AssetsManagerInstance AM = AssetsManagerInstance.GetManager(); AssetsMeta.ShaderAsset meta = AM.LoadAsset <AssetsMeta.ShaderAsset>("IBL_PR_SphereToCubeMapPS"); ShaderBytecode shaderBytecode = new ShaderBytecode(meta.Bytecode); SphereToCubeMapPS = ToDispose(new PixelShader(m_Device, shaderBytecode)); SphereToCubeMapPS.DebugName = "SphereToCubeMapPS"; meta = AM.LoadAsset <AssetsMeta.ShaderAsset>("IBL_PR_IrradiancePS"); shaderBytecode = new ShaderBytecode(meta.Bytecode); IrradiancePS = ToDispose(new PixelShader(m_Device, shaderBytecode)); IrradiancePS.DebugName = "IrradiancePS"; meta = AM.LoadAsset <AssetsMeta.ShaderAsset>("IBL_PR_PreFilteredPS"); shaderBytecode = new ShaderBytecode(meta.Bytecode); PreFilteredPS = ToDispose(new PixelShader(m_Device, shaderBytecode)); PreFilteredPS.DebugName = "PreFilteredPS"; meta = AM.LoadAsset <AssetsMeta.ShaderAsset>("IBL_PR_SphereToCubeMapVS"); shaderBytecode = new ShaderBytecode(meta.Bytecode); SphereToCubeMapVS = ToDispose(new VertexShader(m_Device, shaderBytecode)); SphereToCubeMapVS.DebugName = "SphereToCubeMapVS"; CustomInputLayout = ToDispose(new InputLayout(m_Device, ShaderSignature.GetInputSignature(shaderBytecode), new InputElement[] { new InputElement("SV_VertexID", 0, Format.R32G32B32_Float, 0, 0), })); // Create the per environment map buffer ViewProjection matrices ConstantsBuffer = ToDispose(new Buffer( m_Device, Utilities.SizeOf <Matrix>() * 2, ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0) ); ConstantsBuffer.DebugName = "ConstantsBuffer"; BRDFParamsBuffer = ToDispose(new Buffer( m_Device, Utilities.SizeOf <BRDFParamsBufferStruct>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0) ); BRDFParamsBuffer.DebugName = "BRDFParamsBuffer"; Sampler = ToDispose(new SamplerState(m_Device, new SamplerStateDescription() { Filter = Filter.MinMagMipLinear, // Trilinear AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap, AddressW = TextureAddressMode.Wrap, ComparisonFunction = Comparison.Never, MipLodBias = 0, MinimumLod = 0, MaximumLod = float.MaxValue })); Sampler.DebugName = "DefaultTrilinearSampler"; }