从旧版中移植,Prefab未确认
This commit is contained in:
@@ -0,0 +1,270 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-2090386079456462257
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 12
|
||||
hdPluginSubTargetMaterialVersions:
|
||||
m_Keys: []
|
||||
m_Values:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Grid2DFull DoublePanel-XZ
|
||||
m_Shader: {fileID: 4800000, guid: 37e7e81471ec9d14198517da0d17fd45, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _DISABLE_SSR_TRANSPARENT
|
||||
- _NORMALMAP_TANGENT_SPACE
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses:
|
||||
- TransparentDepthPrepass
|
||||
- TransparentDepthPostpass
|
||||
- TransparentBackface
|
||||
- RayTracingPrepass
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AnisotropyMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BaseColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BentNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BentNormalMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _CoatMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissiveColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _HeightMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _IridescenceMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _IridescenceThicknessMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecularColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SubsurfaceMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TangentMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TangentMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ThicknessMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TransmittanceColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AORemapMax: 1
|
||||
- _AORemapMin: 0
|
||||
- _ATDistance: 1
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlbedoAffectEmissive: 0
|
||||
- _AlphaCutoff: 0.5
|
||||
- _AlphaCutoffEnable: 0
|
||||
- _AlphaCutoffPostpass: 0.5
|
||||
- _AlphaCutoffPrepass: 0.5
|
||||
- _AlphaCutoffShadow: 0.5
|
||||
- _AlphaDstBlend: 0
|
||||
- _AlphaSrcBlend: 1
|
||||
- _AlphaToMask: 0
|
||||
- _AlphaToMaskInspectorValue: 0
|
||||
- _Anisotropy: 0
|
||||
- _BlendMode: 0
|
||||
- _CoatMask: 0
|
||||
- _CullMode: 2
|
||||
- _CullModeForward: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DepthOffsetEnable: 0
|
||||
- _DetailAlbedoScale: 1
|
||||
- _DetailNormalScale: 1
|
||||
- _DetailSmoothnessScale: 1
|
||||
- _DiffusionProfile: 0
|
||||
- _DiffusionProfileHash: 0
|
||||
- _DisplacementLockObjectScale: 1
|
||||
- _DisplacementLockTilingScale: 1
|
||||
- _DisplacementMode: 0
|
||||
- _DoubleSidedEnable: 0
|
||||
- _DoubleSidedGIMode: 0
|
||||
- _DoubleSidedNormalMode: 1
|
||||
- _DstBlend: 0
|
||||
- _EmissiveColorMode: 1
|
||||
- _EmissiveExposureWeight: 1
|
||||
- _EmissiveIntensity: 1
|
||||
- _EmissiveIntensityUnit: 0
|
||||
- _EnableBlendModePreserveSpecularLighting: 1
|
||||
- _EnableFogOnTransparent: 1
|
||||
- _EnableGeometricSpecularAA: 0
|
||||
- _EnergyConservingSpecularColor: 1
|
||||
- _HeightAmplitude: 0.02
|
||||
- _HeightCenter: 0.5
|
||||
- _HeightMapParametrization: 0
|
||||
- _HeightMax: 1
|
||||
- _HeightMin: -1
|
||||
- _HeightOffset: 0
|
||||
- _HeightPoMAmplitude: 2
|
||||
- _HeightTessAmplitude: 2
|
||||
- _HeightTessCenter: 0.5
|
||||
- _InvTilingScale: 1
|
||||
- _Ior: 1.5
|
||||
- _IridescenceMask: 1
|
||||
- _IridescenceThickness: 1
|
||||
- _LinkDetailsWithBase: 1
|
||||
- _MaterialID: 1
|
||||
- _Metallic: 0
|
||||
- _MetallicRemapMax: 0
|
||||
- _MetallicRemapMin: 0
|
||||
- _NormalMapSpace: 0
|
||||
- _NormalScale: 1
|
||||
- _OpaqueCullMode: 2
|
||||
- _PPDLodThreshold: 5
|
||||
- _PPDMaxSamples: 15
|
||||
- _PPDMinSamples: 5
|
||||
- _PPDPrimitiveLength: 1
|
||||
- _PPDPrimitiveWidth: 1
|
||||
- _PlaneLevel: -0.05
|
||||
- _RayTracing: 0
|
||||
- _ReceivesSSR: 1
|
||||
- _ReceivesSSRTransparent: 0
|
||||
- _RefractionModel: 0
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessRemapMax: 1
|
||||
- _SmoothnessRemapMin: 0
|
||||
- _SpecularAAScreenSpaceVariance: 0.1
|
||||
- _SpecularAAThreshold: 0.2
|
||||
- _SpecularOcclusionMode: 1
|
||||
- _SrcBlend: 1
|
||||
- _StencilRef: 0
|
||||
- _StencilRefDepth: 8
|
||||
- _StencilRefGBuffer: 10
|
||||
- _StencilRefMV: 40
|
||||
- _StencilWriteMask: 6
|
||||
- _StencilWriteMaskDepth: 8
|
||||
- _StencilWriteMaskGBuffer: 14
|
||||
- _StencilWriteMaskMV: 40
|
||||
- _SubsurfaceMask: 1
|
||||
- _SupportDecals: 1
|
||||
- _SurfaceType: 0
|
||||
- _TexWorldScale: 1
|
||||
- _TexWorldScaleEmissive: 1
|
||||
- _Thickness: 1
|
||||
- _TransmissionEnable: 1
|
||||
- _TransparentBackfaceEnable: 0
|
||||
- _TransparentCullMode: 2
|
||||
- _TransparentDepthPostpassEnable: 0
|
||||
- _TransparentDepthPrepassEnable: 0
|
||||
- _TransparentSortPriority: 0
|
||||
- _TransparentWritingMotionVec: 0
|
||||
- _TransparentZWrite: 0
|
||||
- _UVBase: 0
|
||||
- _UVDetail: 0
|
||||
- _UVEmissive: 0
|
||||
- _UseEmissiveIntensity: 0
|
||||
- _UseShadowThreshold: 0
|
||||
- _ZTestDepthEqualForOpaque: 3
|
||||
- _ZTestGBuffer: 4
|
||||
- _ZTestTransparent: 4
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
|
||||
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
|
||||
- _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
|
||||
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
|
||||
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0}
|
||||
m_BuildTextureStacks: []
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b83f491038a41a4a9a0d1aff43a69a4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,108 @@
|
||||
Shader "GridFull/infTutorialDouble"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_PlaneLevel("High",float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags{
|
||||
"RenderPipeline"="UniversalRenderPipeline"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"Queue"="Transparent"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull off
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
//float _PlaneLevel;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
struct Varings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 nearPoint : TEXCOORD0;
|
||||
float3 farPoint : TEXCOORD1;
|
||||
};
|
||||
float3 TransformHClipToWorld(float3 positionCS, float4x4 inv_VP)
|
||||
{
|
||||
float4 unprojectedPoint = mul(inv_VP, float4(positionCS, 1.0));
|
||||
return unprojectedPoint.xyz / unprojectedPoint.w;
|
||||
}
|
||||
Varings vert(Attributes input)
|
||||
{
|
||||
//此shader专用于quad mesh
|
||||
//所以使用4个顶点的uv值进行变换 作为 裁切空间的坐标
|
||||
//保证这是一个覆盖全屏幕的渲染
|
||||
Varings o;
|
||||
float2 uv = input.uv * 2.0 - 1.0;
|
||||
//默认情况下,Zndc = 1是远平面
|
||||
half farPlane = 1;
|
||||
half nearPlane = 0;
|
||||
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
//有时候会反转z
|
||||
farPlane = 1 - farPlane;
|
||||
nearPlane = 1 - nearPlane;
|
||||
#endif
|
||||
|
||||
float4 position = float4(uv, farPlane, 1);
|
||||
float3 nearPoint = TransformHClipToWorld(float3(position.xy, nearPlane), UNITY_MATRIX_I_VP);
|
||||
float3 farPoint = TransformHClipToWorld(float3(position.xy, farPlane), UNITY_MATRIX_I_VP);
|
||||
o.positionCS = position;
|
||||
o.nearPoint = nearPoint;
|
||||
o.farPoint = farPoint;
|
||||
return o;
|
||||
}
|
||||
float computeViewZ(float3 pos) {
|
||||
float4 clip_space_pos = mul(UNITY_MATRIX_VP, float4(pos.xyz, 1.0));
|
||||
float viewZ = clip_space_pos.w; //根据projection矩阵定义,positionCS.w = viewZ
|
||||
return viewZ;
|
||||
}
|
||||
half Grid(float2 uv){
|
||||
float2 derivative = fwidth(uv);
|
||||
uv = frac(uv - 0.5); //中心对齐
|
||||
uv = abs(uv - 0.5);
|
||||
uv = uv / derivative;
|
||||
float min_value = min(uv.x, uv.y);
|
||||
half grid = 1.0 - min(min_value, 1.0);
|
||||
return grid;
|
||||
}
|
||||
half4 frag(Varings input) : SV_TARGET{
|
||||
//计算地平面
|
||||
float t = -input.nearPoint.y / (input.farPoint.y - input.nearPoint.y);
|
||||
//float3 positionWS = input.nearPoint + t * (input.farPoint - input.nearPoint);
|
||||
//half ground = step(_PlaneLevel, t);
|
||||
float3 positionWS = input.nearPoint + t * (input.farPoint - input.nearPoint);
|
||||
half ground = step(-0.05, t);
|
||||
|
||||
float3 cameraPos = _WorldSpaceCameraPos;
|
||||
float fromOrigin = abs(cameraPos.y);
|
||||
|
||||
float viewZ = computeViewZ(positionWS);
|
||||
float2 uv = positionWS.xz;
|
||||
//计算grid
|
||||
float fading = max(0.0, 1.0 - viewZ / 150);
|
||||
half smallGrid = Grid(uv) * lerp(1, 0, min(1.0, fromOrigin / 100));
|
||||
half middleGrid = Grid(uv * 0.1) * lerp(1, 0, min(1.0, fromOrigin / 300));
|
||||
half largeGrid = Grid(uv * 0.01) * lerp(1, 0, min(1.0, fromOrigin / 800));
|
||||
|
||||
//合并计算
|
||||
half grid = smallGrid + middleGrid + largeGrid;
|
||||
return half4(0.5, 0.5, 0.5 ,ground * grid * fading * 0.5); //顺便改色减淡一下
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37e7e81471ec9d14198517da0d17fd45
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
99
Convention/[Art]/GridFull/Grid2DFull/Grid2DFull-XY.shader
Normal file
99
Convention/[Art]/GridFull/Grid2DFull/Grid2DFull-XY.shader
Normal file
@@ -0,0 +1,99 @@
|
||||
Shader "GridFull/2DFull"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_ColorLevel("Color Level",Range(0,1)) =1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags{
|
||||
"RenderPipeline"="UniversalRenderPipeline"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"Queue"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull off
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
half _ColorLevel;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
struct Varings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 nearPoint : TEXCOORD0;
|
||||
float3 farPoint : TEXCOORD1;
|
||||
};
|
||||
float3 TransformHClipToWorld(float3 positionCS, float4x4 inv_VP)
|
||||
{
|
||||
float4 unprojectedPoint = mul(inv_VP, float4(positionCS, 1.0));
|
||||
return unprojectedPoint.xyz / unprojectedPoint.w;
|
||||
}
|
||||
Varings vert(Attributes input)
|
||||
{
|
||||
Varings o;
|
||||
float2 uv = input.uv * 2.0 - 1.0;
|
||||
half farPlane = 1;
|
||||
half nearPlane = 0;
|
||||
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
farPlane = 1 - farPlane;
|
||||
nearPlane = 1 - nearPlane;
|
||||
#endif
|
||||
|
||||
float4 position = float4(uv, farPlane, 1);
|
||||
float3 nearPoint = TransformHClipToWorld(float3(position.xy, nearPlane), UNITY_MATRIX_I_VP);
|
||||
float3 farPoint = TransformHClipToWorld(float3(position.xy, farPlane), UNITY_MATRIX_I_VP);
|
||||
o.positionCS = position;
|
||||
o.nearPoint = nearPoint;
|
||||
o.farPoint = farPoint;
|
||||
return o;
|
||||
}
|
||||
float computeViewZ(float3 pos) {
|
||||
float4 clip_space_pos = mul(UNITY_MATRIX_VP, float4(pos.xyz, 1.0));
|
||||
float viewZ = clip_space_pos.w;
|
||||
return viewZ;
|
||||
}
|
||||
half Grid(float2 uv){
|
||||
float2 derivative = fwidth(uv);
|
||||
uv = frac(uv - 0.5);
|
||||
uv = abs(uv - 0.5);
|
||||
uv = uv / derivative;
|
||||
float min_value = min(uv.x, uv.y);
|
||||
half grid = 1.0 - min(min_value, 1.0);
|
||||
return grid;
|
||||
}
|
||||
half4 frag(Varings input) : SV_TARGET{
|
||||
float t = -input.nearPoint.z / (input.farPoint.z - input.nearPoint.z);
|
||||
float3 positionWS = input.nearPoint + t * (input.farPoint - input.nearPoint);
|
||||
half ground = step(0, t);
|
||||
|
||||
float3 cameraPos = _WorldSpaceCameraPos;
|
||||
float fromOrigin = abs(cameraPos.z);
|
||||
|
||||
float viewZ = computeViewZ(positionWS);
|
||||
float2 uv = positionWS.xy;
|
||||
float fading = max(0.0, 1.0 - viewZ / 150);
|
||||
half smallGrid = Grid(uv) * lerp(1, 0, min(1.0, fromOrigin / 100));
|
||||
half middleGrid = Grid(uv * 0.1) * lerp(1, 0, min(1.0, fromOrigin / 300));
|
||||
half largeGrid = Grid(uv * 0.01) * lerp(1, 0, min(1.0, fromOrigin / 800));
|
||||
|
||||
half grid = smallGrid + middleGrid + largeGrid;
|
||||
return half4(0.5, 0.5, 0.5 ,ground * grid * fading * 0.5 * _ColorLevel);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c172eb9b2d40f564a955c20e1b05f365
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
271
Convention/[Art]/GridFull/Grid2DFull/Grid2DFull-XZ.mat
Normal file
271
Convention/[Art]/GridFull/Grid2DFull/Grid2DFull-XZ.mat
Normal file
@@ -0,0 +1,271 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Grid2DFull-XZ
|
||||
m_Shader: {fileID: 4800000, guid: 080d6d6029e2c884bb79b02882433133, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _DISABLE_SSR_TRANSPARENT
|
||||
- _NORMALMAP_TANGENT_SPACE
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses:
|
||||
- TransparentDepthPrepass
|
||||
- TransparentDepthPostpass
|
||||
- TransparentBackface
|
||||
- RayTracingPrepass
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AnisotropyMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BaseColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BentNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BentNormalMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _CoatMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissiveColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _HeightMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _IridescenceMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _IridescenceThicknessMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecularColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SubsurfaceMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TangentMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TangentMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ThicknessMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TransmittanceColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AORemapMax: 1
|
||||
- _AORemapMin: 0
|
||||
- _ATDistance: 1
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlbedoAffectEmissive: 0
|
||||
- _AlphaCutoff: 0.5
|
||||
- _AlphaCutoffEnable: 0
|
||||
- _AlphaCutoffPostpass: 0.5
|
||||
- _AlphaCutoffPrepass: 0.5
|
||||
- _AlphaCutoffShadow: 0.5
|
||||
- _AlphaDstBlend: 0
|
||||
- _AlphaSrcBlend: 1
|
||||
- _AlphaToMask: 0
|
||||
- _AlphaToMaskInspectorValue: 0
|
||||
- _Anisotropy: 0
|
||||
- _BlendMode: 0
|
||||
- _CoatMask: 0
|
||||
- _ColorLevel: 1
|
||||
- _CullMode: 2
|
||||
- _CullModeForward: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DepthOffsetEnable: 0
|
||||
- _DetailAlbedoScale: 1
|
||||
- _DetailNormalScale: 1
|
||||
- _DetailSmoothnessScale: 1
|
||||
- _DiffusionProfile: 0
|
||||
- _DiffusionProfileHash: 0
|
||||
- _DisplacementLockObjectScale: 1
|
||||
- _DisplacementLockTilingScale: 1
|
||||
- _DisplacementMode: 0
|
||||
- _DoubleSidedEnable: 0
|
||||
- _DoubleSidedGIMode: 0
|
||||
- _DoubleSidedNormalMode: 1
|
||||
- _DstBlend: 0
|
||||
- _EmissiveColorMode: 1
|
||||
- _EmissiveExposureWeight: 1
|
||||
- _EmissiveIntensity: 1
|
||||
- _EmissiveIntensityUnit: 0
|
||||
- _EnableBlendModePreserveSpecularLighting: 1
|
||||
- _EnableFogOnTransparent: 1
|
||||
- _EnableGeometricSpecularAA: 0
|
||||
- _EnergyConservingSpecularColor: 1
|
||||
- _HeightAmplitude: 0.02
|
||||
- _HeightCenter: 0.5
|
||||
- _HeightMapParametrization: 0
|
||||
- _HeightMax: 1
|
||||
- _HeightMin: -1
|
||||
- _HeightOffset: 0
|
||||
- _HeightPoMAmplitude: 2
|
||||
- _HeightTessAmplitude: 2
|
||||
- _HeightTessCenter: 0.5
|
||||
- _InvTilingScale: 1
|
||||
- _Ior: 1.5
|
||||
- _IridescenceMask: 1
|
||||
- _IridescenceThickness: 1
|
||||
- _LinkDetailsWithBase: 1
|
||||
- _MaterialID: 1
|
||||
- _Metallic: 0
|
||||
- _MetallicRemapMax: 0
|
||||
- _MetallicRemapMin: 0
|
||||
- _NormalMapSpace: 0
|
||||
- _NormalScale: 1
|
||||
- _OpaqueCullMode: 2
|
||||
- _PPDLodThreshold: 5
|
||||
- _PPDMaxSamples: 15
|
||||
- _PPDMinSamples: 5
|
||||
- _PPDPrimitiveLength: 1
|
||||
- _PPDPrimitiveWidth: 1
|
||||
- _PlaneLevel: -0.05
|
||||
- _RayTracing: 0
|
||||
- _ReceivesSSR: 1
|
||||
- _ReceivesSSRTransparent: 0
|
||||
- _RefractionModel: 0
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessRemapMax: 1
|
||||
- _SmoothnessRemapMin: 0
|
||||
- _SpecularAAScreenSpaceVariance: 0.1
|
||||
- _SpecularAAThreshold: 0.2
|
||||
- _SpecularOcclusionMode: 1
|
||||
- _SrcBlend: 1
|
||||
- _StencilRef: 0
|
||||
- _StencilRefDepth: 8
|
||||
- _StencilRefGBuffer: 10
|
||||
- _StencilRefMV: 40
|
||||
- _StencilWriteMask: 6
|
||||
- _StencilWriteMaskDepth: 8
|
||||
- _StencilWriteMaskGBuffer: 14
|
||||
- _StencilWriteMaskMV: 40
|
||||
- _SubsurfaceMask: 1
|
||||
- _SupportDecals: 1
|
||||
- _SurfaceType: 0
|
||||
- _TexWorldScale: 1
|
||||
- _TexWorldScaleEmissive: 1
|
||||
- _Thickness: 1
|
||||
- _TransmissionEnable: 1
|
||||
- _TransparentBackfaceEnable: 0
|
||||
- _TransparentCullMode: 2
|
||||
- _TransparentDepthPostpassEnable: 0
|
||||
- _TransparentDepthPrepassEnable: 0
|
||||
- _TransparentSortPriority: 0
|
||||
- _TransparentWritingMotionVec: 0
|
||||
- _TransparentZWrite: 0
|
||||
- _UVBase: 0
|
||||
- _UVDetail: 0
|
||||
- _UVEmissive: 0
|
||||
- _UseEmissiveIntensity: 0
|
||||
- _UseShadowThreshold: 0
|
||||
- _ZTestDepthEqualForOpaque: 3
|
||||
- _ZTestGBuffer: 4
|
||||
- _ZTestTransparent: 4
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
|
||||
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
|
||||
- _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
|
||||
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
|
||||
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &5027933924106573666
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 12
|
||||
hdPluginSubTargetMaterialVersions:
|
||||
m_Keys: []
|
||||
m_Values:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e0f5baad6aeed745b241ed0b15f1ae7
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
108
Convention/[Art]/GridFull/Grid2DFull/Grid2DFull-XZ.shader
Normal file
108
Convention/[Art]/GridFull/Grid2DFull/Grid2DFull-XZ.shader
Normal file
@@ -0,0 +1,108 @@
|
||||
Shader "GridFull/infTutorial"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_ColorLevel("Color Level",Range(0,1)) =1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags{
|
||||
"RenderPipeline"="UniversalRenderPipeline"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"Queue"="Transparent"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull off
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
half _ColorLevel;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
struct Varings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 nearPoint : TEXCOORD0;
|
||||
float3 farPoint : TEXCOORD1;
|
||||
};
|
||||
float3 TransformHClipToWorld(float3 positionCS, float4x4 inv_VP)
|
||||
{
|
||||
float4 unprojectedPoint = mul(inv_VP, float4(positionCS, 1.0));
|
||||
return unprojectedPoint.xyz / unprojectedPoint.w;
|
||||
}
|
||||
Varings vert(Attributes input)
|
||||
{
|
||||
//此shader专用于quad mesh
|
||||
//所以使用4个顶点的uv值进行变换 作为 裁切空间的坐标
|
||||
//保证这是一个覆盖全屏幕的渲染
|
||||
Varings o;
|
||||
float2 uv = input.uv * 2.0 - 1.0;
|
||||
//默认情况下,Zndc = 1是远平面
|
||||
half farPlane = 1;
|
||||
half nearPlane = 0;
|
||||
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
//有时候会反转z
|
||||
farPlane = 1 - farPlane;
|
||||
nearPlane = 1 - nearPlane;
|
||||
#endif
|
||||
|
||||
float4 position = float4(uv, farPlane, 1);
|
||||
float3 nearPoint = TransformHClipToWorld(float3(position.xy, nearPlane), UNITY_MATRIX_I_VP);
|
||||
float3 farPoint = TransformHClipToWorld(float3(position.xy, farPlane), UNITY_MATRIX_I_VP);
|
||||
o.positionCS = position;
|
||||
o.nearPoint = nearPoint;
|
||||
o.farPoint = farPoint;
|
||||
return o;
|
||||
}
|
||||
float computeViewZ(float3 pos) {
|
||||
float4 clip_space_pos = mul(UNITY_MATRIX_VP, float4(pos.xyz, 1.0));
|
||||
float viewZ = clip_space_pos.w; //根据projection矩阵定义,positionCS.w = viewZ
|
||||
return viewZ;
|
||||
}
|
||||
half Grid(float2 uv){
|
||||
float2 derivative = fwidth(uv);
|
||||
uv = frac(uv - 0.5); //中心对齐
|
||||
uv = abs(uv - 0.5);
|
||||
uv = uv / derivative;
|
||||
float min_value = min(uv.x, uv.y);
|
||||
half grid = 1.0 - min(min_value, 1.0);
|
||||
return grid;
|
||||
}
|
||||
half4 frag(Varings input) : SV_TARGET{
|
||||
//计算地平面
|
||||
float t = -input.nearPoint.y / (input.farPoint.y - input.nearPoint.y);
|
||||
//float3 positionWS = input.nearPoint + t * (input.farPoint - input.nearPoint);
|
||||
//half ground = step(_PlaneLevel, t);
|
||||
float3 positionWS = input.nearPoint + t * (input.farPoint - input.nearPoint);
|
||||
half ground = step(0, t);
|
||||
|
||||
float3 cameraPos = _WorldSpaceCameraPos;
|
||||
float fromOrigin = abs(cameraPos.y);
|
||||
|
||||
float viewZ = computeViewZ(positionWS);
|
||||
float2 uv = positionWS.xz;
|
||||
//计算grid
|
||||
float fading = max(0.0, 1.0 - viewZ / 150);
|
||||
half smallGrid = Grid(uv) * lerp(1, 0, min(1.0, fromOrigin / 100));
|
||||
half middleGrid = Grid(uv * 0.1) * lerp(1, 0, min(1.0, fromOrigin / 300));
|
||||
half largeGrid = Grid(uv * 0.01) * lerp(1, 0, min(1.0, fromOrigin / 800));
|
||||
|
||||
//合并计算
|
||||
half grid = smallGrid + middleGrid + largeGrid;
|
||||
return half4(0.5, 0.5, 0.5 ,ground * grid * fading * 0.5 * _ColorLevel); //顺便改色减淡一下
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 080d6d6029e2c884bb79b02882433133
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Convention/[Art]/GridFull/Grid2DFull/GridSpriteFull-XY.mat
Normal file
32
Convention/[Art]/GridFull/Grid2DFull/GridSpriteFull-XY.mat
Normal file
@@ -0,0 +1,32 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GridSpriteFull-XY
|
||||
m_Shader: {fileID: 4800000, guid: 099ea33a7b313e343aec7a115569eb79, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 2750
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _ColorLevel: 1
|
||||
- _GridScale: 1
|
||||
m_Colors:
|
||||
- _Offset: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_BuildTextureStacks: []
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9620d68e03db6c845ab23c22bac32d9a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
108
Convention/[Art]/GridFull/Grid2DFull/GridSpriteFull-XY.shader
Normal file
108
Convention/[Art]/GridFull/Grid2DFull/GridSpriteFull-XY.shader
Normal file
@@ -0,0 +1,108 @@
|
||||
Shader "GridFull/infTutorial"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_ColorLevel("Color Level",Range(0,1)) = 1
|
||||
_Offset("Position Offset", Vector) = (0,0,0,0)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags{
|
||||
"RenderPipeline"="UniversalRenderPipeline"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"Queue"="Transparent"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull off
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
half _ColorLevel;
|
||||
float2 _Offset;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
struct Varings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 nearPoint : TEXCOORD0;
|
||||
float3 farPoint : TEXCOORD1;
|
||||
};
|
||||
float3 TransformHClipToWorld(float3 positionCS, float4x4 inv_VP)
|
||||
{
|
||||
float4 unprojectedPoint = mul(inv_VP, float4(positionCS, 1.0));
|
||||
return unprojectedPoint.xyz / unprojectedPoint.w;
|
||||
}
|
||||
Varings vert(Attributes input)
|
||||
{
|
||||
//此shader专用于quad mesh
|
||||
//所以使用4个顶点的uv值进行变换 作为 裁切空间的坐标
|
||||
//保证这是一个覆盖全屏幕的渲染
|
||||
Varings o;
|
||||
float2 uv = input.uv * 2.0 - 1.0;
|
||||
//默认情况下,Zndc = 1是远平面
|
||||
half farPlane = 1;
|
||||
half nearPlane = 0;
|
||||
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
//有时候会反转z
|
||||
farPlane = 1 - farPlane;
|
||||
nearPlane = 1 - nearPlane;
|
||||
#endif
|
||||
|
||||
float4 position = float4(uv, farPlane, 1);
|
||||
float3 nearPoint = TransformHClipToWorld(float3(position.xy, nearPlane), UNITY_MATRIX_I_VP);
|
||||
float3 farPoint = TransformHClipToWorld(float3(position.xy, farPlane), UNITY_MATRIX_I_VP);
|
||||
o.positionCS = position;
|
||||
o.nearPoint = nearPoint;
|
||||
o.farPoint = farPoint;
|
||||
return o;
|
||||
}
|
||||
float computeViewZ(float3 pos) {
|
||||
float4 clip_space_pos = mul(UNITY_MATRIX_VP, float4(pos.xyz, 1.0));
|
||||
float viewZ = clip_space_pos.w; //根据projection矩阵定义,positionCS.w = viewZ
|
||||
return viewZ;
|
||||
}
|
||||
half Grid(float2 uv){
|
||||
float2 derivative = fwidth(uv);
|
||||
uv = frac(uv - 0.5); //中心对齐
|
||||
uv = abs(uv - 0.5);
|
||||
uv = uv / derivative;
|
||||
float min_value = min(uv.x, uv.y);
|
||||
half grid = 1.0 - min(min_value, 1.0);
|
||||
return grid;
|
||||
}
|
||||
half4 frag(Varings input) : SV_TARGET{
|
||||
//计算地平面
|
||||
float t = -input.nearPoint.z / (input.farPoint.z - input.nearPoint.z);
|
||||
float3 positionWS = input.nearPoint + t * (input.farPoint - input.nearPoint);
|
||||
half ground = step(0, t);
|
||||
|
||||
float3 cameraPos = _WorldSpaceCameraPos;
|
||||
float fromOrigin = abs(cameraPos.z);
|
||||
|
||||
float viewZ = computeViewZ(positionWS);
|
||||
float2 uv = positionWS.xy - _Offset;//mul(unity_ObjectToWorld , float4(0,0,0,1)).xy;
|
||||
//计算grid
|
||||
float fading = max(0.0, 1.0 - viewZ / 150);
|
||||
half smallGrid = Grid(uv) * lerp(1, 0, min(1.0, fromOrigin / 100));
|
||||
half middleGrid = Grid(uv * 0.1) * lerp(1, 0, min(1.0, fromOrigin / 300));
|
||||
half largeGrid = Grid(uv * 0.01) * lerp(1, 0, min(1.0, fromOrigin / 800));
|
||||
|
||||
//合并计算
|
||||
half grid = smallGrid + middleGrid + largeGrid;
|
||||
return half4(0.5, 0.5, 0.5 ,ground * grid * fading * 0.5 * _ColorLevel); //顺便改色减淡一下
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 099ea33a7b313e343aec7a115569eb79
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Convention/[Art]/GridFull/Grid2DFull/GridSpriteFullSetter.cs
Normal file
17
Convention/[Art]/GridFull/Grid2DFull/GridSpriteFullSetter.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Convention.VFX
|
||||
{
|
||||
public class GridSpriteFullSetter : MonoBehaviour
|
||||
{
|
||||
[Resources]public Transform target;
|
||||
[Resources]public MeshRenderer MyMeshRenderer;
|
||||
|
||||
void Update()
|
||||
{
|
||||
MyMeshRenderer.material.SetVector("_Offset", target.position);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b57e9e00549108469fb592a16980c2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user