EEVEE Next: Ensure correct material settings are used #108283

Merged
Miguel Pozo merged 3 commits from pragma37/blender:pull-fix-shaderkey into main 2023-05-25 18:02:00 +02:00
2 changed files with 8 additions and 4 deletions

View File

@ -203,7 +203,7 @@ MaterialPass MaterialModule::material_pass_get(Object *ob,
matpass.sub_pass = nullptr;
}
else {
ShaderKey shader_key(matpass.gpumat, geometry_type, pipeline_type);
ShaderKey shader_key(matpass.gpumat, geometry_type, pipeline_type, blender_mat->blend_flag);
PassMain::Sub *shader_sub = shader_map_.lookup_or_add_cb(shader_key, [&]() {
/* First time encountering this shader. Create a sub that will contain materials using it. */

View File

@ -108,7 +108,7 @@ static inline eMaterialGeometry to_material_geometry(const Object *ob)
/** Unique key to identify each material in the hash-map. */
struct MaterialKey {
Material *mat;
::Material *mat;
uint64_t options;
MaterialKey(::Material *mat_, eMaterialGeometry geometry, eMaterialPipeline surface_pipeline)
@ -145,10 +145,14 @@ struct ShaderKey {
GPUShader *shader;
uint64_t options;
ShaderKey(GPUMaterial *gpumat, eMaterialGeometry geometry, eMaterialPipeline pipeline)
ShaderKey(GPUMaterial *gpumat,
eMaterialGeometry geometry,
eMaterialPipeline pipeline,
char blend_flags)
{
shader = GPU_material_get_shader(gpumat);
options = shader_uuid_from_material_type(pipeline, geometry);
options = blend_flags;
options = (options << 6u) | shader_uuid_from_material_type(pipeline, geometry);
options = (options << 16u) | shader_closure_bits_from_flag(gpumat);
}