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

Method Bind

Source/Engine/Renderer/Editor/MaterialComplexity.cpp:49–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void MaterialComplexityMaterialShader::WrapperShader::Bind(BindParameters& params)
50{
51 auto& drawCall = *params.DrawCall;
52
53 // Get original material from the draw call
54 IMaterial* material = nullptr;
55 switch (Domain)
56 {
57 case MaterialDomain::Surface:
58 case MaterialDomain::Terrain:
59 material = *(IMaterial**)&drawCall.Surface.Lightmap;
60 break;
61 case MaterialDomain::Particle:
62 material = *(IMaterial**)&drawCall.ObjectPosition;
63 break;
64 case MaterialDomain::Decal:
65 material = drawCall.Material;
66 break;
67 }
68
69 // Disable lightmaps
70 const auto lightmapsEnable = EnableLightmapsUsage;
71 EnableLightmapsUsage = false;
72
73 // Estimate the shader complexity
74 ASSERT_LOW_LAYER(material && material->IsReady());
75 material->Bind(params);
76 GPUPipelineState* materialPs = params.GPUContext->GetState();
77 const float complexity = (float)Math::Min(materialPs->Complexity, MATERIAL_COMPLEXITY_LIMIT) / MATERIAL_COMPLEXITY_LIMIT;
78
79 // Draw with custom color
80 const Color color(complexity, complexity, complexity, 1.0f);
81 MaterialAsset->SetParameterValue(TEXT("Color"), Variant(color));
82 MaterialAsset->Bind(params);
83
84 EnableLightmapsUsage = lightmapsEnable;
85}
86
87MaterialComplexityMaterialShader::MaterialComplexityMaterialShader()
88{

Callers 1

DrawMethod · 0.45

Calls 5

MinFunction · 0.50
VariantFunction · 0.50
IsReadyMethod · 0.45
GetStateMethod · 0.45
SetParameterValueMethod · 0.45

Tested by

no test coverage detected