更新
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e79d6e47cd311f5458ae73d513c8d8d0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
half3 mTangentWS;
|
||||
half mTangentSign;
|
||||
half3 mBitangentWS;
|
||||
full3 mNormalWS;
|
||||
half3 mNormalVS;
|
||||
|
||||
half3 mTangentToWorld[3];
|
||||
|
||||
full3 TransformTangentToWorldDir(full3 normalTS)
|
||||
{
|
||||
full3 normalWS = 0;
|
||||
normalWS.x = dot(mTangentToWorld[0], normalTS);
|
||||
normalWS.y = dot(mTangentToWorld[1], normalTS);
|
||||
normalWS.z = dot(mTangentToWorld[2], normalTS);
|
||||
// After tangent space interpolation, axis lengths change slightly;
|
||||
// actual normalization is needed, otherwise highlight quality degrades significantly
|
||||
return normalize(normalWS);
|
||||
}
|
||||
|
||||
void SetupTBN()
|
||||
{
|
||||
mTangentWS = normalize(mVaryings.tangentWS.xyz);
|
||||
mTangentSign = mVaryings.tangentWS.w;
|
||||
mBitangentWS = normalize(mVaryings.bitangentWS);
|
||||
mNormalWS = normalize(mVaryings.normalWS);
|
||||
mNormalVS = TransformWorldToViewDir(mNormalWS);
|
||||
|
||||
mTangentToWorld[0] = half3(mTangentWS.x, mBitangentWS.x, mNormalWS.x);
|
||||
mTangentToWorld[1] = half3(mTangentWS.y, mBitangentWS.y, mNormalWS.y);
|
||||
mTangentToWorld[2] = half3(mTangentWS.z, mBitangentWS.z, mNormalWS.z);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb91a210b7841e34c806fba601d0c514
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Data/TBN.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
full4 mBaseUV;
|
||||
half mMipmapBias;
|
||||
|
||||
void SetupUV()
|
||||
{
|
||||
mMipmapBias = gGlobalMipmapBias - 1;
|
||||
mBaseUV = full4(mVaryings.uv.xy, 0, mMipmapBias);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cd9997854b875543a1658c223b65c66
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Data/UV.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
full3 mViewDirWS;
|
||||
full3 mViewDirTS;
|
||||
|
||||
half mNdotV;
|
||||
half mOneMinusNdotV;
|
||||
|
||||
void UpdateViewDataFromNormal()
|
||||
{
|
||||
mNdotV = saturate(dot(mNormalWS, mViewDirWS));
|
||||
mOneMinusNdotV = 1 - mNdotV;
|
||||
}
|
||||
|
||||
void SetupViewData()
|
||||
{
|
||||
// ViewDir
|
||||
// 1. Must normalize; otherwise, PBS has visual bugs
|
||||
// 2. Must calculate in fragment shader; otherwise highlight shapes on large triangles lack precision
|
||||
mViewDirWS = normalize(GetWorldSpaceViewDir(mVaryings.positionWS));
|
||||
mViewDirTS = GetViewDirectionTangentSpace(half4(mTangentWS, mTangentSign), mNormalWS, mViewDirWS);
|
||||
|
||||
UpdateViewDataFromNormal();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d15a247faf6ea54ba8c405877def80f
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Data/ViewData.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fc8d936bba60894d83354e30e1dcb3f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
half4 mBaseMapColor;
|
||||
half4 mAlbedoColor;
|
||||
half mAlpha;
|
||||
|
||||
void SetupBaseMap()
|
||||
{
|
||||
// The GL standard clearly states that the Alpha Source of sRGB should be linear, so hardware does not perform special processing on Alpha
|
||||
// Substance Source output depends on the format set for the corresponding value; color types default to sRGB, numeric types default to Linear, and opacity is a numeric type
|
||||
// Whether the final Alpha Source is linear depends on the artist's output, but the GPU assumes Alpha is linear and does not perform conversion
|
||||
// Therefore, no color space conversion is needed for Alpha here; whether in gamma or linear space, linear Alpha should be used
|
||||
mBaseMapColor = tex2Dbias(_BaseMap, mBaseUV);
|
||||
mBaseMapColor.xyz = TryGammaToLinear(mBaseMapColor.xyz);
|
||||
|
||||
mAlbedoColor = mBaseMapColor * _BaseColor;
|
||||
mAlpha = mAlbedoColor.a;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f46a81ea1abe16e4fac318ba0788360a
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Maps/BaseMap.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
// Used for scaling detail albedo. Main features:
|
||||
// - Depending if detailAlbedo brightens or darkens, scale magnifies effect.
|
||||
// - No effect is applied if detailAlbedo is 0.5.
|
||||
half3 ScaleDetailAlbedo(half3 detailAlbedo, half scale)
|
||||
{
|
||||
// detailAlbedo = detailAlbedo * 2.0h - 1.0h;
|
||||
// detailAlbedo *= _DetailAlbedoMapScale;
|
||||
// detailAlbedo = detailAlbedo * 0.5h + 0.5h;
|
||||
// return detailAlbedo * 2.0f;
|
||||
|
||||
// A bit more optimized
|
||||
return half(2.0) * detailAlbedo * scale - scale + half(1.0);
|
||||
}
|
||||
|
||||
void ApplyDetailAlbedo(full4 detailUV, half detailMask)
|
||||
{
|
||||
// Detail textures and secondary maps typically require uniform UVs, so uv.xy is insufficient and new UVs are needed
|
||||
half3 detailAlbedoColor = tex2Dbias(_DetailAlbedoMap, detailUV);
|
||||
detailAlbedoColor = TryGammaToLinear(detailAlbedoColor);
|
||||
detailAlbedoColor = ScaleDetailAlbedo(detailAlbedoColor, _DetailAlbedoMapScale);
|
||||
mAlbedoColor.rgb *= LerpWhiteTo(detailAlbedoColor, detailMask);
|
||||
}
|
||||
|
||||
void ApplyDetailNormal(full4 detailUV, half detailMask)
|
||||
{
|
||||
half4 detailBumpMapColor = tex2Dbias(_DetailNormalMap, detailUV);
|
||||
full3 detailNormalTS = UnpackNormalScale(detailBumpMapColor, _DetailNormalMapScale);
|
||||
// With UNITY_NO_DXT5nm unpacked vector is not normalized for BlendNormalRNM
|
||||
// For visual consistancy we going to do in all cases
|
||||
detailNormalTS = normalize(detailNormalTS);
|
||||
full3 blendNormalTS = BlendNormalRNM(mNormalTS, detailNormalTS);
|
||||
// todo: detailMask should lerp the angle of the quaternion rotation, not the normals
|
||||
full3 finalNormalTS = lerp(mNormalTS, blendNormalTS, detailMask);
|
||||
SetNormalTS_Detail(finalNormalTS);
|
||||
}
|
||||
|
||||
void SetupDetailMap()
|
||||
{
|
||||
#if _DETAIL_ON
|
||||
{
|
||||
half detailMask = GetMaskValue(_DetailMaskSrc);
|
||||
|
||||
#if SCENE_OBJ
|
||||
{
|
||||
half heightBegin = _DetailParams.x - _DetailParams.y;
|
||||
half heightEnd = _DetailParams.x + _DetailParams.y;
|
||||
half3 privotPositionWS = mul(UNITY_MATRIX_M, half4(0, 0, 0, 1)).xyz;
|
||||
half rotatedHeightOS = (mVaryings.positionWS - privotPositionWS).y;
|
||||
half heightPercent = smoothstep(heightBegin, heightEnd, rotatedHeightOS);
|
||||
half angleBegin = _DetailParams.z - _DetailParams.w;
|
||||
half angleEnd = _DetailParams.z + _DetailParams.w;
|
||||
half anglePercent = smoothstep(angleBegin, angleEnd, dot(mNormalWS, half3(0, 1, 0)));
|
||||
detailMask *= heightPercent * anglePercent;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Detail textures and secondary maps typically require uniform UVs, so uv.xy is insufficient and new UVs are needed
|
||||
full4 detailUV = full4(mVaryings.uv.zw, 0, mMipmapBias);
|
||||
|
||||
// half4 detailMapColor = tex2Dbias(_DetailAlbedoMap, detailUV);
|
||||
// detailMapColor.rgb = TryGammaToLinear(detailMapColor);
|
||||
// half4 detailAlbedoColor = detailMapColor * _DetailColor;
|
||||
// half detailAlpha = detailAlbedoColor.a * detailMask;
|
||||
// mAlbedoColor.rgb = mAlbedoColor * (1 - detailAlpha) + detailAlbedoColor * detailAlpha;
|
||||
|
||||
ApplyDetailAlbedo(detailUV, detailMask);
|
||||
ApplyDetailNormal(detailUV, detailMask);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b67acb4579b767646bc4d5a6d5cb58fd
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Maps/DetailMap.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
half4 mHeightMapColor;
|
||||
|
||||
void SetupHeightMap()
|
||||
{
|
||||
#if _PARALLAXMAP
|
||||
{
|
||||
mHeightMapColor = tex2Dbias(_ParallaxMap, mBaseUV);
|
||||
mBaseUV.xy += ParallaxOffset1Step(mHeightMapColor, _ParallaxScale, mViewDirTS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fafe4b1dda166464cb06fe27e15c25e8
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Maps/HeightMap.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
half4 mBaseMaskColor;
|
||||
half4 mExtraMaskColor;
|
||||
half mMaskValues[9];
|
||||
|
||||
void SetupMaskMap()
|
||||
{
|
||||
mBaseMaskColor = tex2Dbias(_BaseMaskMap, mBaseUV);
|
||||
mExtraMaskColor = tex2Dbias(_ExtraMaskMap, mBaseUV);
|
||||
|
||||
mMaskValues[0] = 1;
|
||||
mMaskValues[1] = mBaseMaskColor.r;
|
||||
mMaskValues[2] = mBaseMaskColor.g;
|
||||
mMaskValues[3] = mBaseMaskColor.b;
|
||||
mMaskValues[4] = mBaseMaskColor.a;
|
||||
mMaskValues[5] = mExtraMaskColor.r;
|
||||
mMaskValues[6] = mExtraMaskColor.g;
|
||||
mMaskValues[7] = mExtraMaskColor.b;
|
||||
mMaskValues[8] = mExtraMaskColor.a;
|
||||
}
|
||||
|
||||
half GetMaskValue(int index)
|
||||
{
|
||||
return mMaskValues[index];
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba3674259fd6dc449993097efd67d1c8
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Maps/MaskMap.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
full3 mBaseNormalTS;
|
||||
full3 mNormalTS;
|
||||
|
||||
void PostUpdateNormalTS()
|
||||
{
|
||||
mNormalWS = TransformTangentToWorldDir(mNormalTS);
|
||||
mTangentWS = normalize(mTangentWS - mNormalWS * dot(mTangentWS, mNormalWS));
|
||||
mBitangentWS = cross(mNormalWS, mTangentWS) * mTangentSign;
|
||||
|
||||
mNormalVS = TransformWorldToViewDir(mNormalWS);
|
||||
}
|
||||
|
||||
void SetNormalTS_Base(full3 normalTS)
|
||||
{
|
||||
#if _NORMALMAP
|
||||
{
|
||||
mNormalTS = normalTS;
|
||||
PostUpdateNormalTS();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetNormalTS_Detail(full3 normalTS)
|
||||
{
|
||||
#if _DETAIL_ON
|
||||
{
|
||||
mNormalTS = normalTS;
|
||||
PostUpdateNormalTS();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetupNormalMap()
|
||||
{
|
||||
mNormalTS = half3(0, 1, 0);
|
||||
|
||||
half4 bumpMapColor = tex2Dbias(_BumpMap, mBaseUV);
|
||||
mBaseNormalTS = UnpackNormalScale(bumpMapColor, _BumpScale);
|
||||
SetNormalTS_Base(mBaseNormalTS);
|
||||
}
|
||||
|
||||
half3 CalcuateDebugNormalMapColor()
|
||||
{
|
||||
half3 debugNormalMapColor = 0.5 * (mBaseNormalTS + 1);
|
||||
debugNormalMapColor.rgb *= debugNormalMapColor.rgb;
|
||||
return debugNormalMapColor;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0e7adb2d7871164c82e9263f49fcc1f
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Surface/Maps/NormalMap.hlsl
|
||||
uploadId: 820558
|
||||
Reference in New Issue
Block a user