; --
; Material library for interior shaders, compatible with some original shaders.
; In first half of this file, you can see available templates and parameters for them.
; --

; Global parameters, defined in [INCLUDE] section:
[DEFAULTS]
DisableDev = 1  ; This option disables materials from “dev_materials_interior.ini” which might be accidendally included with older configs

; Windscreen banner, including masking pass and shadowing colorization
[TEMPLATE: Material_WindscreenBanner]
BlurBackground = 0        ; increase to make banner blur things behind it for rougher transparency look
; RainDrops = 1           ; set to 0 if mesh overlays interior windscreen to avoid duplicating rain drops in two layers
; WindscreenMesh =        ; set name of interior windscreen mesh here if banner mesh overlays it to automatically fix rendering order
; Brightness =            ; use to adjust brightness
; CastShadowsThreshold =  ; cast shadows for areas with alpha above this value

; Mask pass
MaskPass = 0.5            ; mask pass opacity
MaskPassColor = 0, 0, 0   ; mask pass color adjustment

; Colorful shadowing
ColorfulShadowing = 2     ; colorful shadowing opacity

; Digital screens, with pixels and all that
[TEMPLATE: Material_DigitalScreen]
MatrixType = IPS           ; valid values: IPS, TN, VA
UseTextureCoordinates = 1  ; with 0, vertex coordinates will be used. sometimes it’s better, sometimes it’s buggier
ScreenScale = 480          ; amount of pixels horizontally
ScreenAspectRatio = 0.25   ; aspect ratio, height/width
Emissive = 4               ; screen brightness
FlipXY = 0                 ; rotate display 90°
SkewTextureCoordinates = 0 ; this value can help fixing tilted UV coordinates
TreatTextureAsHDR = 0      ; set to 1 if input texture is HDR

; Alternative way of making digital screens: cover it with a piece of glass and alter that piece
; with this adjustment, changing the way it filters things behind it (by using multiplicative blending)
[TEMPLATE: Material_DigitalScreen_GlassOverlay]
MatrixType = IPS           ; valid values: IPS, TN, VA
UseTextureCoordinates = 1  ; with 0, vertex coordinates will be used. sometimes it’s better, sometimes it’s buggier
ScreenScale = 480          ; amount of pixels horizontally
ScreenAspectRatio = 0.25   ; aspect ratio, height/width
FlipXY = 0                 ; rotate display 90°

; Version of ksPerPixelMultiMap_NMDetail, but with simple fur-like effect. It uses both alpha from txMaps and alpha 
; from txNormalDetail as some sort of height map for fur effect (and adds custom noise on top)
[TEMPLATE: Material_Fur]
FurLayers = 6         ; how many layers fur has (or, how many times mesh is rendered), higher values are more expensive, so be careful
FurScale = 1          ; fur “depth”
FurFacingScale = 0.5  ; optional reduction of fur “depth” for surfaces facing camera, not accurate, of course, but might help to make it look better
FurGravityFactor = 1  ; how much fur is pushed down
FurUseTextures = 1    ; set to 0 to rely only on noise texture and to not use alphas from txMaps and txNormalDetail
FurFidelityScale = 1  ; scale of noise texture (set to 0 to disable noise texture)
FurOcclusion = 0.5    ; how bright should be lower areas 
FurRimExponent = 3    ; exponent for rim lighting, increase to reduce it on areas facing viewer
FurAmbient = 1        ; brightness of rim lighting (both vertex AO and red channel of txMaps are taken into account)
FurDiffuse = 1        ; brightness of sun and extra lights for some sort of backlit

; More advanced settings for complex cases
ThresholdExponent = 0.8   ; alters whole fur effect
ThresholdMultipler = 0.8

; Common PBR materials with fitting PBR textures (normals, roughness, detail AO):
[TEMPLATE: Material_Plastic_v2 EXTENDS Material_InteriorPBRDetail]
Reflectance = 0.04
DetailNormalPBRSecondaryColor = 0, 0, 0, 0.5
DetailNormalBlend = 0.5
DetailNormalTexture = common/pbr_plastic.dds
DetailNormalPBRSmoothnessGamma = 1
DetailTextureBlur = 1

