154 lines
5.1 KiB
Text
154 lines
5.1 KiB
Text
#if TARGET_PLATFORM == "xenon"
|
|
#define NORMAL_MAP_FORMAT "DXN"
|
|
#else
|
|
#define NORMAL_MAP_FORMAT "<auto compression>"
|
|
#endif
|
|
|
|
//
|
|
// default images
|
|
//
|
|
#if ("$normalMap$" == "" || "$normalMap$" == "$identityNormalMap") && "$specColorMap$" == "" && "$cosinePowerMap$" == ""
|
|
#define NORMAL_MAP_TILE "tile both"
|
|
#define NORMAL_MAP_FILTER "nearest"
|
|
#define NORMAL_MAP_IMAGE "$identityNormalMap"
|
|
#define NORMAL_MAP_ANIMRATE 0
|
|
#define NORMAL_MAP_NOPICMIP 1
|
|
|
|
#define USE_SPECULAR 0
|
|
#define SPEC_SUFFIX ""
|
|
#else
|
|
#if "$normalMap$" == "" || "$normalMap$" == "$identityNormalMap"
|
|
#define NORMAL_MAP_TILE "tile both"
|
|
#define NORMAL_MAP_FILTER "nearest"
|
|
#define NORMAL_MAP_IMAGE "$identityNormalMap"
|
|
#define NORMAL_MAP_NOPICMIP 1
|
|
#else
|
|
#define NORMAL_MAP_TILE "@tileNormal@"
|
|
#define NORMAL_MAP_FILTER "@filterNormal@"
|
|
#define NORMAL_MAP_IMAGE "$normalMap$"
|
|
#define NORMAL_MAP_NOPICMIP @nopicmipNormal@
|
|
#endif
|
|
|
|
#if "$specColorMap$" == "" && "$cosinePowerMap$" == ""
|
|
#define USE_SPECULAR 0
|
|
#define SPEC_SUFFIX ""
|
|
#else
|
|
#define USE_SPECULAR 1
|
|
#define SPEC_SUFFIX "_spec"
|
|
|
|
#if "$specColorMap$" != ""
|
|
#define SPEC_COLOR_IMAGE "$specColorMap$"
|
|
#else
|
|
#define SPEC_COLOR_IMAGE "$white"
|
|
#endif
|
|
#if "$cosinePowerMap$" != ""
|
|
#define COSINE_POWER_IMAGE "$cosinePowerMap$"
|
|
#else
|
|
#define COSINE_POWER_IMAGE "$white"
|
|
#endif
|
|
|
|
#if "@formatSpecular@" == "<auto compression>"
|
|
#define SPECULAR_FORMAT "DXT5"
|
|
#else
|
|
#define SPECULAR_FORMAT "@formatSpecular@"
|
|
#endif
|
|
|
|
#if SPEC_COLOR_IMAGE != "$white"
|
|
#define COSINE_POWER_SCALE ((@cosinePowerStrength@ * 0.01) * 30.5 / 32.0)
|
|
#else
|
|
#define COSINE_POWER_SCALE (@cosinePowerStrength@ * 0.01)
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#define USE_DETAIL_MAP ("$detailMap$" != "")
|
|
#if USE_DETAIL_MAP
|
|
#define DETAIL_SUFFIX "_detail"
|
|
#else
|
|
#define DETAIL_SUFFIX ""
|
|
#endif
|
|
|
|
|
|
refImage( "$colorMap$" );
|
|
#include "commonsetup.template"
|
|
|
|
|
|
#if @texScroll@
|
|
#define TEX_SCROLL_SUFFIX "_scroll"
|
|
#else
|
|
#define TEX_SCROLL_SUFFIX ""
|
|
#endif
|
|
|
|
#if "@blendFunc@" == "Add"
|
|
#if SPEC_SUFFIX != ""
|
|
#error "specular not allowed on additive phong materials"
|
|
#endif
|
|
#if TEX_SCROLL_SUFFIX != ""
|
|
#error "tex scroll not allowed on additive phong materials"
|
|
#endif
|
|
#if USE_DETAIL_MAP
|
|
#error "detail map not allowed on additive phong materials"
|
|
#endif
|
|
techniqueSet( "phong_add" );
|
|
#elif "@blendFunc@" == "Replace"
|
|
#if "@alphaTest@" == "Always"
|
|
techniqueSet( "phong_replace" + SPEC_SUFFIX + DETAIL_SUFFIX + TEX_SCROLL_SUFFIX );
|
|
#else
|
|
techniqueSet( "phong_alphatest" + SPEC_SUFFIX + DETAIL_SUFFIX + TEX_SCROLL_SUFFIX );
|
|
#endif
|
|
#elif "@blendFunc@" == "Blend"
|
|
techniqueSet( "phong_blend" + SPEC_SUFFIX + DETAIL_SUFFIX + TEX_SCROLL_SUFFIX );
|
|
#else
|
|
#error "blendFunc '@blendFunc@' with alphaTest '@alphaTest@' not supported for phong materials"
|
|
#endif
|
|
|
|
|
|
textureTable
|
|
{
|
|
#if "$colorMap$" == ""
|
|
#error "colorMap may not be blank in phong materials"
|
|
#endif
|
|
"colorMap" = map( "@tileColor@", "@filterColor@", "$colorMap$", @nopicmipColor@ ) "@formatColor@" : "colorMap";
|
|
|
|
#if USE_DETAIL_MAP
|
|
"detailMap" = map( "tile both", "@filterDetail@", "$detailMap$", @nopicmipDetail@ ) "@formatDetail@" : "colorMap";
|
|
#endif
|
|
|
|
#if NORMAL_MAP_IMAGE == "$identityNormalMap"
|
|
"normalMap" = map( "tile both", "<auto filter>", "$identityNormalMap", true ) "<auto compression>" : "normalMap";
|
|
#elif NORMAL_MAP_FORMAT == "DXN"
|
|
"normalMap" = composite
|
|
(
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).r,
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).g,
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).b,
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).g
|
|
) NORMAL_MAP_FORMAT : "normalMap";
|
|
#else
|
|
"normalMap" = composite
|
|
(
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).g,
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).g,
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).g,
|
|
map( NORMAL_MAP_TILE, NORMAL_MAP_FILTER, NORMAL_MAP_IMAGE, NORMAL_MAP_NOPICMIP ).r
|
|
) NORMAL_MAP_FORMAT : "normalMap";
|
|
#endif
|
|
|
|
#if USE_SPECULAR
|
|
"specularMap" = composite
|
|
(
|
|
map( "@tileSpecular@", "@filterSpecular@", SPEC_COLOR_IMAGE, @nopicmipSpecular@ ).r * (@specColorStrength@ * 0.01),
|
|
map( "@tileSpecular@", "@filterSpecular@", SPEC_COLOR_IMAGE, @nopicmipSpecular@ ).g * (@specColorStrength@ * 0.01),
|
|
map( "@tileSpecular@", "@filterSpecular@", SPEC_COLOR_IMAGE, @nopicmipSpecular@ ).b * (@specColorStrength@ * 0.01),
|
|
map( "@tileSpecular@", "@filterSpecular@", COSINE_POWER_IMAGE, @nopicmipSpecular@ ) * COSINE_POWER_SCALE
|
|
) SPECULAR_FORMAT : "specularMap";
|
|
#endif
|
|
}
|
|
|
|
|
|
constantTable
|
|
{
|
|
#if USE_DETAIL_MAP
|
|
"detailScale" = float4( @detailScaleX@ * imageWidth( "$colorMap$" ) / imageWidth( "$detailMap$" ), @detailScaleY@ * imageHeight( "$colorMap$" ) / imageHeight( "$detailMap$" ), 0, 0 );
|
|
#endif
|
|
}
|