commit 9559cc8882161192a43be22670a8ff69db1ea13a Author: Roman <1325980292@qq.com> Date: Sat Aug 27 19:22:38 2022 +0800 短学期Log 任务:替换和实装美术素材 1.在教程场景布置图标和文字提示内容 DONE 2.制作GamePlay中背景元素的动画并实装 DONE 3.替换拆迁障碍物美术素材 DONE 任务:实装音乐和音效 1.为两个场景添加音乐,并且在GamePlay场景不重开音乐。 DONE 2.实装人摔地音效 DONE 3.实装人跑动音效 效果不好 DONE 4.实装人马分离音效 DONE *.补充实装人降落到马上的音效 DONE 5.实装创烂障碍物音效 DONE 6.实装圣火点燃音效 DONE 7.实装马磕磕碰碰音效 DONE 8.实装马似音效 DONE 9.实装马着地音效 DONE 10.实装马起跳音效 DONE 11.实装马蹄点地音效 效果不好 DONE 任务:实装特效 1.实装后处理 DONE 2.实装日夜更替 DONE 3.实装树叶飘落 DONE 4.实装圣火粒子 效果不好 DONE 5.实装破碎灰尘 效果不好 DONE 6.实装马蹄灰尘 DONE 7.实装红黑闪特效 DONE 任务:完善没写的零散逻辑 1.在教程场景,若人马分离障碍处没接到人,过一个转场然后复位人和马 **:仍然存在问题,当如此,人的动画失效。这个问题现在不好修,等待人的死亡动画实装后再修 已修复 DONE 2.在教程场景,点燃圣火仅有进入触发器后加载转场然后转移场景的功能,没有点燃圣火的过程,现补充其逻辑 DONE 3.开发GamePlay距离记录和重开系统 DONE 4.策划要在点燃圣火时镜头放大,体现标题感 URP相机不太好做 ABANDON 5.人的死亡动画逻辑之前没做 DONE 任务:测试并修复Bug DONE 修复Bug 1.在教程场景,可破坏障碍物的碎片的层级不对,创烂瞬间会有层级突变的问题。在GamePlay层级,也出现了这个问题。 已修复 DONE 2.现在的高障碍实在太高了,基本有80%以上的概率导致马翻,应该调低障碍物、或者调大马的跳跃力度。 DONE 3.跑步动画和跑步音效完全对不上 加快跑步动画 DONE 4.原爆破给力范围太大,会导致旧的碎片也被波及 已修复 DONE commit cab00851df5e4da70b981c564888c53d86de1f95 Author: Roman <1325980292@qq.com> Date: Sat Aug 27 02:51:21 2022 +0800 短学期Log 任务:替换和实装美术素材 1.在教程场景布置图标和文字提示内容 DONE 2.制作GamePlay中背景元素的动画并实装 DONE 3.替换拆迁障碍物美术素材 DONE 任务:实装音乐和音效 1.为两个场景添加音乐,并且在GamePlay场景不重开音乐。 DONE 2.实装人摔地音效 DONE 3.实装人跑动音效 DONE 4.实装人马分离音效 DONE 5.实装创烂障碍物音效 DOING 6.实装圣火点燃音效 7.实装马磕磕碰碰音效 8.实装马似音效 9.实装马着地音效 10.实装马起跳音效 任务:实装特效 …… 任务:完善没写的零散逻辑 1.在教程场景,若人马分离障碍处没接到人,过一个转场然后复位人和马 **:仍然存在问题,当如此,人的动画失效。这个问题现在不好修,等待人的死亡动画实装后再修 WAIT 2.在教程场景,点燃圣火仅有进入触发器后加载转场然后转移场景的功能,没有点燃圣火的过程,现补充其逻辑 DONE 3.开发GamePlay距离记录和重开系统 …… 修复Bug 1.在教程场景,可破坏障碍物的碎片的层级不对,创烂瞬间会有层级突变的问题。在GamePlay层级,也出现了这个问题。 2.现在的高障碍实在太高了,基本有80%以上的概率导致马翻,应该调低障碍物、或者调大马的跳跃力度。 commit 3f0c9dd791c66e7222d6dbb72d8b762b73f06aed Merge: e6888a7 bc74426 Author: Roman <1325980292@qq.com> Date: Fri Aug 26 18:13:00 2022 +0800 Merge branch 'Saipo' of https://e.coding.net/gensokyogroup/saima/SAIMA into Roman # Conflicts: # UserSettings/EditorUserSettings.asset # UserSettings/Layouts/CurrentMaximizeLayout.dwlt # UserSettings/Layouts/default-2021.dwlt commit e6888a748dc7188bd3c2f7ce4bceade7402f8cec Author: Roman <1325980292@qq.com> Date: Fri Aug 26 18:11:05 2022 +0800 任务:编写教程和开始场景 分析:分为五个阶段,每个阶段一屏宽。前四个阶段是教程阶段,分别仅放一种障碍(第一个无障碍)和提示,提示参照茶杯头教程关。 每个阶段间有明显间断、镜头固定,但当马通过该阶段的障碍后,镜头右移一个阶段。马不能倒退,相机左侧有空气墙。 到达最终阶段后,按流程点燃圣火进入游戏 设计: 1.搭建核心场景,放置障碍物。 DONE 2.设计教程及开始场景管理器 (1.控制相机,使马每通过一个阶段,相机运动到记录的位置 DONE (2.给相机左侧添加空气墙 DONE (3.管理器要明确记录此时玩家处于哪个阶段 DONE (4.当玩家进入点燃圣火触发器,切断操控,等待动画结束或者一些信号,触发从右向左的渐变黑幕遮挡全屏,随后转场到新场景。 DONE 至此,基本逻辑完成,需要补充大量细节、替换大量美术素材。 修复问题: 1.人马分离障碍连续出现可能导致致命问题,修复使其不能连续出现 DONE 2.GamePlay中,远处的山需要补充运动逻辑 DONE commit 5d922db6142634cdd20aa7801c0b3c1c4994360c Author: Roman <1325980292@qq.com> Date: Wed Aug 24 17:59:05 2022 +0800 任务:制作人物动画逻辑 1.当人物处于Normal时,重复播放骑在马上的动画 2.当人物被射出,播放一次跳上动画,之后停在最后一帧,等待落到平台上。 3.当人物进入Walk态,开始重复播放跑步动画。 4.当人物开始降落,触发一次跳下动画,停在最后一帧 5.当Recover结束,状态恢复为Normal,重回到骑在马上动画 DONE commit d1fe07492af5ce6ea736ef738eb3e38170a08066 Merge: 436eaf0 5e10767 Author: Roman <1325980292@qq.com> Date: Wed Aug 24 10:42:58 2022 +0800 Merge branch 'Saipo' of https://e.coding.net/gensokyogroup/saima/SAIMA into Roman # Conflicts: # UserSettings/Layouts/default-2021.dwlt commit 436eaf01046248372e887eb8276f38e021915790 Author: Roman <1325980292@qq.com> Date: Wed Aug 24 10:40:51 2022 +0800 为了拉取的提交,少量修改
318 lines
10 KiB
GLSL
318 lines
10 KiB
GLSL
Shader "TextMeshPro/Distance Field Overlay" {
|
|
|
|
Properties {
|
|
_FaceTex ("Face Texture", 2D) = "white" {}
|
|
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
|
|
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
|
|
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
|
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
|
|
|
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
|
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
|
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
|
|
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
|
|
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
|
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
|
|
|
_Bevel ("Bevel", Range(0,1)) = 0.5
|
|
_BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
|
|
_BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
|
|
_BevelClamp ("Bevel Clamp", Range(0,1)) = 0
|
|
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
|
|
|
|
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
|
|
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1)
|
|
_SpecularPower ("Specular", Range(0,4)) = 2.0
|
|
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
|
|
_Diffuse ("Diffuse", Range(0,1)) = 0.5
|
|
_Ambient ("Ambient", Range(1,0)) = 0.5
|
|
|
|
_BumpMap ("Normal map", 2D) = "bump" {}
|
|
_BumpOutline ("Bump Outline", Range(0,1)) = 0
|
|
_BumpFace ("Bump Face", Range(0,1)) = 0
|
|
|
|
_ReflectFaceColor ("Reflection Color", Color) = (0,0,0,1)
|
|
_ReflectOutlineColor("Reflection Color", Color) = (0,0,0,1)
|
|
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
|
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
|
|
|
|
|
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
|
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
|
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
|
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
|
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
|
|
|
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
|
_GlowOffset ("Offset", Range(-1,1)) = 0
|
|
_GlowInner ("Inner", Range(0,1)) = 0.05
|
|
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
|
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
|
|
|
_WeightNormal ("Weight Normal", float) = 0
|
|
_WeightBold ("Weight Bold", float) = 0.5
|
|
|
|
_ShaderFlags ("Flags", float) = 0
|
|
_ScaleRatioA ("Scale RatioA", float) = 1
|
|
_ScaleRatioB ("Scale RatioB", float) = 1
|
|
_ScaleRatioC ("Scale RatioC", float) = 1
|
|
|
|
_MainTex ("Font Atlas", 2D) = "white" {}
|
|
_TextureWidth ("Texture Width", float) = 512
|
|
_TextureHeight ("Texture Height", float) = 512
|
|
_GradientScale ("Gradient Scale", float) = 5.0
|
|
_ScaleX ("Scale X", float) = 1.0
|
|
_ScaleY ("Scale Y", float) = 1.0
|
|
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
|
_Sharpness ("Sharpness", Range(-1,1)) = 0
|
|
|
|
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
|
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
|
|
|
_MaskCoord ("Mask Coordinates", vector) = (0, 0, 32767, 32767)
|
|
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
|
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
|
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
|
|
|
_StencilComp ("Stencil Comparison", Float) = 8
|
|
_Stencil ("Stencil ID", Float) = 0
|
|
_StencilOp ("Stencil Operation", Float) = 0
|
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
|
|
|
_CullMode ("Cull Mode", Float) = 0
|
|
_ColorMask ("Color Mask", Float) = 15
|
|
}
|
|
|
|
SubShader {
|
|
|
|
Tags
|
|
{
|
|
"Queue"="Overlay"
|
|
"IgnoreProjector"="True"
|
|
"RenderType"="Transparent"
|
|
}
|
|
|
|
Stencil
|
|
{
|
|
Ref [_Stencil]
|
|
Comp [_StencilComp]
|
|
Pass [_StencilOp]
|
|
ReadMask [_StencilReadMask]
|
|
WriteMask [_StencilWriteMask]
|
|
}
|
|
|
|
Cull [_CullMode]
|
|
ZWrite Off
|
|
Lighting Off
|
|
Fog { Mode Off }
|
|
ZTest Always
|
|
Blend One OneMinusSrcAlpha
|
|
ColorMask [_ColorMask]
|
|
|
|
Pass {
|
|
CGPROGRAM
|
|
#pragma target 3.0
|
|
#pragma vertex VertShader
|
|
#pragma fragment PixShader
|
|
#pragma shader_feature __ BEVEL_ON
|
|
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
|
#pragma shader_feature __ GLOW_ON
|
|
|
|
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
|
|
|
#include "UnityCG.cginc"
|
|
#include "UnityUI.cginc"
|
|
#include "TMPro_Properties.cginc"
|
|
#include "TMPro.cginc"
|
|
|
|
struct vertex_t {
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
float4 position : POSITION;
|
|
float3 normal : NORMAL;
|
|
fixed4 color : COLOR;
|
|
float2 texcoord0 : TEXCOORD0;
|
|
float2 texcoord1 : TEXCOORD1;
|
|
};
|
|
|
|
|
|
struct pixel_t {
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
float4 position : SV_POSITION;
|
|
fixed4 color : COLOR;
|
|
float2 atlas : TEXCOORD0; // Atlas
|
|
float4 param : TEXCOORD1; // alphaClip, scale, bias, weight
|
|
float4 mask : TEXCOORD2; // Position in object space(xy), pixel Size(zw)
|
|
float3 viewDir : TEXCOORD3;
|
|
|
|
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
|
float4 texcoord2 : TEXCOORD4; // u,v, scale, bias
|
|
fixed4 underlayColor : COLOR1;
|
|
#endif
|
|
float4 textures : TEXCOORD5;
|
|
};
|
|
|
|
// Used by Unity internally to handle Texture Tiling and Offset.
|
|
float4 _FaceTex_ST;
|
|
float4 _OutlineTex_ST;
|
|
|
|
pixel_t VertShader(vertex_t input)
|
|
{
|
|
pixel_t output;
|
|
|
|
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
UNITY_TRANSFER_INSTANCE_ID(input,output);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
|
|
float bold = step(input.texcoord1.y, 0);
|
|
|
|
float4 vert = input.position;
|
|
vert.x += _VertexOffsetX;
|
|
vert.y += _VertexOffsetY;
|
|
|
|
float4 vPosition = UnityObjectToClipPos(vert);
|
|
|
|
float2 pixelSize = vPosition.w;
|
|
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
|
float scale = rsqrt(dot(pixelSize, pixelSize));
|
|
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
|
if (UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
|
|
|
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
|
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
|
|
|
float bias =(.5 - weight) + (.5 / scale);
|
|
|
|
float alphaClip = (1.0 - _OutlineWidth*_ScaleRatioA - _OutlineSoftness*_ScaleRatioA);
|
|
|
|
#if GLOW_ON
|
|
alphaClip = min(alphaClip, 1.0 - _GlowOffset * _ScaleRatioB - _GlowOuter * _ScaleRatioB);
|
|
#endif
|
|
|
|
alphaClip = alphaClip / 2.0 - ( .5 / scale) - weight;
|
|
|
|
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
|
float4 underlayColor = _UnderlayColor;
|
|
underlayColor.rgb *= underlayColor.a;
|
|
|
|
float bScale = scale;
|
|
bScale /= 1 + ((_UnderlaySoftness*_ScaleRatioC) * bScale);
|
|
float bBias = (0.5 - weight) * bScale - 0.5 - ((_UnderlayDilate * _ScaleRatioC) * 0.5 * bScale);
|
|
|
|
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
|
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
|
float2 bOffset = float2(x, y);
|
|
#endif
|
|
|
|
// Generate UV for the Masking Texture
|
|
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
|
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
|
|
|
// Support for texture tiling and offset
|
|
float2 textureUV = UnpackUV(input.texcoord1.x);
|
|
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
|
|
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
|
|
|
|
|
|
output.position = vPosition;
|
|
output.color = input.color;
|
|
output.atlas = input.texcoord0;
|
|
output.param = float4(alphaClip, scale, bias, weight);
|
|
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
|
output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
|
|
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
|
output.texcoord2 = float4(input.texcoord0 + bOffset, bScale, bBias);
|
|
output.underlayColor = underlayColor;
|
|
#endif
|
|
output.textures = float4(faceUV, outlineUV);
|
|
|
|
return output;
|
|
}
|
|
|
|
|
|
fixed4 PixShader(pixel_t input) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
|
|
float c = tex2D(_MainTex, input.atlas).a;
|
|
|
|
#ifndef UNDERLAY_ON
|
|
clip(c - input.param.x);
|
|
#endif
|
|
|
|
float scale = input.param.y;
|
|
float bias = input.param.z;
|
|
float weight = input.param.w;
|
|
float sd = (bias - c) * scale;
|
|
|
|
float outline = (_OutlineWidth * _ScaleRatioA) * scale;
|
|
float softness = (_OutlineSoftness * _ScaleRatioA) * scale;
|
|
|
|
half4 faceColor = _FaceColor;
|
|
half4 outlineColor = _OutlineColor;
|
|
|
|
faceColor.rgb *= input.color.rgb;
|
|
|
|
faceColor *= tex2D(_FaceTex, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y);
|
|
outlineColor *= tex2D(_OutlineTex, input.textures.zw + float2(_OutlineUVSpeedX, _OutlineUVSpeedY) * _Time.y);
|
|
|
|
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
|
|
|
|
#if BEVEL_ON
|
|
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
|
|
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
|
|
|
|
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
|
|
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
|
|
n = normalize(n- bump);
|
|
|
|
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), -1.0));
|
|
|
|
float3 col = GetSpecular(n, light);
|
|
faceColor.rgb += col*faceColor.a;
|
|
faceColor.rgb *= 1-(dot(n, light)*_Diffuse);
|
|
faceColor.rgb *= lerp(_Ambient, 1, n.z*n.z);
|
|
|
|
fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
|
|
faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
|
|
#endif
|
|
|
|
#if UNDERLAY_ON
|
|
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
|
faceColor += input.underlayColor * saturate(d - input.texcoord2.w) * (1 - faceColor.a);
|
|
#endif
|
|
|
|
#if UNDERLAY_INNER
|
|
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
|
faceColor += input.underlayColor * (1 - saturate(d - input.texcoord2.w)) * saturate(1 - sd) * (1 - faceColor.a);
|
|
#endif
|
|
|
|
#if GLOW_ON
|
|
float4 glowColor = GetGlowColor(sd, scale);
|
|
faceColor.rgb += glowColor.rgb * glowColor.a;
|
|
#endif
|
|
|
|
// Alternative implementation to UnityGet2DClipping with support for softness.
|
|
#if UNITY_UI_CLIP_RECT
|
|
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
|
faceColor *= m.x * m.y;
|
|
#endif
|
|
|
|
#if UNITY_UI_ALPHACLIP
|
|
clip(faceColor.a - 0.001);
|
|
#endif
|
|
|
|
return faceColor * input.color.a;
|
|
}
|
|
|
|
ENDCG
|
|
}
|
|
}
|
|
|
|
Fallback "TextMeshPro/Mobile/Distance Field"
|
|
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
|
}
|