public CShaderSamplers GetSamplerBinder_PickedEditor(CRenderContext RHICtx, CShaderProgram shader) { if (shader == null) { return(null); } if (mSamplerBinder_PickedEditor == null) { mSamplerBinder_PickedEditor = new CShaderSamplers(); using (var it = MtlInst.Material.GetSamplerStateDescs().GetEnumerator()) { while (it.MoveNext()) { var name = it.Current.Key; var samplerDesc = it.Current.Value; CSamplerBindInfo info = new CSamplerBindInfo(); if (shader.FindSamplerBindInfoByShaderName(MtlInst, name, ref info)) { CSamplerState SamplerState = CEngine.Instance.SamplerStateManager.GetSamplerState(RHICtx, samplerDesc); mSamplerBinder_PickedEditor.PSBindSampler(info.PSBindPoint, SamplerState); } else { var defaultSamplerDesc = new CSamplerStateDesc(); defaultSamplerDesc.SetDefault(); CSamplerState SamplerState = CEngine.Instance.SamplerStateManager.GetSamplerState(RHICtx, defaultSamplerDesc); mSamplerBinder_PickedEditor.PSBindSampler(info.PSBindPoint, SamplerState); } } } } return(mSamplerBinder_PickedEditor); }
protected override void OnCreated() { AddSRV("gEnvMap"); var SamplerStatDesc = new CSamplerStateDesc(); SamplerStatDesc.SetDefault(); SamplerStatDesc.Filter = ESamplerFilter.SPF_MIN_MAG_MIP_LINEAR; SamplerStat = CEngine.Instance.SamplerStateManager.GetSamplerState(CEngine.Instance.RenderContext, SamplerStatDesc); }
protected override void OnCreated() { //AddSRV("gBaseSceneView"); //AddSRV("gBloomTex"); //mobile ao sampler state; { var SamplerDesc_MobileAo = new CSamplerStateDesc(); SamplerDesc_MobileAo.SetDefault(); SamplerDesc_MobileAo.Filter = ESamplerFilter.SPF_MIN_MAG_LINEAR_MIP_POINT; SamplerDesc_MobileAo.AddressU = EAddressMode.ADM_CLAMP; SamplerDesc_MobileAo.AddressV = EAddressMode.ADM_CLAMP; SamplerDesc_MobileAo.AddressW = EAddressMode.ADM_CLAMP; mSampStat_MobileAo = CEngine.Instance.SamplerStateManager.GetSamplerState(CEngine.Instance.RenderContext, SamplerDesc_MobileAo); } }
public CShaderSamplers GetSamplerBinder_Shadow(CRenderContext RHICtx, CShaderProgram shader) { if (shader == null) { return(null); } if (mSamplerBinder_Shadow == null) { mSamplerBinder_Shadow = new CShaderSamplers(); //var SamplerDesc = new CSamplerStateDesc(); //SamplerDesc.SetDefault(); //for (UInt32 i = 0; i < shader.SamplerNumber; i++) //{ // CSamplerBindInfo info = new CSamplerBindInfo(); // shader.GetSamplerBindInfo(i, ref info); // MtlInst.GetSamplerStateDesc(i, ref SamplerDesc); // CSamplerState SamplerState = CEngine.Instance.SamplerStateManager.GetSamplerState(RHICtx, SamplerDesc); // mSamplerBinder_Shadow.PSBindSampler(info.PSBindPoint, SamplerState); //} using (var it = MtlInst.Material.GetSamplerStateDescs().GetEnumerator()) { while (it.MoveNext()) { var name = it.Current.Key; var samplerDesc = it.Current.Value; CSamplerBindInfo info = new CSamplerBindInfo(); if (shader.FindSamplerBindInfoByShaderName(MtlInst, name, ref info)) { CSamplerState SamplerState = CEngine.Instance.SamplerStateManager.GetSamplerState(RHICtx, samplerDesc); mSamplerBinder_Shadow.PSBindSampler(info.PSBindPoint, SamplerState); } else { var defaultSamplerDesc = new CSamplerStateDesc(); defaultSamplerDesc.SetDefault(); CSamplerState SamplerState = CEngine.Instance.SamplerStateManager.GetSamplerState(RHICtx, defaultSamplerDesc); mSamplerBinder_Shadow.PSBindSampler(info.PSBindPoint, SamplerState); } } } } return(mSamplerBinder_Shadow); }
protected override void OnCreated() { AddSRV("gEnvMap"); AddSRV("gShadowMap"); var SamplerStatDesc = new CSamplerStateDesc(); SamplerStatDesc.SetDefault(); SamplerStatDesc.Filter = ESamplerFilter.SPF_MIN_MAG_MIP_LINEAR; SamplerStat = CEngine.Instance.SamplerStateManager.GetSamplerState(CEngine.Instance.RenderContext, SamplerStatDesc); var SamplerDesc_ShadowMap = new CSamplerStateDesc(); SamplerDesc_ShadowMap.SetDefault(); SamplerDesc_ShadowMap.AddressU = EAddressMode.ADM_BORDER; SamplerDesc_ShadowMap.AddressV = EAddressMode.ADM_BORDER; SamplerDesc_ShadowMap.BorderColor = new Color4(1.0f, 1.0f, 1.0f, 1.0f); mSampler_ShadowMap = CEngine.Instance.SamplerStateManager.GetSamplerState(CEngine.Instance.RenderContext, SamplerDesc_ShadowMap); }
public void GetSamplerBinder(CRenderContext RHICtx, CShaderProgram shader, CShaderSamplers sampler) { if (shader == null || MtlInst.Material.GetSamplerStateDescs().Count <= 0) { return; } using (var it = MtlInst.Material.GetSamplerStateDescs().GetEnumerator()) { while (it.MoveNext()) { var name = it.Current.Key; var samplerDesc = it.Current.Value; CSamplerBindInfo info = new CSamplerBindInfo(); if (shader.FindSamplerBindInfoByShaderName(MtlInst, name, ref info)) { CSamplerState SamplerState = CEngine.Instance.SamplerStateManager.GetSamplerState(RHICtx, samplerDesc); sampler.PSBindSampler(info.PSBindPoint, SamplerState); } } } }
public unsafe void UpdateGpuBufferVTF(CRenderContext rc, EngineNS.CCommandList cmd, Graphics.CGfxCamera Camera) { CTexture2DDesc desc = new CTexture2DDesc(); desc.Init(); var spDesc = new CSamplerStateDesc(); spDesc.SetDefault(); spDesc.Filter = ESamplerFilter.SPF_MIN_MAG_MIP_POINT; mSamplerState = CEngine.Instance.SamplerStateManager.GetSamplerState(rc, spDesc); int vertStride = sizeof(Cluster.GpuSceneVertex); int size = mAllVertices.Count * vertStride; int side = (int)Math.Sqrt((float)size) + 1; desc.Width = 512; desc.Height = 512; desc.MipLevels = 1; desc.Format = EPixelFormat.PXF_R32G32B32A32_FLOAT; mVertexTexture = rc.CreateTexture2D(desc); CShaderResourceViewDesc srvDesc = new CShaderResourceViewDesc(); srvDesc.mFormat = desc.Format; srvDesc.mTexture2D = mVertexTexture.CoreObject; mVertexTextureView = rc.CreateShaderResourceView(srvDesc); mVertexTextureView.ResourceState.StreamState = EStreamingState.SS_Valid; { var copyArray = mAllVertices.ToArray(); fixed(Vector4 *p = &mVertexTexData[0]) fixed(Cluster.GpuSceneVertex * v = ©Array[0]) { CoreSDK.SDK_Memory_Copy(p, v, (uint)size); mVertexTexture.UpdateMipData(cmd, 0, p, 512, 512, 512 * 4 * 4); } } int InstStride = sizeof(GpuMeshInstanceData); size = mGpuInstanceDatas.Count * InstStride; side = (int)Math.Sqrt((float)size) + 1; desc.Width = 256; desc.Height = 256; desc.MipLevels = 1; desc.Format = EPixelFormat.PXF_R32G32B32A32_FLOAT; mInstanceDataTexture = rc.CreateTexture2D(desc); srvDesc.mFormat = desc.Format; srvDesc.mTexture2D = mInstanceDataTexture.CoreObject; mInstanceDataTextureView = rc.CreateShaderResourceView(srvDesc); mInstanceDataTextureView.ResourceState.StreamState = EStreamingState.SS_Valid; { var copyArray = mGpuInstanceDatas.ToArray(); fixed(Vector4 *p = &mInstTexData[0]) fixed(GpuMeshInstanceData * v = ©Array[0]) { CoreSDK.SDK_Memory_Copy(p, v, (uint)size); mInstanceDataTexture.UpdateMipData(cmd, 0, p, 256, 256, 256 * 4 * 4); } } }
public void PSBindSampler(UInt32 slot, CSamplerState sampler) { SDK_IShaderSamplers_PSBindSampler(CoreObject, (byte)slot, sampler.CoreObject); }
public void SetPassData(CRenderContext rc, CGfxMesh mesh, UInt32 index, CGfxSceneView vp, CPass pass) { //OnEffectRefresh(rc); if (pass.RenderPipeline == null) { var rplDesc = new CRenderPipelineDesc(); pass.RenderPipeline = rc.CreateRenderPipeline(rplDesc); } pass.RenderPipeline.ShaderProgram = mEffect.ShaderProgram; pass.RenderPipeline.RasterizerState = mMaterial.RasterizerState; pass.RenderPipeline.DepthStencilState = mMaterial.DepthStencilState; pass.RenderPipeline.BlendState = mMaterial.BlendState; pass.GeometryMesh = mesh.MeshPrimitives.GeometryMesh; pass.BindCBuffer(mEffect.ShaderProgram, mEffect.PerInstanceId, CBuffer); pass.BindCBuffer(mEffect.ShaderProgram, mEffect.PerFrameId, CEngine.Instance.PerFrameCBuffer); if (vp != null) { pass.ViewPort = vp.Viewport; } var textures = new CShaderResources(); { Material.BindTextures(textures, mEffect.ShaderProgram); foreach (var i in Textures) { textures.PSBindTexture(i.Key, i.Value); } mesh.ShadingEnv.BindResources(mesh, CBuffer, textures, mEffect.ShaderProgram); } pass.ShaderResources = textures; CShaderSamplers samplers = new CShaderSamplers(); { CSamplerStateDesc sampDesc = new CSamplerStateDesc(); sampDesc.SetDefault(); sampDesc.Filter = ESamplerFilter.SPF_MIN_MAG_MIP_POINT; CSamplerState samp = CEngine.Instance.SamplerStateManager.GetSamplerState(rc, sampDesc); for (UInt32 i = 0; i < mEffect.ShaderProgram.SamplerNumber; i++) { CSamplerBindInfo info = new CSamplerBindInfo(); mEffect.ShaderProgram.GetSamplerBindInfo(i, ref info); samplers.PSBindSampler(info.PSBindPoint, samp); } } pass.ShaderSamplers = samplers; foreach (var i in mesh.MdfQueue.Modifiers) { i.OnSetPassData(pass); } CDrawPrimitiveDesc dpDesc = new CDrawPrimitiveDesc(); mesh.MeshPrimitives.GetAtom(index, 0, ref dpDesc); pass.BindDrawPrimitive(ref dpDesc); }