Jump to content

Material format suggestion


photo

Recommended Posts

Where a state has an items tag, it would be nice to be able to reference the items by their names rather than their numerical values. Like the use of "triplanar" here.

<state name="detail_mask_mapping" detail="1" detail_mask="1" items="base,detail,uv0,uv1,triplanar,overlap0,overlap1" defines="name_items"/>
<parameter name="detail_mask_triplanar_blend" detail_mask="1" detail_mask_mapping="triplanar" detail="1" type="slider">0.5f</parameter>

It wouldn't apply only to parameters, but anywhere that a state is referenced. This makes the file a little easier to read and maintain, and should be backwards compatible with the proviso that items whose names are actually numbers could still only be referred to by numerical value, not by their item name.

Link to comment

Thanks Morbid.

I suppose I should elaborate on why this is important to us - you might have another way to solve this specific use case in the interim.
In 2.3, we have a bunch of materials that adapt built-in materials like this:
 

<material name="riotinto_mesh_with_rainbow_feature" parent="mesh_base">
  <state name="deferred">0</state>
  <shader pass="ambient"
          fragment="rainbows.frag"/>
</material>
<material name="riotinto_mesh_with_sparkles_feature" parent="mesh_base">
  <state name="deferred">0</state>
  <shader pass="ambient"
          fragment="sparkles.frag"/>
</material>

But in 2.6 we can't override shaders like that, so we have to make our own copy of mesh_base.basemat and make the shader change there. We don't want to do that for every material we've derived from mesh_base (in reality, it's more than two!) so instead we make a single copy of the basemat with some additions like this:
 

<state name="default_mesh">1</state>
<state name="rainbow_mesh">0</state>
<state name="sparkles_mesh">0</state>
...
<shader pass="ambient"
        default_mesh="0"
        rainbow_mesh="1"
        fragment="rainbows.frag"/>
<shader pass="ambient"
        default_mesh="0"
        sparkles_mesh="1"
        fragment="sparkles.frag"/>

and also add a default_mesh="1" to the original ambient pass.

We would prefer:

<state name="mesh_style", items="default_mesh,rainbow_mesh,sparkles_mesh">0</state>
...
<shader pass="ambient"
        mesh_style="1"
        fragment="rainbows.frag"/>
<shader pass="ambient"
        mesh_style="2"
        fragment="sparkles.frag"/>

because we don't have to switch default_mesh off everywhere in addition to enabling the state we _do_ want. But mesh_style="2" is a lot less readable than sparkles_mesh="1" in this case, so we'd really prefer to be able to write mesh_style="sparkles_mesh".

I think the feature I've suggested is a nice thing to have generally (and easy to implement) but you may well know a neater solution for how to make multiple derivations of mesh_base?

Link to comment
×
×
  • Create New...