Changes between Version 2 and Version 3 of MaterialSystem


Ignore:
Timestamp:
2012-04-15 15:04:38 (14 months ago)
Author:
Philip
Comment:

material alternatives

Legend:

Unmodified
Added
Removed
Modified
  • MaterialSystem

    v2 v3  
    2121 * '''Shader effects''' control which shader technique to use in each different context, depending on rendering mode, hardware capabilities, user-selected graphics options, etc. 
    2222 
     23== Conditionals == 
     24 
     25Various XML files can contain conditionals, which are typically attributes of the form `if="..."`. These are C-preprocessor-style boolean expressions that can use the current set of defines, e.g.: 
     26{{{ 
     27<alternative ... if="CFG_FORCE_ALPHATEST"/> 
     28<require context="MODE_SHADOWCAST || MODE_SILHOUETTEOCCLUDER"/> 
     29<whatever if="(FOO || !(BAR && BAZ)) && QUX > 100"/> 
     30}}} 
     31 
    2332== Materials == 
    2433 
     
    2736<?xml version="1.0" encoding="utf-8"?> 
    2837<material> 
     38    <alternative material="alphatest_spec.xml" if="CFG_FORCE_ALPHATEST"/> 
    2939    <shader effect="model_transparent"/> 
    3040    <alpha_blending/> 
     
    3646}}} 
    3747Materials can contain: 
    38  * `<shader effect="..."/>` - refers to one of the [source:ps/trunk/binaries/data/mods/public/shaders/effects effect XML files]. 
    39  * `<alpha_blending/>` - required if using a shader effect that uses alpha-blending. (This causes the engine to render the model twice, in `ALPHABLEND_PASS_OPAQUE` and `ALPHABLEND_PASS_BLEND` passes, to get correct blending relative to transparent water.) 
    40  * `<define name="..." value="..."/>` - specifies a name/value define that is used when loading the shader. The value is typically `"1"` to enable an effect. 
    41  * `<uniform name="..." value="..."/>` - specifies a uniform value that is used when rendering models using this material. The value is between 1 and 4 space-separated decimal numbers, e.g. `value="16"` or `value="1.0 1.0 0.0 0.5"`. 
     48 * (rarely used) `<alternative material="..." if="..."/>` - if the conditional expression is true, then this material will be replaced by the given alternative. This can be useful so e.g. alpha-blended materials can get replaced with alpha-tested materials depending on some configuration. 
     49 * (required) `<shader effect="..."/>` - refers to one of the [source:ps/trunk/binaries/data/mods/public/shaders/effects effect XML files]. 
     50 * (rarely used) `<alpha_blending/>` - required if using a shader effect that uses alpha-blending. (This causes the engine to render the model twice, in `ALPHABLEND_PASS_OPAQUE` and `ALPHABLEND_PASS_BLEND` passes, to get correct blending relative to transparent water.) 
     51 * (zero or more times) `<define name="..." value="..."/>` - specifies a name/value define that is used when loading the shader. The value is typically `"1"` to enable an effect. 
     52 * (zero or more times) `<uniform name="..." value="..."/>` - specifies a uniform value that is used when rendering models using this material. The value is between 1 and 4 space-separated decimal numbers, e.g. `value="16"` or `value="1.0 1.0 0.0 0.5"`. 
    4253 
    4354== Defines ==