diff --git a/Assets/Gothic-Core/Resources/Prefabs/UI/Menus/LoadingArea.prefab b/Assets/Gothic-Core/Resources/Prefabs/UI/Menus/LoadingArea.prefab index 1a4b086fb..665e43617 100644 --- a/Assets/Gothic-Core/Resources/Prefabs/UI/Menus/LoadingArea.prefab +++ b/Assets/Gothic-Core/Resources/Prefabs/UI/Menus/LoadingArea.prefab @@ -133,7 +133,7 @@ Canvas: m_OverrideSorting: 0 m_OverridePixelPerfect: 0 m_SortingBucketNormalizedSize: 0 - m_VertexColorAlwaysGammaSpace: 1 + m_VertexColorAlwaysGammaSpace: 0 m_AdditionalShaderChannelsFlag: 0 m_UpdateRectTransformForStandalone: 0 m_SortingLayerID: 0 diff --git a/Assets/Gothic-Core/Scripts/Const/Constants.cs b/Assets/Gothic-Core/Scripts/Const/Constants.cs index fa617ecf6..61298a030 100644 --- a/Assets/Gothic-Core/Scripts/Const/Constants.cs +++ b/Assets/Gothic-Core/Scripts/Const/Constants.cs @@ -16,6 +16,7 @@ public static class Animations // Unity shaders public static readonly Shader ShaderUnlit = Shader.Find("Universal Render Pipeline/Unlit"); public static readonly Shader ShaderUnlitParticles = Shader.Find("Universal Render Pipeline/Particles/Unlit"); + public static readonly Shader ShaderUI = Shader.Find("Gothic/UI"); public static readonly Shader ShaderTMPSprite = Shader.Find("TextMeshPro/Sprite"); public static readonly Shader ShaderDecal = Shader.Find("Shader Graphs/Decal"); public static readonly Shader ShaderStandard = Shader.Find("Standard"); diff --git a/Assets/Gothic-Core/Scripts/Services/Meshes/TextureService.cs b/Assets/Gothic-Core/Scripts/Services/Meshes/TextureService.cs index 7b3062ca3..05631497f 100644 --- a/Assets/Gothic-Core/Scripts/Services/Meshes/TextureService.cs +++ b/Assets/Gothic-Core/Scripts/Services/Meshes/TextureService.cs @@ -50,9 +50,9 @@ public void Init() MainMenuTextImageMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Transparent); // Loading Bars - GothicLoadingMenuMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Opaque); - LoadingBarBackgroundMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Opaque); - LoadingBarMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Opaque); + GothicLoadingMenuMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Fade); + LoadingBarBackgroundMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Fade); + LoadingBarMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Fade); // Status Bars StatusBarBackgroundMaterial = GetEmptyMaterial(MaterialExtension.BlendMode.Opaque); @@ -110,7 +110,7 @@ public void SetTexture(string texture, Material material) public Material GetEmptyMaterial(MaterialExtension.BlendMode blendMode) { - var standardShader = Constants.ShaderUnlit; + var standardShader = Constants.ShaderUI; var material = new Material(standardShader); switch (blendMode) @@ -118,14 +118,14 @@ public Material GetEmptyMaterial(MaterialExtension.BlendMode blendMode) case MaterialExtension.BlendMode.Opaque: material.ToOpaqueMode(); break; + case MaterialExtension.BlendMode.Fade: + material.ToFadeMode(); + break; case MaterialExtension.BlendMode.Transparent: material.ToTransparentMode(); break; } - // Enable clipping of alpha values. - material.EnableKeyword("_ALPHATEST_ON"); - return material; } diff --git a/Assets/Gothic-Core/Shaders/GothicUI.shader b/Assets/Gothic-Core/Shaders/GothicUI.shader new file mode 100644 index 000000000..d8227e4b1 --- /dev/null +++ b/Assets/Gothic-Core/Shaders/GothicUI.shader @@ -0,0 +1,105 @@ +Shader "Gothic/UI" +{ + Properties + { + [MainTexture] _BaseMap("Texture", 2D) = "white" {} + [MainColor] _BaseColor("Color", Color) = (1,1,1,1) + + // Obsolete properties for backward compatibility + [HideInInspector] _MainTex("Base Map", 2D) = "white" {} + [HideInInspector] _Color("Base Color", Color) = (1,1,1,1) + + // Blending state — driven by MaterialExtension methods + // Defaults match ToOpaqueMode() behavior + [HideInInspector] _SrcBlend("Src Blend", Float) = 1 + [HideInInspector] _DstBlend("Dst Blend", Float) = 0 + [HideInInspector] _ZWrite("Z Write", Float) = 1 + [HideInInspector] _Cull("Cull", Float) = 0 + + // Alpha cutoff + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + } + + SubShader + { + Tags + { + "RenderType" = "Opaque" + "Queue" = "Geometry" + "RenderPipeline" = "UniversalPipeline" + "IgnoreProjector" = "True" + } + + Blend [_SrcBlend] [_DstBlend] + ZWrite [_ZWrite] + Cull [_Cull] + + Pass + { + Name "Default" + Tags { "LightMode" = "SRPDefaultUnlit" } + + HLSLPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma target 2.0 + + #pragma shader_feature_local_fragment _ALPHATEST_ON + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + + struct Attributes + { + float4 positionOS : POSITION; + float2 uv : TEXCOORD0; + float4 color : COLOR; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct Varyings + { + float4 positionCS : SV_POSITION; + float2 uv : TEXCOORD0; + float4 color : COLOR; + UNITY_VERTEX_OUTPUT_STEREO + }; + + TEXTURE2D(_BaseMap); + SAMPLER(sampler_BaseMap); + float4 _BaseMap_ST; + half4 _BaseColor; + half _Cutoff; + + // Alias for backward compatibility with code that sets _MainTex + #define _MainTex _BaseMap + #define _Color _BaseColor + + Varyings vert(Attributes input) + { + Varyings output; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + output.positionCS = TransformObjectToHClip(input.positionOS.xyz); + output.uv = TRANSFORM_TEX(input.uv, _BaseMap); + output.color = input.color * _BaseColor; + return output; + } + + half4 frag(Varyings input) : SV_Target + { + half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv); + half4 color = texColor * input.color; + + #if defined(_ALPHATEST_ON) + clip(color.a - _Cutoff); + #endif + + return color; + } + ENDHLSL + } + } + + FallBack "Hidden/Universal Render Pipeline/FallbackError" +} diff --git a/Assets/Gothic-Core/Shaders/GothicUI.shader.meta b/Assets/Gothic-Core/Shaders/GothicUI.shader.meta new file mode 100644 index 000000000..18b53662c --- /dev/null +++ b/Assets/Gothic-Core/Shaders/GothicUI.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 02703c9bf67e33063b41c3d6cbc9be01 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index f3250c4fc..dbce42e08 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -38,7 +38,9 @@ GraphicsSettings: - {fileID: 4800000, guid: 2934cb51602218b448edcb4315625e2a, type: 3} - {fileID: 4800000, guid: 3c0120062f2bdbd41b55907f82494d88, type: 3} - {fileID: 4800000, guid: 25dd2ac8db094fa1bf57da112a073017, type: 3} - m_PreloadedShaders: [] + - {fileID: 4800000, guid: 02703c9bf67e33063b41c3d6cbc9be01, type: 3} + m_PreloadedShaders: + - {fileID: 0} m_PreloadShadersBatchTimeLimit: -1 m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} m_CustomRenderPipeline: {fileID: 11400000, guid: ff1e1f739462f6446bfdd47f8653ddb3, type: 2}