/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Data/Base/Shaders/Debug/DebugText.ezShader
94 строки
2 KB
C-Core
Render instance data refactor (#1713)
19 ноя 2025, 20:31
Не верифицирован
19 ноя 2025, 20:31
b8e6103
Код
Авторство
О чём код?
[PLATFORMS] ALL [PERMUTATIONS] CAMERA_MODE TOPOLOGY [RENDERSTATE] BlendingEnabled0 = true DestBlend0 = Blend_InvSrcAlpha SourceBlend0 = Blend_SrcAlpha DestBlendAlpha0 = Blend_InvSrcAlpha DepthTest = false DepthWrite = false [VERTEXSHADER] #define USE_TEXCOORD0 #define USE_COLOR0 #include <Shaders/Common/GlobalConstants.h> #include <Shaders/Materials/MaterialInterpolator.h> struct GlyphData { float2 topLeftCorner; uint color; uint glyphIndexAndSize; }; StructuredBuffer<GlyphData> glyphData BIND_GROUP(BG_RENDER_PASS); VS_OUT main(uint VertexID : SV_VertexID, uint InstanceID : SV_InstanceID) { float2 vertexPositions[6] = { float2(0.0, 0.0), float2(1.0, 1.0), float2(0.0, 1.0), float2(0.0, 0.0), float2(1.0, 0.0), float2(1.0, 1.0), }; uint index = VertexID / 6; uint vertexIndex = VertexID % 6; GlyphData data = glyphData[index]; float glyphIndex = float(data.glyphIndexAndSize & 0xFFFF); float size = float((data.glyphIndexAndSize >> 16) & 0xFFFF); float2 vertexPosition = vertexPositions[vertexIndex]; float2 positionInPixel = (vertexPosition * size + data.topLeftCorner); float2 screenPosition = (positionInPixel * ViewportSize.zw) * float2(2.0, -2.0) + float2(-1.0, 1.0); float2 invAtlasSize = 1.0 / float2(16.0, 8.0); float texCoordX = fmod( glyphIndex, 16.0 ); float texCoordY = floor( glyphIndex * invAtlasSize.x ); VS_OUT RetVal; RetVal.Position = float4(screenPosition, 0.0, 1.0); RetVal.TexCoord0 = (float2(texCoordX, texCoordY) + vertexPosition) * invAtlasSize; RetVal.Color0 = RGBA8ToFloat4(data.color); #if defined(CAMERA_MODE) # if CAMERA_MODE == CAMERA_MODE_STEREO RetVal.RenderTargetArrayIndex = InstanceID % 2; # endif #endif return RetVal; } [PIXELSHADER] #define USE_TEXCOORD0 #define USE_COLOR0 #include <Shaders/Materials/MaterialInterpolator.h> Texture2D FontTexture BIND_GROUP(BG_RENDER_PASS); SamplerState FontTexture_AutoSampler BIND_GROUP(BG_RENDER_PASS); float4 main(PS_IN Input) : SV_Target { float glyph = FontTexture.Sample(FontTexture_AutoSampler, Input.TexCoord0.xy).r; float c = saturate(glyph * 2.0 - 1.0); // 0.5 - 1 is color content float a = saturate(glyph * 2.0); // 0 - 0.5 is alpha content return float4(c, c, c, a) * Input.Color0; }