[TEMPLATE: Material_Leather_v2 EXTENDS Material_InteriorPBRDetail]
Reflectance = 0.04
DetailNormalTexture = common/pbr_leather_bumpy.dds
DetailNormalIntensity = 3
DetailNormalPBRSecondaryColor = 1, 1, 1, 0.08

[TEMPLATE: Material_LeatherSpotty_v2 EXTENDS Material_InteriorPBRDetail]
Reflectance = 0.03
DetailNormalTexture = common/pbr_leather_spotty.dds
DetailNormalPBRSecondaryColor = 0, 0, 0, 0.1

[TEMPLATE: Material_LeatherPoked_v2 EXTENDS Material_InteriorPBRDetail]
Reflectance = 0.04
DetailNormalTexture = common/pbr_leather_pattern.dds
DetailNormalIntensity = 2
DetailNormalPBRSecondaryColor = 0, 0, 0, 10
DetailNormalPBRReflectance = 10

[TEMPLATE: Material_Fabric_v2 EXTENDS Material_InteriorPBRDetail]
Reflectance = 0.02
DetailNormalTexture = common/pbr_fabric.dds
DetailNormalPBRSecondaryColor = 0, 0, 0, 0.3
UseClothShading = 1
Reflectance = 0.4
ClothSheenColor = 1, 1, 1

[TEMPLATE: Material_Carpet_v2 EXTENDS Material_InteriorPBRDetail]
Reflectance = 0.04
DetailNormalTexture = common/pbr_carpet.dds
DetailNormalPBRSecondaryColor = 0, 0, 0, 1

[TEMPLATE: Material_Velvet_v2 EXTENDS Material_InteriorPBRDetail]
DetailNormalTexture = common/pbr_carpet.dds
DetailNormalPBRSecondaryColor = 0, 0, 0, 0
UseClothShading = 1
Reflectance = 0.5
DetailScale = 40
ClothSheenColor = 1, 1, 1

[TEMPLATE: Material_Aluminium_v2 EXTENDS Material_InteriorPBRDetail]
Metalness = 0.4
Reflectance = 1
BrightnessAdjustment = 0.5
DetailTexture = 1
DetailNormalTexture = common/pbr_metal.dds
DetailNormalPBRSecondaryColor = 0, 0, 0, 0
DetailScale = 30
DetailNormalBlend = 1
DetailNormalPBRSmoothnessGamma = 2

[TEMPLATE: Material_Metal_v2 EXTENDS Material_Aluminium_v2]
Metalness = 0.8
BrightnessAdjustment = 0.8
LocalReflectionsSharpness = 1

[TEMPLATE: Material_MetalOld_v2 EXTENDS Material_Aluminium_v2]
Metalness = 0.8
Reflectance = 0.0
Brightness = 0.3
DetailNormalPBRSmoothnessGamma = 1
LocalReflectionsSharpness = 0

[TEMPLATE: Material_AluminiumOld_v2 EXTENDS Material_Aluminium_v2]
Metalness = 0.2
Reflectance = 0.2
Brightness = 0.5

[TEMPLATE: Material_Carbon EXTENDS Material_InteriorPBR]
HasDetailNormals = 1
Smoothness = 0.9
Reflectance = 0.2
CubemapReflectionBlur = 0.35
UseClearCoat = 1
ClearCoatSmoothness = 1.0
ClearCoatIntensity = 1.0
DetailTexture = common/carbon.png
DetailNormalTexture = common/carbon_nm.png
DetailNormalBlend = 1
DetailScale = 420

