MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Bind

Method Bind

Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp:35–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void DeferredMaterialShader::Bind(BindParameters& params)
36{
37 auto context = params.GPUContext;
38 auto& view = params.RenderContext.View;
39 auto& drawCall = *params.DrawCall;
40 Span<byte> cb(_cbData.Get(), _cbData.Count());
41 int32 srv = 3;
42
43 // Setup features
44 const bool useLightmap = _info.BlendMode == MaterialBlendMode::Opaque && LightmapFeature::Bind(params, cb, srv);
45 if (_info.ShadingModel == MaterialShadingModel::CustomLit)
46 ForwardShadingFeature::Bind(params, cb, srv);
47
48 // Setup parameters
49 MaterialParameter::BindMeta bindMeta;
50 bindMeta.Context = context;
51 bindMeta.Constants = cb;
52 bindMeta.Input = nullptr;
53 bindMeta.Buffers = params.RenderContext.Buffers;
54 bindMeta.CanSampleDepth = false;
55 bindMeta.CanSampleGBuffer = false;
56 MaterialParams::Bind(params.ParamsLink, bindMeta);
57 context->BindSR(0, params.ObjectBuffer);
58
59 // Check if using mesh skinning
60 const bool useSkinning = drawCall.Surface.Skinning != nullptr;
61 bool perBoneMotionBlur = false;
62 if (useSkinning)
63 {
64 // Bind skinning buffer
65 ASSERT(drawCall.Surface.Skinning->IsReady());
66 context->BindSR(1, drawCall.Surface.Skinning->BoneMatrices->View());
67 if (drawCall.Surface.Skinning->PrevBoneMatrices && drawCall.Surface.Skinning->PrevBoneMatrices->IsAllocated())
68 {
69 context->BindSR(2, drawCall.Surface.Skinning->PrevBoneMatrices->View());
70 perBoneMotionBlur = true;
71 }
72 }
73
74 // Bind constants
75 if (_cb)
76 {
77 context->UpdateCB(_cb, _cbData.Get());
78 context->BindCB(0, _cb);
79 }
80
81 // Select pipeline state based on current pass and render mode
82 const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != MaterialFeaturesFlags::None || view.Mode == ViewMode::Wireframe;
83 CullMode cullMode = view.Pass == DrawPass::Depth ? CullMode::TwoSided : _info.CullMode;
84#if USE_EDITOR
85 if (IsRunningRadiancePass)
86 cullMode = CullMode::TwoSided;
87#endif
88 if (cullMode != CullMode::TwoSided && drawCall.WorldDeterminant)
89 {
90 // Invert culling when scale is negative
91 cullMode = cullMode == CullMode::Normal ? CullMode::Inverted : CullMode::Normal;
92 }

Callers

nothing calls this directly

Calls 12

BindFunction · 0.85
IsAllocatedMethod · 0.80
GetMethod · 0.45
CountMethod · 0.45
BindSRMethod · 0.45
IsReadyMethod · 0.45
ViewMethod · 0.45
UpdateCBMethod · 0.45
BindCBMethod · 0.45
GetPSMethod · 0.45
SetStateMethod · 0.45
SetStencilRefMethod · 0.45

Tested by

no test coverage detected