/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Data/Base/Shaders/Editor/TextureCubePreview.ezShader
100 строк
2 KB
C-Core
Couple of follow up fixes after the bind group changes (#1607)
12 июл 2025, 18:29
Не верифицирован
12 июл 2025, 18:29
72585a0
Код
Авторство
О чём код?
[PLATFORMS] ALL [PERMUTATIONS] CAMERA_MODE = CAMERA_MODE_PERSPECTIVE [MATERIALPARAMETER] int ShowChannelMode; [RENDERSTATE] CullMode = CullMode_None [SHADER] #define USE_WORLDPOS #define USE_NORMAL [MATERIALCONSTANTS] INT1(ShowChannelMode); FLOAT1(LodLevel); BOOL1(IsLinear); [VERTEXSHADER] #include <Shaders/Materials/MaterialVertexShader.h> VS_OUT main(VS_IN Input) { return FillVertexData(Input); } [PIXELSHADER] #include <Shaders/Materials/MaterialInterpolator.h> #include <Shaders/Common/GlobalConstants.h> TextureCube BaseTexture BIND_GROUP(BG_MATERIAL); SamplerState BaseTexture_AutoSampler BIND_GROUP(BG_MATERIAL); float4 SampleTexture(PS_IN Input) { float3 normal = normalize(Input.Normal); float3 viewDir = normalize(Input.WorldPosition - GetCameraPosition()); // I find this simple lookup way more useful than the reflected, distorted thing below // especially with alpha cut-outs, the reflected thing is completely unusable float3 dir = CubeMapDirection(normal); //float3 dir = CubeMapDirection(reflect(viewDir, normal)); if (GetMaterialData(LodLevel) < 0) { return BaseTexture.Sample(BaseTexture_AutoSampler, dir); } return BaseTexture.SampleLevel(BaseTexture_AutoSampler, dir, GetMaterialData(LodLevel)); } float4 main(PS_IN Input) : SV_Target { float3 color = float3(1, 1, 1); float4 texel = SampleTexture(Input).rgba; float alpha = 1.0; if (GetMaterialData(ShowChannelMode) == 0) { color = texel.rgb; alpha = texel.a; } else if (GetMaterialData(ShowChannelMode) == 1) { color = texel.rgb; } else if (GetMaterialData(ShowChannelMode) == 2) { color = texel.r; } else if (GetMaterialData(ShowChannelMode) == 3) { color = texel.g; } else if (GetMaterialData(ShowChannelMode) == 4) { color = texel.b; } else if (GetMaterialData(ShowChannelMode) == 5) { color = SrgbToLinear(texel.a); // alpha is always linear } if (GetMaterialData(IsLinear) && GetMaterialData(ShowChannelMode) < 5) { color = SrgbToLinear(color); } clip(alpha - 0.5); return float4(color, alpha); }