; Specialized material templates with predefined settings for easier setup, for “ksPerPixelMultiMap” and “ksPerPixelMultiMap_NMDetail”
; Those templates are meant for materials set in Kunos style: with occlusion map in “txDiffuse” and color in “txDetail”. If your materials
; are different, change “OcclusionSource” and “ColorSource” (look for “Material_InteriorPBR” a bit lower).
[TEMPLATE: Material_Velvet EXTENDS Material_InteriorPBR]
Smoothness = 0
Reflectance = 0.04

[TEMPLATE: Material_Fabric EXTENDS Material_InteriorPBR]
Smoothness = 0
Reflectance = 0.02

[TEMPLATE: Material_Carpet EXTENDS Material_InteriorPBR]
Smoothness = 0
OcclusionMap = -0.1, 1

[TEMPLATE: Material_Leather EXTENDS Material_InteriorPBR]
Smoothness = 0.65
Reflectance = 0.03

[TEMPLATE: Material_DashboardLeather EXTENDS Material_InteriorPBR]
Smoothness = 0.01
Reflectance = 0.02

[TEMPLATE: Material_Plastic EXTENDS Material_InteriorPBR]
Smoothness = 0.7
Reflectance = 0.04

[TEMPLATE: Material_Metal EXTENDS Material_InteriorPBR]
Smoothness = 0.95
Metalness = 0.9
Reflectance = 0.0
BrightnessAdjustment = 2
CubemapReflectionBlur = 1

[TEMPLATE: Material_Chrome EXTENDS Material_InteriorPBR]
Smoothness = 0.95
Metalness = 0.85
Reflectance = 0.0
BrightnessAdjustment = 1
CubemapReflectionBlur = 1

; Uses a custom leather details texture with extra PBR details
; Texture is from https://cc0textures.com/view?tex=Leather02
; Warning: obsolete.
[TEMPLATE: Material_LeatherDetailed EXTENDS Material_InteriorPBR]
Smoothness = 0
Reflectance = 0.02
ApplyTilingFix = 0
HasDetailNormals = 1
DetailNormalBlend = 0.8
DetailScale = 40
DetailNormalPBRFormat = 1
DetailNormalTexture = common/pbr_leather_spotty.dds
DetailNormalPBRSecondaryColor = 0, 0, 0, 0.1
DetailNormalPBRReflectance = 0.5

; Generic PBR material, for “ksPerPixelMultiMap” and “ksPerPixelMultiMap_NMDetail”
[TEMPLATE: Material_InteriorPBR]
HasDetailNormals = 1      ; set to 0 for meshes with “ksPerPixelMultiMap” shader

UseClearCoat = 0             ; set to 1 to add clear coat to material
ClearCoatSmoothness = 1.0    ; smoothness of clear coat
ClearCoatIntensity = 1.0     ; multiplier for clear coat, with 0, it’s pretty much disabled
ClearCoatNormalsShare = 0.0  ; how much of “txNormalDetail” goes to clear coat
ClearCoatF0 = 0.04           ; F0 for clear coat, should be 0.04 for most cases

ColorSource = DIFFUSE_NORMALIZED  ; where to take diffuse color from, valid values: DIFFUSE, DIFFUSE_NORMALIZED, FORCE_WHITE, DESATURATE
OcclusionSource = LUMINANCE      ; where to take occlusion from, valid values: NONE, LUMINANCE, MAPS_ALPHA
OcclusionMult = 1.0 ; multiplier for occlusion intensity

Smoothness = 0.9    ; smoothess before it’s scaled by texture
Metalness = 0       ; metalness before it’s scaled by texture
Reflectance = 0.04  ; reflectance before it’s scaled by texture

OcclusionMap = 0, 1    ; in what range occlusion scales
SmoothnessMap = 1, 1   ; same for smoothness (for it, green channel of txMaps is used)
MetalnessMap = 1, 1    ; same for metalness (red channel of txMaps; sure it’s a questionable idea, but here we are)
ReflectanceMap = 1, 1  ; same for smoothness (blue channel of txMaps)

