publicreadonlyGUIContentsyncButtonText=newGUIContent("Re-Synchronize Layers","Re-synchronize all layers's properties with the referenced Material");
publicreadonlyGUIContentsyncAllButtonText=newGUIContent("Re-Synchronize","Re-synchronize all layers material properties with the referenced Materials");
publicreadonlyGUIContentsyncAllButUVButtonText=newGUIContent("Re-Synchronize Without UV Mapping","Re-synchronize all but UV Mapping properties with the referenced Materials");
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0
publicstaticGUIContentmaterialIDText=newGUIContent("Material type","Subsurface Scattering: enable for translucent materials such as skin, vegetation, fruit, marble, wax and milk.");
publicstaticGUIContenthorizonFadeText=newGUIContent("Horizon Fade (Spec occlusion)","horizon fade is use to control specular occlusion");
// Per pixel displacement
publicstaticGUIContentenablePerPixelDisplacementText=newGUIContent("Enable Per Pixel Displacement","Per pixel displacement work best with flat surfaces. This is an expensive features and should be enable wisely. Typical use case is paved road.");
publicstaticGUIContentppdMinSamplesText=newGUIContent("Minimum steps","Minimum steps (texture sample) to use with per pixel displacement mapping");
protectedconststringkMaterialID="_MaterialID";
protectedconststringkStencilRef="_StencilRef";
protectedMaterialPropertyhorizonFade=null;
protectedconststringkHorizonFade="_HorizonFade";
// Wind
protectedMaterialPropertywindEnable=null;
// MaterialID
materialID=FindProperty(kMaterialID,props,false);// LayeredLit is force to be standard for now, so materialID could not exist
publicstaticGUIContentbentNormalMapText=newGUIContent("Bent normal map","Use only with indirect diffuse lighting (Lightmap/lightprobe) - Cosine weighted Bent Normal Map (average unoccluded direction) (BC7/BC5/DXT5(nm))");
publicstaticGUIContentbentNormalMapOSText=newGUIContent("Bent normal map OS","Use only with indirect diffuse lighting (Lightmap/lightprobe) - Bent Normal Map (BC7/DXT1/RGB)");
publicstaticGUIContentheightMapMinText=newGUIContent("Height Min","Minimum value in the heightmap (in world units)");
publicstaticGUIContentheightMapMaxText=newGUIContent("Height Max","Maximum value in the heightmap (in world units)");
publicstaticGUIContentheightMapMinText=newGUIContent("Height Min (cm)","Minimum value in the heightmap (in centimeters)");
publicstaticGUIContentheightMapMaxText=newGUIContent("Height Max (cm)","Maximum value in the heightmap (in centimeters)");
// indentation around base color is a workaround for a bug in material properties UI where the color picker is not indented properly and gets cropped (and unusable in layered shader UI)
// Remove when bug is fixed.
EditorGUI.indentLevel--;
EditorGUI.indentLevel++;
if(materialID==null||// Will be the case for Layered materials where we only support standard and the parameter does not exist
// UVSet0 is always set, planar and triplanar will override it.
floatX,Y,Z,W;
X=(uvBaseMapping==UVBaseMapping.UV0)?1.0f:0.0f;
Y=(uvBaseMapping==UVBaseMapping.UV1)?1.0f:0.0f;
UVMappingMask[layerIndex].colorValue=(layerIndex==0)?newColor(1.0f,0.0f,0.0f,0.0f):newColor(X,Y,Z,W);// Special case for Main Layer and Blend Mask, only UV0. As Layer0 is shared by both here, need to force X to 1.0 in all case
float4 opacityAsDensity = saturate((inputAlphaMask - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks.argb)) * 20.0); // 20.0 is the number of steps in inputAlphaMask (Density mask. We decided 20 empirically)
// Note: If per pixel displacement is enabled it mean we will fetch again the various heightmaps at the intersection location. Not sure the compiler can optimize.
// If any layer use a bent normal map, then bentNormalTS contain the interpolated result of bentnormal and normalmap (in case no bent normal are available)
// Note: the code in LitDataInternal ensure that we fallback on normal map for layer that have no bentnormal
// If there is no bent normal map provided, fallback on regular normal map
bentNormalTS = normalTS;
#endif
return bentNormalTS;
}
float ADD_IDX(GetSurfaceData)(FragInputs input, LayerTexCoord layerTexCoord, out SurfaceData surfaceData, out float3 normalTS)
float ADD_IDX(GetSurfaceData)(FragInputs input, LayerTexCoord layerTexCoord, out SurfaceData surfaceData, out float3 normalTS, out float3 bentNormalTS)
// This function convert the tangent space normal/tangent to world space and orthonormalize it + apply a correction of the normal if it is not pointing towards the near plane