[INCLUDE: common/materials_base.ini]

[TEMPLATE: Material_PBR]
; Core PBR parameters:
F0 = 0.04                ; base reflectivity for non-metal materials with metalness workflow
Emissive = 0, 0, 0       ; emissive value
AlbedoGain = 1, 1, 1     ; RGB multiplier for albedo texture
BlurCubemap = 0          ; forcefully blur cubemap (use it to reduce details in reflections in areas where cubemap does not fit well)
RoughnessGamma = 1       ; gamma for roughness (not recommended to change)

; Textures:
TextureAlbedo =          ; albedo map without ambient occlusion
TextureNormal =          ; normal texture, only red and green channels are read (use DXT5NM flag as second parameter if texture is in dxt5nm format)
TextureEmAoMeRo =        ; emissive, ambient, metalness and roughness maps in RGBA channels accordingly (arranged for better visual with DXT5/BC7 compression)
TextureSpecular =        ; specular map, used only with specular workflow; if not set, metalness map is used as specular map
TextureVarianceAO =      ; optional albedo variance and additional AO map, uses UV2 (only active when corresponding flags are set)

; Flags:
SpecularWorkflow = 0       ; by default metalness workflow is used, set this to 1 to switch to specular (or set optional TextureSpecular value)
ApplyTilingFix = 0         ; apply tiling fix (not available with parallax)
ApplyAOMap = 0             ; apply extra AO map from TextureVarianceAO
ApplyVarianceMap = 0       ; apply albedo variance map from TextureVarianceAO (applied as multiplier)
SkipAlbedoForEmissive = 0  ; do not use albedo for emissive color

; Optional parallax. To use, set this texture to height map:
TextureDisplacement =    ; currently, texture has to be square
DisplacementMax = 50     ; maximum distance at which displacement is active
DisplacementMin = 30     ; minimum distance at which displacement is active
ParallaxScale = 0.02     ; parallax depth
ParallaxSteps = 20       ; maximum number of steps, increase to improve visual quality (expensive)
ParallaxOffset = 0.5     ; what value of displacement texture is considered neutral, 0.5 for gray, 0 for white, 1 for black

[TEMPLATE: Material_PBR EXTENDS _Base_Material_Custom]
@OUTPUT = SHADER_REPLACEMENT_...
SHADER = $" ${TextureDisplacement:exists} and 'nePBR_parallax' or 'nePBR' "
PROP_0 = pbrF0, $F0
PROP_1 = pbrAlbedoGain, $AlbedoGain
PROP_2 = pbrRoughnessExp, $RoughnessGamma
PROP_3 = pbrBlurCubemap, $BlurCubemap
PROP_4 = extParallaxScale, $ParallaxScale
PROP_5 = extParallaxSteps, $ParallaxSteps
PROP_6 = extParallaxOffset, $ParallaxOffset
PROP_7 = extDisplacementRangeBase, $" $DisplacementMin / ($DisplacementMax - $DisplacementMin) "
PROP_8 = extDisplacementRangeInv, $" -1 / ($DisplacementMax - $DisplacementMin) "
PROP_9 = ksEmissive, $Emissive
PROP_10 = pbrFlags, $" ( ${SkipAlbedoForEmissive:bool} and 1 or 0 )
  + ( ${ApplyAOMap:bool} and 2 or 0 )
  + ( ${ApplyVarianceMap:bool} and 4 or 0 )
  + ( ${ApplyTilingFix:bool} and 8 or 0 )
  + (( ${SpecularWorkflow:bool} or ${TextureSpecular:exists} ) and 16 or 0 )
  + ( ${TextureSpecular:exists} and 32 or 0 )
  + ( (${TextureNormal:2:str}):lower() == 'dxt5nm' and 64 or 0 )"
RESOURCE_0 = txAlbedo, $TextureAlbedo
RESOURCE_1 = txNormal2, ${TextureNormal:1}
RESOURCE_2 = txEmAoMeRo, $TextureEmAoMeRo
RESOURCE_3 = txDisplacement, $TextureDisplacement
RESOURCE_4 = txSpecular, $TextureSpecular
RESOURCE_5 = txVarianceAO, $TextureVarianceAO