; Brightness = 1                ; brightness adjustment
; DetailNormalBlend = 0         ; redefine detail normal map blend
CubemapReflectionBlur = 0       ; how much to blur cubemap reflection, good for shiny interior materials
ApplyTilingFix = 0              ; set to 1 to apply tiling fix (adds one or two texture reads per pixel)
ApplyShadowBiasFix = 0          ; set to 1 to apply shadows bias fix for interior
ExtraSharpLocalReflections = 0  ; increase up to 1 to make local reflections sharper
DetailTextureBlur = 0           ; blur txDetail to only use color, not pattern (for materials with PBR details)

DetailNormalPBRFormat = 0           ; set to 1 to use blue channel of txNormalDetail as occlusion map and alpha channel as specular map
DetailNormalPBRSecondaryColor = 0, 0, 0, 0  ; occluded by txNormalDetail color could be non-zero, for better gradients
DetailNormalPBRReflectance = 1      ; how much txNormalDetail does occlude diffuse (for better use of texture range, you can make it more constast and then tune down here)
DetailNormalPBRSmoothness = 1       ; strength of gloss modification (alpha)
DetailNormalPBRMetalness = 1        ; strength of metalness map (alpha of txDetail)
DetailNormalPBRSmoothnessGamma = 1  ; modifier for gloss/roughness, to increase variety with existing textures

; Preset for new PBR materials with accurate PBR details
[TEMPLATE: Material_InteriorPBRDetail EXTENDS Material_InteriorPBR]
Smoothness = 0
Reflectance = 0.04
HasDetailNormals = 1
DetailScale = 30
DetailNormalBlend = $" -1 * def( $DetailNormalIntensity, 1 ) "
DetailNormalPBRFormat = 1
DetailNormalPBRReflectance = 0.5
ColorSource = $" ${DiffuseAsAO:exists} and 'FORCE_WHITE' or discard() "
OcclusionMult = ${DiffuseAsAO:?}

; --
; Here goes second half, actual implementation of those templates.
; If you want to go futher, here is some documentation for the whole format:
; https://github.com/ac-custom-shaders-patch/inipp
; --

[INCLUDE: materials_base.ini]
[SHADER_REPLACEMENT_0SCREEN: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_VELVET_MM: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_VELVET_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_LEATHER_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_LEATHER_MM: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_ROUGH_LEATHER_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_PLASTIC_LEATHER_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_DASHBOARD_LEATHER_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_CARBON_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_CARBON_MM: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_CARBON_MM: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_CARPET_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_PLASTIC_MM: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_PLASTIC_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_FABRIC_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_METAL_MM: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_STEEL_OLD_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_BRUSHED_MMNND: _DeactivateDevMaterial]
[SHADER_REPLACEMENT_0INT_COMPOSITE_MM: _DeactivateDevMaterial]

[TEMPLATE: Material_WindscreenBanner EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_WINDSCREEN_BANNER_...
SHADER = ksWindscreen
IS_TRANSPARENT = 1
EXTRA_MASK_PASS = $" $MaskPass > 0 and 1 or 0 "
EXTRA_MASK_PASS_OPACITY = $MaskPass
EXTRA_MASK_PASS_COLOR = ${MaskPassColor:?}
EXTRA_MASK_PASS_COLOR_MULT = ${MaskPassBoostColor:?}
EXTRA_MASK_PASS_OPACITY_CLIP = $"( not ${MaskPassOpacityClip:exists} and ${WindscreenMode:bool} and 0.5 ) or ${MaskPassOpacityClip:bool}"
COLORFUL_SHADOWING = $ColorfulShadowing
COLORFUL_SHADOWING_COLOR_MULT = ${ColorfulShadowingBoostColor:?}
COLORFUL_SHADOWING_OPACITY_CLIP = $"( not ${ColorfulShadowingOpacityClip:exists} and ${WindscreenMode:bool} and 0.5 ) or ${ColorfulShadowingOpacityClip:bool}"
ATTRIBUTE_0_RFXEXCLUDE = RainFX.WindscreenExclude, $"( not ${RainDrops:exists} and ${WindscreenMesh:exists} ) or ( ${RainDrops:exists} and not ${RainDrops:bool} )"
MOVE_MESH_IN_FRONT_OF = ${WindscreenMesh:?}
CAST_SHADOWS = $" ${CastShadowsThreshold:exists} and 1 or discard() "
PROP_0_BANNERMODE = bannerMode, $" not ${WindscreenMode:bool} and 1 + $BlurBackground or 0 "
PROP_0_KSAMBIENT = ksAmbient, $" ${Brightness:exists} and $Brightness * 0.4 or discard() "
PROP_0_KSDIFFUSE = ksDiffuse, $" ${Brightness:exists} and $Brightness * 0.4 or discard() "
PROP_0_KSALPHAREF = ksAlphaRef, ${CastShadowsThreshold:?}

[TEMPLATE: Material_DigitalScreen EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_SCREEN_...
TAGS = DIGITAL_SCREEN
SHADER = smDigitalScreen
PROP_0_SMSCREENTYPE = smScreenType, $" $MatrixType == 'IPS' and 1 or $MatrixType == 'VA' and 2 or 0 "
PROP_0_SMSCREENSCALE = smScreenScale, $ScreenScale, $" $ScreenScale * $ScreenAspectRatio "
PROP_0_SMUSETEXTURECOORDINATES = smUseTextureCoordinates, $UseTextureCoordinates
PROP_0_SMFLIPXY = smFlipXY, $FlipXY
PROP_0_SMSKEWCOORDINATES = smTextureCoordinatesSkew, $SkewTextureCoordinates
PROP_0_KSEMISSIVE = ksEmissive, $Emissive
MATERIAL_FLAG_1 = $TreatTextureAsHDR

[TEMPLATE: Material_DigitalScreen_GlassOverlay EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_SCREEN_...
TAGS = DIGITAL_SCREEN
BLEND_MODE = MULTIPLY
SHADER = smDigitalScreenGlassOverlay
PROP_0_SMSCREENTYPE = smScreenType, $" $MatrixType == 'IPS' and 1 or $MatrixType == 'VA' and 2 or 0 "
PROP_0_SMSCREENSCALE = smScreenScale, $ScreenScale, $" $ScreenScale * $ScreenAspectRatio "
PROP_0_SMUSETEXTURECOORDINATES = smUseTextureCoordinates, $UseTextureCoordinates
PROP_0_SMFLIPXY = smFlipXY, $FlipXY

[MIXIN: _Material_InteriorPBR_ClearCoat]
@ACTIVE = $UseClearCoat
PROP_0_PBCLEARCOATSMOOTHNESS = pbClearCoatSmoothness, $ClearCoatSmoothness
PROP_0_PBCLEARCOATREFLECTANCE = pbClearCoatReflectance, $ClearCoatReflectance
PROP_0_PBCLEARCOATINTENSITY = pbClearCoatIntensity, $ClearCoatIntensity
PROP_0_PBCLEARCOATTHICKNESS = pbClearCoatThickness, $ClearCoatThickness
PROP_0_PBCLEARCOATIOR = pbClearCoatIOR, $ClearCoatIOR
PROP_0_PBCLEARCOATNORMALSHARE = pbClearCoatNormalShare, $ClearCoatNormalsShare
PROP_0_PBCLEARCOATF0 = pbClearCoatF0, $ClearCoatF0

[FUNCTION: _InteriorPBR_MultiplyMap]
ARGUMENTS = map, multiplier
PRIVATE = 0
CODE = '
  if type(map) ~= "table" then 
    if type(map) ~= "number" then map = 1 end
    map = { map, map } 
  end
  if type(multiplier) ~= "number" then multiplier = 1 end
  return { map[1] * multiplier, map[2] * multiplier }'

[FUNCTION: _InteriorPBR_GuessResourceType]
ARGUMENTS = value, index
PRIVATE = 0
CODE = '
  if type(value) == "table" or type(value) == "number" then 
    return "RESOURCE_COLOR_" .. index
  end
  if string.sub(value, 1, 1) == "/" then
    return "RESOURCE_TEXTURE_" .. index
  end
  if string.find(value, ".") ~= nil then
    return "RESOURCE_FILE_" .. index
  end
  return "RESOURCE_REF_" .. index'

[FUNCTION: _InteriorPBR_AlterResourceValue]
ARGUMENTS = value
PRIVATE = 0
CODE = '
  if type(value) == "string" and string.sub(value, 1, 1) == "/" then
    return string.sub(value, 2)
  end
  return value'

[TEMPLATE: Material_InteriorPBR EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_INTPBR_...
TAGS = PBR
@MIXIN = _Material_InteriorPBR_ClearCoat
SHADER = $" ${UseClothShading:bool} and 'nePBR_MultiMap_Cloth' or ( ${HasDetailNormals:bool} 
  and ( ${UseClearCoat:bool} and 'nePBR_MultiMap_NMDetail_ClearCoat' or 'nePBR_MultiMap_NMDetail' ) 
  or ( ${UseClearCoat:bool} and 'nePBR_MultiMap_ClearCoat' or 'nePBR_MultiMap' ) ) "
FILL_MISSING_TEXTURES = 1
PROP_0_KSDIFFUSE = ksDiffuse, $" ${Brightness:exists} and ${Brightness} or (${BrightnessAdjustment:exists} and ${BrightnessAdjustment} * 2.5 or discard() ) "
PROP_0_KSALPHAREF = ksAlphaRef, $" ${ApplyTilingFix:bool} and -193 or 0 "
PROP_0_PBOCCLUSION = pbOcclusion, $OcclusionMap
PROP_0_PBSMOOTHNESS = pbSmoothness, $" _InteriorPBR_MultiplyMap( $SmoothnessMap, $Smoothness ) "
PROP_0_PBMETALNESS = pbMetalness, $" _InteriorPBR_MultiplyMap( $MetalnessMap, $Metalness ) "
PROP_0_PBREFLECTANCE = pbReflectance, $" _InteriorPBR_MultiplyMap( $ReflectanceMap, $Reflectance ) "
PROP_0_PBAMBIENTSPEC = pbAmbientSpec, $AmbientSpecular
PROP_0_PBAMBIENTSPECEXP = pbAmbientSpecEXP, $AmbientSpecularEXP
PROP_0_PBCOLORSOURCE = pbColorSource, $" (($ColorSource == 'diffuseNormalized' or $ColorSource == 'DIFFUSE_NORMALIZED') and 1 or ($ColorSource == 'forceWhite' or $ColorSource == 'FORCE_WHITE') and 2 or ($ColorSource == 'desaturate' or $ColorSource == 'DESATURATE') and 3 or 0.1) * (${ForceDetailEverywhere:bool} and -1 or 1) "
PROP_0_PBOCCLUSIONSOURCE = pbOcclusionSource, $" ($OcclusionSource == 'luminance' or $OcclusionSource == 'LUMINANCE') and 1 or ($OcclusionSource == 'mapsAlpha' or $OcclusionSource == 'MAPS_ALPHA') and 2 or 0 "
PROP_0_PBOCCLUSIONMULT = pbOcclusionMult, $OcclusionMult
PROP_0_PBREFLECTIONBLURENV = pbReflectionBlurEnv, $" $CubemapReflectionBlur * 6 "
PROP_0_USEDETAIL = useDetail, $" ${DetailNormalPBRFormat:bool} or ${HasDetailNormals:bool} or ${UseDetail:bool} and 1 or 0 "
PROP_0_PBNORMALDETAILINPBRFORMAT = pbNormalDetailInPBRFormat, $DetailNormalPBRFormat
PROP_0_PBNORMALDETAILPBROCCLUDEDCOLOR = pbNormalDetailPBROccludedColor, ${DetailNormalPBRSecondaryColor:vec4}
PROP_0_PBNORMALDETAILPBRMULTS = pbNormalDetailPBRMults, $DetailNormalPBRReflectance, $DetailNormalPBRSmoothness, $DetailNormalPBRMetalness
PROP_0_EXTRASHARPLOCALREFLECTIONS = extExtraSharpLocalReflections, $" def( $LocalReflectionsSharpness, 0.001 ) * ( def( $LocalReflectionsForce, 1 ) == 1 and -1 or 1 ) " 
PROP_0_DETAILNORMALBLEND = detailNormalBlend, ${DetailNormalBlend:?}
PROP_0_DETAILUVMULTIPLIER = detailUVMultiplier, ${DetailScale:?}
PROP_0_PBCLOTHSHEENCOLOR = pbClothSheenColor, $" def3( $ClothSheenColor, 1, 1, 1 )"
PROP_0_PBCLOTHSUBSURFACECOLOR = pbClothSubsurfaceColor, $" def3( $ClothSubsurfaceColor, 0, 0, 0 )"
PROP_0_PBBLURCOLORS = pbBlurColors, $DetailTextureBlur
PROP_0_PBROUGHNESSEXP = pbRoughnessEXP, $DetailNormalPBRSmoothnessGamma
PROP_0_SHADOWBIASMULT = shadowBiasMult, $" ${ApplyShadowBiasFix:bool} and -1 * def($ShadowBiasFixStrength, 1) or discard() "
RESOURCE_0 = $" ${DetailTexture:exists} and 'txDetail' or discard() "
$" _InteriorPBR_GuessResourceType($DetailTexture, 0) " = $" _InteriorPBR_AlterResourceValue(${DetailTexture:?})"
RESOURCE_1 = $" ${DetailNormalTexture:exists} and 'txNormalDetail' or discard() "
$" _InteriorPBR_GuessResourceType($DetailNormalTexture, 1) " = $" _InteriorPBR_AlterResourceValue(${DetailNormalTexture:?})"
RESOURCE_2 = $" ${NormalTexture:exists} and 'txNormal' or discard() "
$" _InteriorPBR_GuessResourceType($NormalTexture, 2) " = $" _InteriorPBR_AlterResourceValue(${NormalTexture:?})"
RESOURCE_3 = $" ${DiffuseTexture:exists} and 'txDiffuse' or discard() "
$" _InteriorPBR_GuessResourceType($DiffuseTexture, 3) " = $" _InteriorPBR_AlterResourceValue(${DiffuseTexture:?})"
DOUBLE_FACE_SHADOW_BIASED = 1


[TEMPLATE: Material_Fur EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_FUR_...
TAGS = FUR
SHADER = nePerPixelMultiMap_NMDetail_fur
_FurLayers = $" max($FurLayers, 2) "
FUR_LAYERS = $_FurLayers
PROP_0_FURSCALE = furScale, $" $FurScale * 0.0025 "
PROP_0_FURFACINGMULT = furFacingMult, $FurFacingScale
PROP_0_FURVERTICALOFFSET = furVerticalOffset, $" -0.7 * clamp($FurGravityFactor, -1.2, 1.2) "
PROP_0_FURFIDELITYSCALE = furFidelityScale, $" (${FurUseTextures:bool} and 1 or -1) * 2.7 * $FurFidelityScale "
PROP_0_FURTHRESHOLDEXP = furThresholdExp, $ThresholdExponent
PROP_0_FURTHRESHOLDMULT = furThresholdMult, $ThresholdMultipler
PROP_0_FUROCCLUSION = furOcclusion, $" max(1 - $FurOcclusion, 0) "
PROP_0_FURRIMEXP = furRimExp, $FurRimExponent
PROP_0_FURAMBIENT = furAmbient, $" $FurAmbient * 2 "
PROP_0_FURDIFFUSE = furDiffuse, $FurDiffuse