diff --git a/Assets/Materials/__TempUnlitPlayer.mat b/Assets/Materials/Enemy.mat similarity index 85% rename from Assets/Materials/__TempUnlitPlayer.mat rename to Assets/Materials/Enemy.mat index c7bd10a..bdaef78 100644 --- a/Assets/Materials/__TempUnlitPlayer.mat +++ b/Assets/Materials/Enemy.mat @@ -1,18 +1,5 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!114 &-7482216973894315043 -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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} - m_Name: - m_EditorClassIdentifier: - version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -20,15 +7,14 @@ Material: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: __TempUnlitPlayer - m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Name: Enemy + m_Shader: {fileID: 4800000, guid: ef0b3230706b9ff44b7a6246f9feac63, type: 3} m_ShaderKeywords: m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 - m_CustomRenderQueue: 2000 - stringTagMap: - RenderType: Opaque + m_CustomRenderQueue: 3000 + stringTagMap: {} disabledShaderPasses: [] m_SavedProperties: serializedVersion: 3 @@ -65,6 +51,10 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _NoiseMap: + m_Texture: {fileID: 2800000, guid: 32d99a4d1161f0f4ca4fca2997778b37, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _OcclusionMap: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} @@ -90,9 +80,11 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} m_Floats: + - _Alpha: 1 - _AlphaClip: 0 - _Blend: 0 - _BumpScale: 1 + - _C: 0 - _ClearCoatMask: 0 - _ClearCoatSmoothness: 0 - _Cull: 2 @@ -104,12 +96,12 @@ Material: - _GlossMapScale: 0 - _Glossiness: 0 - _GlossyReflections: 0 + - _M: 0.1 - _Metallic: 0 - _OcclusionStrength: 1 - _Parallax: 0.005 - _QueueOffset: 0 - _ReceiveShadows: 1 - - _SampleGI: 0 - _Smoothness: 0.5 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 @@ -120,6 +112,21 @@ Material: m_Colors: - _BaseColor: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Color1: {r: 0.06480328, g: 0, b: 0.06301003, a: 1} + - _Color2: {r: 0.4292453, g: 0.94931483, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} m_BuildTextureStacks: [] +--- !u!114 &1271807303275379478 +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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 4 diff --git a/Assets/Materials/__TempUnlitEnemy.mat.meta b/Assets/Materials/Enemy.mat.meta similarity index 79% rename from Assets/Materials/__TempUnlitEnemy.mat.meta rename to Assets/Materials/Enemy.mat.meta index 2a7b034..447f1db 100644 --- a/Assets/Materials/__TempUnlitEnemy.mat.meta +++ b/Assets/Materials/Enemy.mat.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a3da566b980834f66bb68c9aca77ef1d +guid: 40e42a955b3861b4288bb5f76845ff2c NativeFormatImporter: externalObjects: {} mainObjectFileID: 2100000 diff --git a/Assets/Materials/__TempUnlitEnemy.mat b/Assets/Materials/__TempUnlitEnemy.mat deleted file mode 100644 index dd31ca3..0000000 --- a/Assets/Materials/__TempUnlitEnemy.mat +++ /dev/null @@ -1,126 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &-7482216973894315043 -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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} - m_Name: - m_EditorClassIdentifier: - version: 4 ---- !u!21 &2100000 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: __TempUnlitEnemy - m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: 3000 - stringTagMap: - RenderType: Transparent - disabledShaderPasses: - - SHADOWCASTER - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BaseMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - 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} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _SpecGlossMap: - 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_Floats: - - _AlphaClip: 0 - - _Blend: 0 - - _BumpScale: 1 - - _ClearCoatMask: 0 - - _ClearCoatSmoothness: 0 - - _Cull: 2 - - _Cutoff: 0.5 - - _DetailAlbedoMapScale: 1 - - _DetailNormalMapScale: 1 - - _DstBlend: 10 - - _EnvironmentReflections: 1 - - _GlossMapScale: 0 - - _Glossiness: 0 - - _GlossyReflections: 0 - - _Metallic: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.005 - - _QueueOffset: 0 - - _ReceiveShadows: 1 - - _SampleGI: 0 - - _Smoothness: 0.5 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 5 - - _Surface: 1 - - _WorkflowMode: 1 - - _ZWrite: 0 - m_Colors: - - _BaseColor: {r: 0.8396226, g: 0.09109115, b: 0.09109115, a: 1} - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - m_BuildTextureStacks: [] diff --git a/Assets/Materials/__TempUnlitPlayer.mat.meta b/Assets/Materials/__TempUnlitPlayer.mat.meta deleted file mode 100644 index cdba3f3..0000000 --- a/Assets/Materials/__TempUnlitPlayer.mat.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 91f85826a80e340dc930093507b30791 -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 2100000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Models/enemy.blend b/Assets/Models/enemy.blend new file mode 100644 index 0000000..e342325 --- /dev/null +++ b/Assets/Models/enemy.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b575f051c0cbbf1b519db09fc65e150e2050f9f27df23b6fc6e58da3662a4a5 +size 553176 diff --git a/Assets/Models/enemy.blend.meta b/Assets/Models/enemy.blend.meta new file mode 100644 index 0000000..1429383 --- /dev/null +++ b/Assets/Models/enemy.blend.meta @@ -0,0 +1,102 @@ +fileFormatVersion: 2 +guid: 7421c25da3323da4aa7ac7582f03c58e +ModelImporter: + serializedVersion: 20200 + internalIDToNameTable: [] + externalObjects: {} + materials: + materialImportMode: 2 + materialName: 0 + materialSearch: 1 + materialLocation: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: [] + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importVisibility: 1 + importBlendShapes: 1 + importCameras: 1 + importLights: 1 + fileIdsGeneration: 2 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + meshOptimizationFlags: -1 + indexFormat: 0 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 1 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + normalCalculationMode: 4 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 1 + humanDescription: + serializedVersion: 3 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 1 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 2 + humanoidOversampling: 1 + avatarSetup: 0 + addHumanoidExtraRootOnlyWhenUsingAvatar: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab index e18f727..5f2b9a9 100644 --- a/Assets/Prefabs/Enemy.prefab +++ b/Assets/Prefabs/Enemy.prefab @@ -31,7 +31,7 @@ Transform: m_GameObject: {fileID: 1738226812227614583} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalScale: {x: 0.5, y: 0.4, z: 0.6} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 @@ -43,7 +43,7 @@ MeshFilter: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1738226812227614583} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} + m_Mesh: {fileID: -5495902117074765545, guid: 7421c25da3323da4aa7ac7582f03c58e, type: 3} --- !u!23 &1738226812227614582 MeshRenderer: m_ObjectHideFlags: 0 @@ -63,7 +63,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: a3da566b980834f66bb68c9aca77ef1d, type: 2} + - {fileID: 2100000, guid: 40e42a955b3861b4288bb5f76845ff2c, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -96,7 +96,7 @@ BoxCollider: m_IsTrigger: 1 m_Enabled: 1 serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} + m_Size: {x: 2, y: 2, z: 2} m_Center: {x: 0, y: 0, z: 0} --- !u!114 &2766037370157449026 MonoBehaviour: diff --git a/Assets/Scripts/DisableOnDeath.cs b/Assets/Scripts/DisableOnDeath.cs index 4c3201f..320238f 100644 --- a/Assets/Scripts/DisableOnDeath.cs +++ b/Assets/Scripts/DisableOnDeath.cs @@ -7,19 +7,28 @@ public class DisableOnDeath : MonoBehaviour { private EntityHealth _health; private Renderer _renderer; - private Color _color; + + private Color _color1; + private Color _color2; + + private const string COLOR_1 = "_Color1"; + private const string COLOR_2 = "_Color2"; private void Awake() { _health = GetComponent(); _renderer = GetComponentInChildren(); - _color = _renderer.material.color; + + _color1 = _renderer.material.GetColor(COLOR_1); + _color2 = _renderer.material.GetColor(COLOR_2); } private void OnEnable() { _health.Die += Die; - _renderer.material.color = _color; + + _renderer.material.SetColor(COLOR_1, _color1); + _renderer.material.SetColor(COLOR_2, _color2); } private void OnDisable() @@ -31,8 +40,27 @@ public class DisableOnDeath : MonoBehaviour { var oldName = gameObject.name; gameObject.name = "disabled"; - _renderer.material.DOColor(Color.white, 0.1f); - _renderer.material.DOFade(0, 0.1f).SetDelay(0.2f); + + float x = 0; + DOTween.To( + () => x, + t => + { + var c1 = Color.Lerp(_color1, Color.white, t); + var c2 = Color.Lerp(_color2, Color.white, t); + + _renderer.material.SetColor(COLOR_1, c1); + _renderer.material.SetColor(COLOR_2, c2); + _renderer.material.SetFloat("_Alpha", 1.0f-t); + }, + 1.0f, + 0.1f); + + + + // _renderer.material.DOColor(Color.white, COLOR_1, 0.1f); + // _renderer.material.DOColor(Color.white, COLOR_2, 0.1f); + // _renderer.material.DOFade(0, 0.1f).SetDelay(0.2f); transform.DOScale(Vector3.one * 1.5f, 0.3f).SetEase(Ease.OutQuint).OnComplete(() => { gameObject.name = oldName; diff --git a/Assets/Shaders/enemy.shader b/Assets/Shaders/enemy.shader new file mode 100644 index 0000000..b1f179d --- /dev/null +++ b/Assets/Shaders/enemy.shader @@ -0,0 +1,128 @@ +// This shader draws a texture on the mesh. +Shader "custom/enemy" +{ + // The _BaseMap variable is visible in the Material's Inspector, as a field + // called Base Map. + Properties + { + [HDR] _Color1("Color1", Color) = (1,1,1,1) + [HDR] _Color2("Color2", Color) = (1,1,1,1) + _Alpha("Alpha", Float) = 1.0 +// [HDR] _Color2("Color 2", Color) = (1,1,1,1) +// _FadeStrength("Fade Strength", Float) = 0.1 +// _VertexScale("Vertex Scale", Float) = 0 + + _M("M", Float) = 0.5 + _C("C", Float) = 0.0 + + _NoiseMap("Noise Map", 2D) = "black" + _VertexDistortion("Vertex Distortion", Float) = 1.0 + } + + SubShader + { + Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalRenderPipeline" } + + Pass + { + HLSLPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + + struct Attributes + { + float4 positionOS : POSITION; + // The uv variable contains the UV coordinate on the texture for the + // given vertex. + float2 uv : TEXCOORD0; + half3 normal : NORMAL; + }; + + struct Varyings + { + float4 positionHCS : SV_POSITION; + // The uv variable contains the UV coordinate on the texture for the + // given vertex. + float2 uv : TEXCOORD0; + float3 wpos : TEXCOORD1; + half3 normal : NORMAL; + }; + + float _M = 0.5; + float _C = 0.0; + float4 _Color1; + float4 _Color2; + float _Alpha; + float _TimeToNextBeat; + + float _VertexDistortion; + // float _VertexScale; + // float _FadeStrength; + + // This macro declares _BaseMap as a Texture2D object. + TEXTURE2D(_BaseMap); + // This macro declares the sampler for the _BaseMap texture. + SAMPLER(sampler_BaseMap); + TEXTURE2D(_NoiseMap); + SAMPLER(sampler_NoiseMap); + + CBUFFER_START(UnityPerMaterial) + // The following line declares the _BaseMap_ST variable, so that you + // can use the _BaseMap variable in the fragment shader. The _ST + // suffix is necessary for the tiling and offset function to work. + float4 _BaseMap_ST; + float4 _NoiseMap_ST; + CBUFFER_END + + Varyings vert(Attributes IN) + { + Varyings OUT; + + float3 vpos = IN.positionOS.xyz; + float3 wpos = TransformObjectToWorld(vpos); + OUT.wpos = wpos; + OUT.normal = IN.normal; + + float d = 1.0+length(wpos)*0.5; + float2 uv = wpos.zx; + float noise = SAMPLE_TEXTURE2D_LOD(_NoiseMap, sampler_NoiseMap, uv, 0) - 0.5; + + // vpos += _VertexScale*float3(0,0,5)*d; + vpos += float3(_VertexDistortion,0,0)*noise*d; + // vpos += sin(180)*sin(1800)*float3(0,0,5)*d; + + // noise *= d*d * 0.1; + + // vpos *= lerp (0.9,1.1,noise); + + OUT.positionHCS = TransformObjectToHClip(vpos); + // The TRANSFORM_TEX macro performs the tiling and offset + // transformation. + OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap); + return OUT; + } + + half4 frag(Varyings IN) : SV_Target + { + // calculate pixel + float2 res = _ScreenParams; + float2 p = -1.0+2.0*IN.positionHCS.xy/res.xy; + + float2 toCentre = TransformObjectToWorld(-IN.wpos).xy; + toCentre = normalize(toCentre); + + float t = dot(IN.normal, toCentre) * 0.5 + 0.5; + + // float t = dot(IN.normal, float3(0,1,0)) * 0.5 + 0.5; + + // float t = length(p); + // return lerp(_Color1,_Color2,t * _FadeStrength); + float4 c = float4(lerp(_Color1, _Color2, t).xyz, _Alpha); + return c; + } + ENDHLSL + } + } +} \ No newline at end of file diff --git a/Assets/Shaders/enemy.shader.meta b/Assets/Shaders/enemy.shader.meta new file mode 100644 index 0000000..196d911 --- /dev/null +++ b/Assets/Shaders/enemy.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ef0b3230706b9ff44b7a6246f9feac63 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: