; --
; Material library for track 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]
HorizonMaterials = ; horizont  ; fix blending for horizon thing
WaterForceOpaque =             ; list of meshes to set to opaque
WaterForceBlending =           ; list of meshes to set to semi-transparent blending

; Bales (straw cubes), uses fur shader
[TEMPLATE: Material_Bale]
FurLayers = 5         ; 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 = 0    ; 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
FurWorldUVScale = 0   ; scale of world UV to break repetition

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

; Digital screens, with pixels and all that
[TEMPLATE: Material_DigitalScreen]
MatrixType = TN            ; valid values: IPS, TN
UseMultiMap = 0            ; set to 1 to use multimap compatible shader with masking
UseTextureCoordinates = 0  ; with 0, vertex coordinates will be used. sometimes it’s better, sometimes it’s buggier. not available with UseMultiMap
ScreenScale = 200          ; amount of pixels horizontally
ScreenAspectRatio = 1      ; aspect ratio, height/width
Emissive = 4               ; screen brightness
FlipXY = 0                 ; rotate display 90°

; for UseMultiMap mode, masking for digital screen part
UseDiffuseMask = 0         ; use txDiffuse alpha-channel for masking (use INVERT to make it digital screen where texture is transparent)
UseMapsMask = 0            ; use txMaps alpha-channel for masking (use INVERT to make it digital screen where texture is transparent)
UseNormalMask = 0          ; use txNormal alpha-channel for masking (use INVERT to make it digital screen where texture is transparent)
UseAreaMask = 0            ; use rectangle area for masking (use INVERT to make it digital screen outside of rectange area)
GlitchEffect = 0.0         ; simple glitching effect to look more alive

; only for UseMultiMap with non-zero UseAreaMask
AreaMaskCenter = 0.5, 0.5  ; center point of masking rectangle, from 0 to 1 by default
AreaMaskSize = 0.5, 0.5    ; size of masking rectangle, from 0 to 1 by default
AreaMaskTotalSize = 1, 1   ; set size of texture in pixels here to use pixels instead of 0…1 range for AreaMaskCenter and AreaMaskSize

; Water surface, uses two normal textures (could be the same texture used twice),
; with a few modes it can operate in
[TEMPLATE: Material_Water]
Type = LAKE                    ; valid values: LAKE, POND, POOL, SEA, OCEAN
UseNormalMapTwice = 0          ; use txNormal as secondary normal map
UseAlphaFromDiffuse = 0        ; use alpha-channel from txDiffuse for blending
UseAlphaFromNormal = 0         ; use alpha-channel from txNormal for blending
UseRecommendedTextures = 1     ; use recommended textures for water normals
UseRecommendedDetailTexture = 0  ; same, but only for secondary normals texture
UnevenWaterFix = 0             ; increase for uneven water meshes. messes up distant reflections a bit, but reduces dark self-reflecting artifacts
                               ; these ones: https://i.imgur.com/tnbMe8Z.png
; FirstNormalMap = water.dds   ; specify texture from KN5 to be used as main normal map
; SecondNormalMap = water.dds  ; specify different texture from KN5 to be used as secondary normal map

; Alternative for ksPerPixel/ksPerPixelAlpha for those very bright emissive bits
; of lamp posts, which solves flickering issue with distance and adds distant glow
[TEMPLATE: Material_DistantEmissive]
UseAlpha = 0                ; set to 1 if you’re replacing ksPerPixelAlpha, so alpha property would be used
UseEmissiveTexture = 0      ; set to 1 to use txEmissive texture
FloodlightPower = 0.0       ; increase value for floodlight mode, so emissiveness would increase if camera is right in front
FloodlightEXP = 20.0        ; increase for more focused floodlight effect
DistantGlowTextured = 1     ; use slightly blurried sample from txDiffuse for distant glow
BrightnessMult = 1          ; multiplier for brightness
DotMaxDistance = 2000       ; max distance for dot glow (starts fading out at half of it)

; Please avoid editing those values unless there is a real need for that
DistantGlowMult_v2 = 1.0       ; brightness of distant glow
DistanceMult_v2 = 1.0          ; multiplier for distance, for dimming and glow effect
DistantGlowEXP_v2 = 1.0        ; gradient of distant glow
DistantGlowHeightMult_v2 = 1.0 ; height of distant glow
DistantGlowRadius_v2 = 1.0     ; multiplier for distant glow radius
DistanceSoftFactor_v2 = 1.0    ; factor for soft blending
DotRadiusMult_v2 = 1           ; radius of dot glow
DotBrightnessMult_v2 = 1       ; base brightness of dot glow
DotBrightnessCenter_v2 = 1     ; center brightness of dot glow

; Alternative for MultiMap shader with displacement map, stored in alpha-channel of “txNormal”,
; could work either in parallax or tesselation mode depending on settings.
[TEMPLATE: Material_DisplacementMap]
UseTessellation = 0     ; use tessellation shader (requires specially prepared mesh; don’t forget to make sure it would work 
                        ; without that option since some people won’t be using tessellation)
UseParallaxShadows = 0  ; use parallax shadows (slower)

DisplacementDistanceFar = 40.0  ; how far displacement is calculated
DisplacementDistanceNear = 0.5  ; at what distance displacement starts to fade out
DisplacementScale = 1.0         ; scale for displacement
DisplacementOcclusion = 0.2     ; how dark are deepest parts

TessellationFactorMin = 1   ; for tesselation, how much to split mesh at the distance
TessellationFactorMax = 20  ; how much to split mesh nearby

ParallaxEXP = 1.0       ; increase to adjust gamma of heightmap
DisplacementInvert = 0  ; invert height map (just in case)

; Only for ksPerPixel, ksPerPixelAT, ksPerPixelNM, ksMultilayer and ksMultilayer_fresnel_nm! 
; “Squashes” geometry to make sure it won’t clip against far clip plane. Doesn’t affect fog, lighting and other visual aspects, 
; only makes sure to fit mesh in view frustum.
; Warning: highly experimental for now. I’m not sure there won’t be some nasty side effects. Haven’t noticed anything yet though.
[TEMPLATE: Material_DistantGeometry]
DistantCompressionStart = 2000  ; starts squishing after this distance
DistantCompressionRate = 100    ; squishing rate: compresses stuff along view direction in this number of times
RemoveLODOut = 0                ; set to 1 to disable distant LOD hiding for those meshes

; Material for those tubular things near horizon, used for distant landscape. Main changes: switches blending to alpha test, 
; disables transparency and and switches to a new shader based on ksPerPixel, without dynamic lights, but with a lot of other
; options allowing to alter texture (for example, to get rid of bluish tint so WeatherFX could function properly).
[TEMPLATE: Material_Horizon]
; in order of application:
LocalContrast = 1        ; cheap contrast boost based on mipmaps
LocalContrastBlur = 4    ; which mipmap to take to boost contrast from
SaturatedTint = 1, 1, 1  ; tint (multiply) color in saturated areas; values like “1, 0.8, 0” can get rid of fog
SaturatedAdd = 0, 0, 0   ; add color in saturated areas
Tint = 1, 1, 1           ; tint (multiply) color everywhere
Add = 0, 0, 0            ; add color everywhere
Saturation = 1           ; saturation, increase to boost color
Brightness = 1           ; brightness
Gamma = 1                ; gamma
FogMultiplier = 1        ; increase to make foggier; don’t decrease
AlignNormals = 0         ; set to 1 to align all normals vertically
UseAO = 0                ; set to 1 to re-enable AO (both screen-space and vertex), should not be needed

; Alternative for ksMultiMap/ksMultiMap_emissive, for windows, adding a bit of insides in
; the style of Watch Dogs
[TEMPLATE: Material_RoomWindows EXTENDS _Base_Material_Custom]

; Start by setting DebugMode to 1, and deciding on EmissiveMode
DebugMode = 0                   ; mark some special areas for easier positioning
EmissiveMode = DIFFUSE_TEXTURE  ; valid values: DIFFUSE_TEXTURE, DIFFUSE_WITH_EMISSIVE, DIFFUSE_EMISSIVE_BLEND, ONE
  ; DIFFUSE_TEXTURE: emissive = ksEmissive × txDiffuse
  ; DIFFUSE_WITH_EMISSIVE: emissive = ksEmissive × txDiffuse × txEmissive
  ; DIFFUSE_EMISSIVE_BLEND: emissive = ksEmissive × (txDiffuse × (1 - txEmissive.alpha) + txEmissive × txEmissive.alpha)
  ; ONE: emissive = ksEmissive

; After that, decide how to bind floors to model. You can either define them in world-space, for the whole model:
RoomHeight = 3.0          ; with DebugMode, it’s easy to find a good height; notice that ceiling is at the upper edge of red line
RoomVerticalOffset = 3.0  ; changing height would mess up vertical offset, so set it second, that’s the nature of world-space

; Or, you can bind them to texture coordinates, if window texture is nicely repeated all over the place:
SnapToTexCoords = 0        ; for that, change this flag to 1
TexCoordsSnapScale = 1.0   ; how many repeats will make a floor? set this value here
TexCoordsSnapOffset = 0.0  ; offset for texture coordinates snapping

; Once floors are set, you can align them nicely:
RoomCeilingRotation = 0.0  ; rotate ceiling to align it with the building
RoomCeilingScale = 1, 1    ; if needed, you can scale ceiling
RoomCeilingOffset = 0, 0   ; and add some offset so lamps would align nicely with windows

; If you got here, most difficult part is complete. Now, let’s adjust shape if needed (or, skip this step):
Shape1_X_W = 0.14      ; size of a lamp in X axis (in ceiling coordinates)
Shape1_Y_W = 0.6       ; size of a lamp in Y axis 
Shape2_X_W = 0.02      ; size of separator in X axis
Shape2_X_Mult = -0.05  ; effect of separator in X axis (set to 0 to disable)
Shape2_Y_W = 0.02      ; size of separator in Y axis
Shape2_Y_Mult = 0.0    ; effect of separator in Y axis (set to 0 to disable)
ShapeSmoothness = 0.0  ; smoothness/bubbiness of resulting shape, from 0.0 to 1.0
                       ; if you want to get a round lamp, set size to 0 and smoothness to 0.7…1.0
ShapeChance = 0.8      ; chance of lamp appearing in a slot

; After shape is ready, we can adjust brightness, but first, a few preparations (changing those settings
; might invalidate brightness)
NormalsFactor = 0.9        ; with 0, interior is seen everywhere; increase to occlude interior at glazing angles
                           ; usually, 0.8 should work great, but if normals are messed up, change to 0
EmissiveDiffuseMult = 1.0  ; multiplier for txDiffuse for emissiveness (if used in EmissiveMode); will be clipped to 1
EmissiveDiffuseEXP = 0.0   ; if non-zero, txDiffuse will be desaturated. set to more than zero to make dark areas 
                           ; of txDiffuse hide interior better

; And here are brightness parameters:
InteriorMult = 1.0                     ; general brightness multiplier for interior lighting
InteriorBaseBrightness = 0.5           ; constant background brightness for interior
InteriorVolumeBrightness = 1.5         ; brightness of volumetric light inside, changing with view angle
InteriorLightsBrightness = 1.0         ; brightness of actual lights, multiplier
InteriorGlowBrightness = 1.0           ; and multiplier for glow effect for those lights
InteriorVolumeAmbientBrightness = 1.0  ; brightness of volumetric light during the day, depends on ambient

; After everything else is done, you can adjust depth and clipping near windows:
RoomDepth = 3.0              ; in meters, usually 3.0 is enough for small buildings, but thicker ones might need values up to 10
RoomNearEdgeClipping = -1.0  ; coefficient for clipping near windows, set to -1.0 to disable that clipping

; Optional distortion to normals, to simulate glass which is rarely perfectly flat
NormalDistortionScale = 1
NormalDistortionAmount = 1

; --
; 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]

[MATERIAL_ADJUSTMENT_...]
ACTIVE = ${WaterForceOpaque:count}
MESHES = ${WaterForceOpaque}
BLEND_MODE = OPAQUE

[MESH_ADJUSTMENT_...]
ACTIVE = ${WaterForceOpaque:count}
MESHES = ${WaterForceOpaque}
IS_TRANSPARENT = 0

[MATERIAL_ADJUSTMENT_...]
ACTIVE = ${WaterForceBlending:count}
MESHES = ${WaterForceBlending}
BLEND_MODE = ALPHA_BLEND

[MESH_ADJUSTMENT_...]
ACTIVE = ${WaterForceBlending:count}
MESHES = ${WaterForceBlending}
IS_TRANSPARENT = 1

[MATERIAL_ADJUSTMENT_0_FIX_HORIZON]
ACTIVE = ${HorizonMaterials:count}
MATERIALS = ${HorizonMaterials}
BLEND_MODE = ALPHA_TEST

[TEMPLATE: Material_Bale 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.05 "
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) * 1.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
PROP_0_FURWORLDUVSCALE = furWorldUvScale, $FurWorldUVScale

