Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Assets/Gothic-Core/Scripts/Const/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 7 additions & 7 deletions Assets/Gothic-Core/Scripts/Services/Meshes/TextureService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -110,22 +110,22 @@ 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)
{
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;
}

Expand Down
105 changes: 105 additions & 0 deletions Assets/Gothic-Core/Shaders/GothicUI.shader
Original file line number Diff line number Diff line change
@@ -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"
}
9 changes: 9 additions & 0 deletions Assets/Gothic-Core/Shaders/GothicUI.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion ProjectSettings/GraphicsSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down