// A shader for displaying artwork in high quality, as though it // were printed or painted onto a canvas. Shader "Silent/Filamented Extras/Painting Canvas" { Properties { _MainTex("Main Texture", 2D) = "white" {} [Space] [NoScaleOffset][Normal] _BumpMap("Canvas Pattern Normal", 2D) = "bump" {} _BumpSize("Pattern Scale", Float) = 1 _BumpScale("Pattern Intensity", Float) = 1 _BumpScaleWarp("Main Texture Canvas Intensity", Float) = 1 [Space] [NoScaleOffset]_MOESMap("Canvas MOES Map", 2D) = "white" {} _MetallicScale("Metallic", Range( 0 , 1)) = 0 _OcclusionScale("Occlusion", Range( 0 , 1)) = 0 _SmoothnessScale("Smoothness", Range( 0 , 1)) = 0 [Space] _Emission("Emission Power", Float) = 0 _EmissionColor("Emission Color", Color) = (1,1,1,1) [Space] [Header(System)] [Toggle(_LIGHTMAPSPECULAR)]_LightmapSpecular("Lightmap Specular", Range(0, 1)) = 1 _LightmapSpecularMaxSmoothness("Lightmap Specular Max Smoothness", Range(0, 1)) = 1 _ExposureOcclusion("Lightmap Occlusion Sensitivity", Range(0, 1)) = 0.2 [Space] [KeywordEnum(None, SH, RNM, MonoSH)] _Bakery ("Bakery Mode", Int) = 0 [HideInInspector]_RNM0("RNM0", 2D) = "black" {} [HideInInspector]_RNM1("RNM1", 2D) = "black" {} [HideInInspector]_RNM2("RNM2", 2D) = "black" {} [Toggle(_LTCGI)] _LTCGI ("LTCGI", Int) = 0 [Toggle(_VRCLV)] _VRCLV ("VRC Light Volumes", Int) = 0 [IfDef(_VRCLV)] _VRCLVSurfaceBias("Light Volume Surface Bias", Range(0, 0.5)) = 0.05 [Space] [Enum(UnityEngine.Rendering.CullMode)]_CullMode("Cull Mode", Int) = 2 [Toggle(_ALPHATEST_ON)]_AtoCmode("Cutout Transparency", Float) = 0 [NonModifiableTextureData][HideInInspector] _DFG("DFG", 2D) = "white" {} } CGINCLUDE // First, setup what Filamented does. // Filamented's behaviour is decided by the shading model and what material properties are defined. // These are listed in FilamentMaterialInputs. // You can set up and use anything in the initMaterials function. // SHADING_MODEL_SPECULAR_GLOSSINESS // If this is not defined, the material will default to metallic/roughness workflow. #define MATERIAL_HAS_NORMAL // If this is not defined, normal maps won't be enabled. #define MATERIAL_HAS_AMBIENT_OCCLUSION // If this is not defined, occlusion won't be taken into account #define MATERIAL_HAS_EMISSIVE // If this is not defined, emission won't be taken into account // MATERIAL_HAS_ANISOTROPY // If this is set, the material will support anisotropy. // MATERIAL_HAS_CLEAR_COAT // If this is set, the material will support clear coat. // HAS_ATTRIBUTE_COLOR // If this is not defined, vertex colour will not be available. #define USE_DFG_LUT // Whether to use the lookup texture for specular reflection calculation. // Requires a shader property _DFG to be present and filled. ENDCG CGINCLUDE #ifndef UNITY_PASS_SHADOWCASTER // Include common files. These will include the other files as needed. #include "Packages/s-ilent.filamented/Filamented/UnityLightingCommon.cginc" #include "Packages/s-ilent.filamented/Filamented/UnityStandardInput.cginc" #include "Packages/s-ilent.filamented/Filamented/UnityStandardConfig.cginc" #include "Packages/s-ilent.filamented/Filamented/UnityStandardCore.cginc" // Note: Unfortunately, Input is still needed due to some interdependancies with other Unity files. // This means that some properties will always be defined, even if they aren't used. // In practise, this won't affect the final compilation, but it means you'll need to watch out for the names // of some common parameters. In this case, only MOESMap and some other properties are defined here because // they are already defined in Input. // uniform sampler2D _MainTex; // uniform sampler2D _BumpMap; uniform sampler2D _MOESMap; // uniform half _BumpScale; uniform float4 _MainTex_TexelSize; uniform half _BumpSize; uniform half _BumpScaleWarp; uniform half _MetallicScale; uniform half _OcclusionScale; uniform half _SmoothnessScale; uniform half _Emission; // uniform half3 _EmissionColor; // Vertex functions are called from UnityStandardCore. // You can alter values here, or copy the function in and modify it. VertexOutputForwardBase vertBase (VertexInput v) { return vertForwardBase(v); } VertexOutputForwardAdd vertAdd (VertexInput v) { return vertForwardAdd(v); } float4 bicubicFilter(sampler2D inTex, float2 texcoord, float4 texscale) { //#if _BICUBIC texcoord *= texscale.zw; float fx = frac(texcoord.x); float fy = frac(texcoord.y); texcoord.x -= fx; texcoord.y -= fy; float4 xcubic = cubic(fx); float4 ycubic = cubic(fy); float4 c = float4(texcoord.x - 0.5, texcoord.x + 1.5, texcoord.y - 0.5, texcoord.y + 1.5); float4 s = float4(xcubic.x + xcubic.y, xcubic.z + xcubic.w, ycubic.x + ycubic.y, ycubic.z + ycubic.w); float4 offset = c + float4(xcubic.y, xcubic.w, ycubic.y, ycubic.w) / s; float4 sample0 = tex2D(inTex, float2(offset.x, offset.z) * texscale.xy); float4 sample1 = tex2D(inTex, float2(offset.y, offset.z) * texscale.xy); float4 sample2 = tex2D(inTex, float2(offset.x, offset.w) * texscale.xy); float4 sample3 = tex2D(inTex, float2(offset.y, offset.w) * texscale.xy); float sx = s.x / (s.x + s.y); float sy = s.z / (s.z + s.w); return lerp( lerp(sample3, sample2, sx), lerp(sample1, sample0, sx), sy); //#else return tex2D(inTex, texcoord); //#endif } // https://iquilezles.org/www/articles/biplanar/biplanar.htm // "p" point being textured // "n" surface normal at "p" // "k" controls the sharpness of the blending in the transitions areas // "s" texture sampler float4 biplanar( sampler2D sam, float3 p, float3 n, float k ) { // grab coord derivatives for texturing float3 dpdx = ddx(p); float3 dpdy = ddy(p); n = abs(n); // determine major axis (in x; yz are following axis) int3 ma = (n.x>n.y && n.x>n.z) ? int3(0,1,2) : (n.y>n.z) ? int3(1,2,0) : int3(2,0,1) ; // determine minor axis (in x; yz are following axis) int3 mi = (n.x