[TEMPLATE: Material_DigitalScreen EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_SCREEN_...
TAGS = DIGITAL_SCREEN
SHADER = $" $UseMultiMap == 1 and 'nePerPixelMultiMap_digitalScreen' or 'smDigitalScreen' "
FILL_MISSING_TEXTURES = 1
PROP_0_SMSCREENTYPE = smScreenType, $" $MatrixType == 'IPS' and 1 or 0 "
PROP_0_SMSCREENSCALE = smScreenScale, $ScreenScale, $" $ScreenScale * $ScreenAspectRatio "
PROP_0_SMUSETEXTURECOORDINATES = smUseTextureCoordinates, $UseTextureCoordinates
PROP_0_SMFLIPXY = smFlipXY, $FlipXY
PROP_0_KSEMISSIVE = ksEmissive, $Emissive
PROP_0_SMMASKDIFFUSEALPHA = smMaskDiffuseAlpha, $" $UseDiffuseMask == 'INVERT' and 2 or $UseDiffuseMask == 'NORMAL' and 1 or $UseDiffuseMask "
PROP_0_SMMASKMAPSALPHA = smMaskMapsAlpha, $" $UseMapsMask == 'INVERT' and 2 or $UseMapsMask == 'NORMAL' and 1 or $UseMapsMask "
PROP_0_SMMASKNORMALALPHA = smMaskNormalAlpha, $" $UseNormalMask == 'INVERT' and 2 or $UseNormalMask == 'NORMAL' and 1 or $UseNormalMask "
PROP_0_SMMASKAREA = smMaskArea, $" $UseAreaMask == 'INVERT' and 2 or $UseAreaMask == 'NORMAL' and 1 or $UseAreaMask "
PROP_0_SMMASKCENTERX = smMaskCenterX, $" ${AreaMaskCenter:1} / ${AreaMaskTotalSize:1} "
PROP_0_SMMASKCENTERY = smMaskCenterY, $" ${AreaMaskCenter:2} / ${AreaMaskTotalSize:2} "
PROP_0_SMMASKWIDTHHALF = smMaskWidthHalf, $" ${AreaMaskSize:1} / ${AreaMaskTotalSize:1} / 2 "
PROP_0_SMMASKHEIGHTHALF = smMaskHeightHalf, $" ${AreaMaskSize:2} / ${AreaMaskTotalSize:2} / 2 "
PROP_0_SMSMGLITCHMULT = smGlitchMult, $" $GlitchEffect "
; PROP_0_KSAMBIENT = ksAmbient, 1000

[MIXIN: _Material_Water_ReuseNormal]
@ACTIVE = ${UseNormalMapTwice}
RESOURCE_0 = txDetailNM
RESOURCE_REF_0 = txNormal

[MIXIN: _Material_Water_FirstNormalMap]
@ACTIVE = ${FirstNormalMap:count}
RESOURCE_1 = txNormal
RESOURCE_TEXTURE_1 = $FirstNormalMap

[MIXIN: _Material_Water_SecondNormalMap]
@ACTIVE = ${SecondNormalMap:count}
RESOURCE_2 = txDetailNM
RESOURCE_TEXTURE_2 = $SecondNormalMap

[MIXIN: _Material_Water_UseRecommendedTextures]
@ACTIVE = ${UseRecommendedTextures}
RESOURCE_1 = txNormal
RESOURCE_2 = txDetailNM
RESOURCE_FILE_1 = common/water_normal.dds
RESOURCE_FILE_2 = common/water_normal.dds

[MIXIN: _Material_Water_UseRecommendedDetailTexture]
@ACTIVE = ${UseRecommendedDetailTexture}
RESOURCE_2 = txDetailNM
RESOURCE_FILE_2 = common/water_normal.dds

[MIXIN: _Material_Water_UseAlphaFromDiffuse]
@ACTIVE = ${UseAlphaFromDiffuse}
PROP_0_KSEMISSIVE = useAlphaFromDiffuse, 1

[MIXIN: _Material_Water_UseAlphaFromNormal]
@ACTIVE = ${UseAlphaFromNormal}
PROP_0_KSEMISSIVE = useAlphaFromNormal, 1

[FUNCTION: _Material_Water_MapType]
ARGUMENTS = Type
CODE = '
  local types = {
    OCEAN = -2,
    LAKE = -1,
    SEA = 0,
    POOL = 1,
    POND = 3
  }
  return types[Type] or 0
'

[TEMPLATE: Material_Water EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_WATER_...
TAGS = NEW_WATER
SHADER = smWaterSurface
PROP_0_KSALPHAREF = ksAlphaRef, $" _Material_Water_MapType( $Type ) "
PROP_0_UNEVENWATERFIX = unevenWaterFix, $UnevenWaterFix
@MIXIN = _Material_Water_ReuseNormal
@MIXIN = _Material_Water_FirstNormalMap
@MIXIN = _Material_Water_SecondNormalMap
@MIXIN = _Material_Water_UseRecommendedTextures
@MIXIN = _Material_Water_UseRecommendedDetailTexture
@MIXIN = _Material_Water_UseAlphaFromDiffuse
@MIXIN = _Material_Water_UseAlphaFromNormal

[TEMPLATE: Material_DistantEmissive EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_DISTANTEMISSIVE_...
SHADER = nePerPixel_light
PROP_0_ALPHA = $" $UseAlpha and '_nothing' or 'alpha' ", 1

PROP_0_EXTUSETXEMISSIVE = extUseTxEmissive, $UseEmissiveTexture
PROP_0_EXTDISTANCEMULT = extDistanceMult, $DistanceMult_v2

PROP_0_EXTPROJECTORPOWER = extProjectorPower, $FloodlightPower
PROP_0_EXTPROJECTOREXP = extProjectorEXP, $FloodlightEXP
PROP_0_EXTDISTANTMULT = extDistantMult, $" max($DistantGlowMult_v2, 0.001) * $BrightnessMult * 0.2 "
PROP_0_EXTDISTANTEXP = extDistantEXP, $" $DistantGlowEXP_v2 "

PROP_0_EXTDOTRADIUSMULT = extDotRadiusMult, $" $DotRadiusMult_v2 * 24 "
PROP_0_EXTDOTBRIGHTNESSBASE = extDotBrightnessBase, $" $DotBrightnessMult_v2 * 0.0625 "
PROP_0_EXTDOTBRIGHTNESSCENTER = extDotBrightnessCenter, $" $DotBrightnessCenter_v2 * $BrightnessMult * 40 "
PROP_0_EXTDOTCENTEREXP = extDotCenterEXP, $" $BrightnessMult * 12 "

PROP_0_EXTDISTANTUSETEXTURE = extDistantUseTexture, $DistantGlowTextured
PROP_0_EXTDISTANTCONCENTRATIONK = extDistantHeightMult, $" $DistantGlowHeightMult_v2 * 0.5 "
PROP_0_EXTDISTANTRADIUSMULT = extDistantRadiusMult, $" $DistantGlowRadius_v2 * 50 "
PROP_0_EXTDISTANTSOFTK = extDistantSoftK, $" $DistanceSoftFactor_v2 * 40 "
PROP_0_EXTMAXDISTANCEHALFINV = extMaxDistanceHalfInv, $" 2 / $DotMaxDistance "

[FUNCTION: _RoomWindows_CalculateS]
ARGUMENTS = S, smoothness
CODE = '
  return S * (1 - 0.75 * smoothness)'

[FUNCTION: _RoomWindows_CalculateES0Neg]
ARGUMENTS = W, S, smoothness
CODE = '
  local s = S * (1 - 0.75 * smoothness)
  return - ( 0.5 - W / 2 - 1 / s ) * s'

[FUNCTION: _RoomWindows_CalculateES1Neg]
ARGUMENTS = W, S, smoothness
CODE = '
  local s = S * (1 - 0.75 * smoothness)
  return ( 0.5 + W / 2 + 1 / s ) * s'

[TEMPLATE: Material_RoomWindows EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_ROOMWINDOWS_...
SHADER = nePerPixelMultiMap_windows
FILL_MISSING_TEXTURES = 1

; Hidden parameters, no need to edit them unless you need to
Shape1_X_S = 6.0
Shape1_Y_S = 6.0
Shape2_X_S = 100
Shape2_Y_S = 100

PROP_0_EXTTXEMISSIVEMODE = extTxEmissiveMode, $" $EmissiveMode == 'DIFFUSE_EMISSIVE_BLEND' and 2 or $EmissiveMode == 'DIFFUSE_WITH_EMISSIVE' and 1 or $EmissiveMode == 'ONE' and 3 or 0 "
PROP_0_ROOMSCALE = extRoomScale, $RoomHeight
PROP_0_ROOMOFFSET = extRoomOffset, $RoomVerticalOffset
PROP_0_ROOMROTATION = extRoomRotation, $" $RoomCeilingRotation * 3.141592 / 180 "
PROP_0_ROOMCEILINGOFFSET = extRoomCeilingOffset, $RoomCeilingOffset
PROP_0_ROOMCEILINGSCALE = extRoomCeilingScale, $RoomCeilingScale
PROP_0_EXTSNAPTOTEXCOORDS = extSnapToTexCoords, $SnapToTexCoords
PROP_0_EXTDEBUGMODE = extDebugMode, $DebugMode
PROP_0_EXTNEAREDGEOFFSET = extNearEdgeOffset, $RoomNearEdgeClipping
PROP_0_EXTFARDISTANCEINV = extFarDistanceInv, $" 1 / min(max($RoomDepth, 0.001), 20) "
PROP_0_EXTBRIGHTNESSBASE = extBrightnessBase, $" $InteriorMult * $InteriorBaseBrightness "
PROP_0_EXTBRIGHTNESSVOLUME = extBrightnessVolume, $" $InteriorMult * $InteriorVolumeBrightness "
PROP_0_EXTBRIGHTNESSLIGHTS = extBrightnessLights, $" $InteriorMult * $InteriorLightsBrightness * 8 "
PROP_0_EXTBRIGHTNESSGLOW = extBrightnessGlow, $" $InteriorMult * $InteriorGlowBrightness * 0.15 "
PROP_0_EXTTEXCOORDSSNAPSCALE = extTexCoordsSnapScale, $TexCoordsSnapScale
PROP_0_EXTEMISSIVEDIFFUSEMULT = extEmissiveDiffuseMult, $EmissiveDiffuseMult
PROP_0_EXTEMISSIVEDIFFUSEEXP = extEmissiveDiffuseEXP, $EmissiveDiffuseEXP
PROP_0_EXTNORMALSFACTOR = extNormalsFactor, $NormalsFactor
PROP_0_EXTTEXCOORDSSNAPOFFSET = extTexCoordsSnapOffset, $" $TexCoordsSnapOffset / $TexCoordsSnapScale "
PROP_0_EXTBRIGHTNESSAMBIENTVOLUME = extBrightnessAmbientVolume, $" $InteriorVolumeAmbientBrightness * 0.4 "

PROP_0_SHAPEXS0 = shapeXS, $" _RoomWindows_CalculateS( $Shape1_X_S, $ShapeSmoothness ) "
PROP_0_SHAPEXES0NEG = shapeXES0Neg, $" _RoomWindows_CalculateES0Neg( $Shape1_X_W, $Shape1_X_S, $ShapeSmoothness ) "
PROP_0_SHAPEXES1NEG = shapeXES1Neg, $" _RoomWindows_CalculateES1Neg( $Shape1_X_W, $Shape1_X_S, $ShapeSmoothness ) "

PROP_0_SHAPEYS0 = shapeYS, $" _RoomWindows_CalculateS( $Shape1_Y_S, $ShapeSmoothness ) "
PROP_0_SHAPEYES0NEG = shapeYES0Neg, $" _RoomWindows_CalculateES0Neg( $Shape1_Y_W, $Shape1_Y_S, $ShapeSmoothness ) "
PROP_0_SHAPEYES1NEG = shapeYES1Neg, $" _RoomWindows_CalculateES1Neg( $Shape1_Y_W, $Shape1_Y_S, $ShapeSmoothness ) "

PROP_0_SHAPEX1S0 = shapeX1S, $" _RoomWindows_CalculateS( $Shape2_X_S, $ShapeSmoothness ) "
PROP_0_SHAPEX1ES0NEG = shapeX1ES0Neg, $" _RoomWindows_CalculateES0Neg( $Shape2_X_W, $Shape2_X_S, $ShapeSmoothness ) "
PROP_0_SHAPEX1ES1NEG = shapeX1ES1Neg, $" _RoomWindows_CalculateES1Neg( $Shape2_X_W, $Shape2_X_S, $ShapeSmoothness ) "
PROP_0_SHAPEX1MULT = shapeX1Mult, $Shape2_X_Mult

PROP_0_SHAPEY1S0 = shapeY1S, $" _RoomWindows_CalculateS( $Shape2_Y_S, $ShapeSmoothness ) "
PROP_0_SHAPEY1ES0NEG = shapeY1ES0Neg, $" _RoomWindows_CalculateES0Neg( $Shape2_Y_W, $Shape2_Y_S, $ShapeSmoothness ) "
PROP_0_SHAPEY1ES1NEG = shapeY1ES1Neg, $" _RoomWindows_CalculateES1Neg( $Shape2_Y_W, $Shape2_Y_S, $ShapeSmoothness ) "
PROP_0_SHAPEY1MULT = shapeY1Mult, $Shape2_Y_Mult

PROP_0_SHAPEPOWER = shapePower, $" 1 + $ShapeSmoothness * 2 "
PROP_0_SHAPECHANCE = shapeChance, $ShapeChance

PROP_0_NORMALDISTORTIONSCALE = extNormalNoiseScale, $" $NormalDistortionScale * 0.02 "
PROP_0_NORMALDISTORTIONAMOUNT = extNormalNoiseAmount, $" $NormalDistortionAmount * 0.02 "

[TEMPLATE: Material_DisplacementMap EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_DISPLACEMENT_...
SHADER = $" $UseTessellation == 1 and 'nePerPixelMultiMap_tessellation' or $UseParallaxShadows == 1 and 'nePerPixelMultiMap_parallax' or 'nePerPixelMultiMap_parallax_noshadows' "
PROP_0_EXTMINTESSELATIONFACTOR = extMinTesselationFactor, $TessellationFactorMin
PROP_0_EXTMAXTESSELATIONFACTOR = extMaxTesselationFactor, $TessellationFactorMax
PROP_0_EXTMINDISPLACEMENTDISTANCE = extMinDisplacementDistance, $DisplacementDistanceFar
PROP_0_EXTMAXDISPLACEMENTDISTANCE = extMaxDisplacementDistance, $DisplacementDistanceNear
PROP_0_EXTHEIGHTSCALE = extHeightScale, $" $DisplacementScale * 0.05 "
PROP_0_EXTPARALLAXSCALE = extParallaxScale, $" $DisplacementScale * 0.01 "
PROP_0_EXTPARALLAXHEIGHTEXP = extParallaxHeightEXP, $ParallaxEXP
PROP_0_EXTDISPLACEMENTINVERT = extDisplacementInvert, $DisplacementInvert
PROP_0_EXTOCCLUSIONVALUE = extOcclusionValue, $DisplacementOcclusion

[MIXIN: _Material_DistantGeometry_RemoveLODOut]
@ACTIVE = ${RemoveLODOut}
LOD_OUT = 0

[TEMPLATE: Material_DistantGeometry EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_0_DISTANTGEO_...
PROP_0_EXTDISTANTFIXSTART = extDistantFixStart, $DistantCompressionStart
PROP_0_EXTDISTANTFIXMULT = extDistantFixMult, $" 1 / max($DistantCompressionRate, 1) "
DISABLE_FAR_PLANE_CLIPPING = 1
@MIXIN = _Material_DistantGeometry_RemoveLODOut

[TEMPLATE: Material_Horizon EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_...
SHADER = ksPerPixel_horizon
BLEND_MODE = ALPHA_TEST
DEPTH_MODE = DEPTH_NORMAL
IS_TRANSPARENT = 0
PROP_0 = ccSaturation, $" def( $Saturation, 1 ) "
PROP_1 = ccBrightness, $" def( $Brightness, 1 ) "
PROP_2 = ccGamma, $" def( $Gamma, 1 ) "
PROP_3 = ccTintAdd, $" def3( $Add, 0, 0, 0 ) "
PROP_4 = ccTintMult, $" def3( $Tint, 1, 1, 1 ) "
PROP_5 = ccTintSatAdd, $" def3( $SaturatedAdd, 0, 0, 0 ) "
PROP_6 = ccTintSatMult, $" def3( $SaturatedTint, 1, 1, 1 ) "
PROP_7 = ccLocalContrast, $" def( $LocalContrast, 1 ) "
PROP_8 = ccLocalConstrastBlur, $" def( $LocalContrastBlur, 4 ) "
PROP_9 = ccFogMult, $" def( $FogMultiplier, 1.2 ) "
PROP_10 = ccAlignNormals, $" def( $AlignNormals, 0 ) "
PROP_11 = ccNoAo, $" 1 - def( $UseAO, 0 ) "
