FyroxEngine/Fyrox · error

There's already a material resource binding with

Error message

There's already a material resource binding with {name}!

What it means

Material::try_get_or_insert_property_group inserts a new MaterialPropertyGroup under the given name if none exists, but panics when a resource binding with that name already exists and is NOT a property group (e.g. it is a texture/sampler binding). The message includes the conflicting name. set_property is a typical caller: it calls this when the property group backing a property does not exist yet.

Solutions

  1. Rename one of the two bindings so the property group name is unique within the material.
  2. Check the existing binding kind first (material.resource_bindings / binding_name) before calling.
  3. If you intended to set a property inside an existing group, use the group's full name path rather than the texture binding name.

Example fix

// before
material.set_property("diffuseTexture", value); // name is already a texture binding
// after
material.bind("diffuseTexture", texture_resource); // set the texture instead of a property
material.set_property("material.color", value);
Defensive patterns

Strategy: validation

Validate before calling

if material.resource_bindings().contains_key(name) {
    log_error(format!("binding {name} already exists"));
} else {
    material.try_get_or_insert_property_group(name);
}

Try / catch

// Panics are not recoverable in normal Rust; guard by checking existing bindings first, or use catch_unwind for batch asset processing.

Prevention

When it happens

Trigger: Calling material.set_property(name, ...) or try_get_or_insert_property_group(name) where `name` collides with an existing non-property-group MaterialResourceBinding, such as a texture already bound under the same name.

Common situations: Defining a shader with a uniform whose name equals a texture binding name; copying property names between materials where one material uses the name for a texture; typos causing you to target a texture binding as a group.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10). Data as JSON: /api/errors/e30790a8e2e29587. Report an issue: GitHub.

Appendix: source

Thrown at fyrox-material/src/lib.rs:923

    }

    /// Tries to find a property group with the given name, creates a new group with the given name
    /// if there's no such group.
    pub fn try_get_or_insert_property_group(
        &mut self,
        name: impl Into<ImmutableString>,
    ) -> &mut MaterialPropertyGroup {
        let name = name.into();
        if let MaterialResourceBinding::PropertyGroup(group) = self
            .resource_bindings
            .entry(name.clone())
            .or_insert_with(|| {
                MaterialResourceBinding::PropertyGroup(MaterialPropertyGroup::default())
            })
        {
            group
        } else {
            panic!("There's already a material resource binding with {name}!");
        }
    }

    /// Sets new value of the resource binding with given name.
    ///
    /// # Type checking
    ///
    /// A new value must have the same type as in shader, otherwise an error will be generated at
    /// attempt to render something with this material.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use fyrox_material::{Material, MaterialProperty};
    /// # use fyrox_core::color::Color;
    /// # use fyrox_core::sstorage::ImmutableString;
    ///
    /// let mut material = Material::standard();

View on GitHub (pinned to 76c91aad8e)