codex-5.2: ресурсы

This commit is contained in:
2026-01-01 02:13:01 +06:00
parent d47a5cc090
commit 4aa7c6f41a
52 changed files with 5787 additions and 912 deletions

View File

@@ -16,25 +16,29 @@ layout(push_constant) uniform UniformBufferObject {
// struct NodeVertexStatic {
// uint32_t
// FX : 9, FY : 9, FZ : 9, // Позиция -224 ~ 288; 64 позиций в одной ноде, 7.5 метров в ряд
// N1 : 4, // Не занято
// LS : 1, // Масштаб карты освещения (1м/16 или 1м)
// Tex : 18, // Текстура
// N2 : 14, // Не занято
// TU : 16, TV : 16; // UV на текстуре
// FX : 11, FY : 11, N1 : 10, // Позиция, 64 позиции на метр, +3.5м запас
// FZ : 11, // Позиция
// LS : 1, // Масштаб карты освещения (1м/16 или 1м)
// Tex : 18, // Текстура
// N2 : 2, // Не занято
// TU : 16, TV : 16; // UV на текстуре
// };
void main()
{
uint fx = Vertex.x & 0x7ffu;
uint fy = (Vertex.x >> 11) & 0x7ffu;
uint fz = Vertex.y & 0x7ffu;
vec4 baseVec = ubo.model*vec4(
float(Vertex.x & 0x1ff) / 64.f - 3.5f,
float((Vertex.x >> 9) & 0x1ff) / 64.f - 3.5f,
float((Vertex.x >> 18) & 0x1ff) / 64.f - 3.5f,
float(fx) / 64.f - 3.5f,
float(fy) / 64.f - 3.5f,
float(fz) / 64.f - 3.5f,
1
);
Geometry.GeoPos = baseVec.xyz;
Geometry.Texture = Vertex.y & 0x3ffff;
Geometry.Texture = (Vertex.y >> 12) & 0x3ffffu;
Geometry.UV = vec2(
float(Vertex.z & 0xffff) / pow(2, 16),
float((Vertex.z >> 16) & 0xffff) / pow(2, 16)

Binary file not shown.

View File

@@ -11,65 +11,36 @@ layout(location = 0) in FragmentObj {
layout(location = 0) out vec4 Frame;
struct InfoSubTexture {
uint Flags; // 1 isExist
uint PosXY, WidthHeight;
uint AnimationFrames_AnimationTimePerFrame;
struct AtlasEntry {
vec4 UVMinMax;
uint Layer;
uint Flags;
uint _Pad0;
uint _Pad1;
};
uniform layout(set = 0, binding = 0) sampler2D MainAtlas;
layout(set = 0, binding = 1) readonly buffer MainAtlasLayoutObj {
uint SubsCount;
uint Counter;
uint WidthHeight;
const uint ATLAS_ENTRY_VALID = 1u;
InfoSubTexture SubTextures[];
uniform layout(set = 0, binding = 0) sampler2DArray MainAtlas;
layout(set = 0, binding = 1) readonly buffer MainAtlasLayoutObj {
AtlasEntry Entries[];
} MainAtlasLayout;
uniform layout(set = 1, binding = 0) sampler2D LightMap;
uniform layout(set = 1, binding = 0) sampler2DArray LightMap;
layout(set = 1, binding = 1) readonly buffer LightMapLayoutObj {
vec3 Color;
} LightMapLayout;
vec4 atlasColor(uint texId, vec2 uv)
{
uint flags = (texId & 0xffff0000) >> 16;
texId &= 0xffff;
vec4 color = vec4(uv, 0, 1);
if((flags & (2 | 4)) > 0)
{
if((flags & 2) > 0)
color = vec4(1, 1, 1, 1);
else if((flags & 4) > 0)
{
color = vec4(1);
}
}
else if(texId >= uint(MainAtlasLayout.SubsCount))
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2 ) * vec3(0, 1, 1), 1);
else {
InfoSubTexture texInfo = MainAtlasLayout.SubTextures[texId];
if(texInfo.Flags == 0)
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2 ) * vec3(1, 0, 1), 1);
AtlasEntry entry = MainAtlasLayout.Entries[texId];
if((entry.Flags & ATLAS_ENTRY_VALID) == 0u)
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2) * vec3(1, 0, 1), 1);
uint posX = texInfo.PosXY & 0xffff;
uint posY = (texInfo.PosXY >> 16) & 0xffff;
uint width = texInfo.WidthHeight & 0xffff;
uint height = (texInfo.WidthHeight >> 16) & 0xffff;
uint awidth = MainAtlasLayout.WidthHeight & 0xffff;
uint aheight = (MainAtlasLayout.WidthHeight >> 16) & 0xffff;
if((flags & 1) > 0)
color = texture(MainAtlas, vec2((posX+0.5f+uv.x*(width-1))/awidth, (posY+0.5f+(1-uv.y)*(height-1))/aheight));
else
color = texture(MainAtlas, vec2((posX+uv.x*width)/awidth, (posY+(1-uv.y)*height)/aheight));
}
return color;
vec2 baseUV = vec2(uv.x, 1.0f - uv.y);
vec2 atlasUV = mix(entry.UVMinMax.xy, entry.UVMinMax.zw, baseUV);
atlasUV = clamp(atlasUV, entry.UVMinMax.xy, entry.UVMinMax.zw);
return texture(MainAtlas, vec3(atlasUV, entry.Layer));
}
vec3 blendOverlay(vec3 base, vec3 blend) {

View File

@@ -9,9 +9,19 @@ layout(location = 0) in FragmentObj {
layout(location = 0) out vec4 Frame;
struct AtlasEntry {
vec4 UVMinMax;
uint Layer;
uint Flags;
uint _Pad0;
uint _Pad1;
};
const uint ATLAS_ENTRY_VALID = 1u;
uniform layout(set = 0, binding = 0) sampler2DArray MainAtlas;
layout(set = 0, binding = 1) readonly buffer MainAtlasLayoutObj {
vec3 Color;
AtlasEntry Entries[];
} MainAtlasLayout;
uniform layout(set = 1, binding = 0) sampler2DArray LightMap;
@@ -19,6 +29,19 @@ layout(set = 1, binding = 1) readonly buffer LightMapLayoutObj {
vec3 Color;
} LightMapLayout;
void main() {
Frame = vec4(Fragment.GeoPos, 1);
vec4 atlasColor(uint texId, vec2 uv)
{
AtlasEntry entry = MainAtlasLayout.Entries[texId];
if((entry.Flags & ATLAS_ENTRY_VALID) == 0u)
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2) * vec3(1, 0, 1), 1);
vec2 baseUV = vec2(uv.x, 1.0f - uv.y);
vec2 atlasUV = mix(entry.UVMinMax.xy, entry.UVMinMax.zw, baseUV);
atlasUV = clamp(atlasUV, entry.UVMinMax.xy, entry.UVMinMax.zw);
return texture(MainAtlas, vec3(atlasUV, entry.Layer));
}
void main() {
Frame = atlasColor(Fragment.Texture, Fragment.UV);
Frame.xyz *= max(0.2f, dot(Fragment.Normal, normalize(vec3(0.5, 1, 0.8))));
}

View File

@@ -9,23 +9,22 @@ layout(location = 0) in FragmentObj {
layout(location = 0) out vec4 Frame;
struct InfoSubTexture {
uint Flags; // 1 isExist
uint PosXY, WidthHeight;
uint AnimationFrames_AnimationTimePerFrame;
struct AtlasEntry {
vec4 UVMinMax;
uint Layer;
uint Flags;
uint _Pad0;
uint _Pad1;
};
uniform layout(set = 0, binding = 0) sampler2D MainAtlas;
layout(set = 0, binding = 1) readonly buffer MainAtlasLayoutObj {
uint SubsCount;
uint Counter;
uint WidthHeight;
const uint ATLAS_ENTRY_VALID = 1u;
InfoSubTexture SubTextures[];
uniform layout(set = 0, binding = 0) sampler2DArray MainAtlas;
layout(set = 0, binding = 1) readonly buffer MainAtlasLayoutObj {
AtlasEntry Entries[];
} MainAtlasLayout;
uniform layout(set = 1, binding = 0) sampler2D LightMap;
uniform layout(set = 1, binding = 0) sampler2DArray LightMap;
layout(set = 1, binding = 1) readonly buffer LightMapLayoutObj {
vec3 Color;
} LightMapLayout;
@@ -35,42 +34,14 @@ vec4 atlasColor(uint texId, vec2 uv)
{
uv = mod(uv, 1);
uint flags = (texId & 0xffff0000) >> 16;
texId &= 0xffff;
vec4 color = vec4(uv, 0, 1);
if((flags & (2 | 4)) > 0)
{
if((flags & 2) > 0)
color = vec4(1, 1, 1, 1);
else if((flags & 4) > 0)
{
color = vec4(1);
}
}
else if(texId >= uint(MainAtlasLayout.SubsCount))
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2 ) * vec3(0, 1, 1), 1);
else {
InfoSubTexture texInfo = MainAtlasLayout.SubTextures[texId];
if(texInfo.Flags == 0)
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2 ) * vec3(1, 0, 1), 1);
AtlasEntry entry = MainAtlasLayout.Entries[texId];
if((entry.Flags & ATLAS_ENTRY_VALID) == 0u)
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2) * vec3(1, 0, 1), 1);
uint posX = texInfo.PosXY & 0xffff;
uint posY = (texInfo.PosXY >> 16) & 0xffff;
uint width = texInfo.WidthHeight & 0xffff;
uint height = (texInfo.WidthHeight >> 16) & 0xffff;
uint awidth = MainAtlasLayout.WidthHeight & 0xffff;
uint aheight = (MainAtlasLayout.WidthHeight >> 16) & 0xffff;
if((flags & 1) > 0)
color = texture(MainAtlas, vec2((posX+0.5f+uv.x*(width-1))/awidth, (posY+0.5f+(1-uv.y)*(height-1))/aheight));
else
color = texture(MainAtlas, vec2((posX+uv.x*width)/awidth, (posY+(1-uv.y)*height)/aheight));
}
return color;
vec2 baseUV = vec2(uv.x, 1.0f - uv.y);
vec2 atlasUV = mix(entry.UVMinMax.xy, entry.UVMinMax.zw, baseUV);
atlasUV = clamp(atlasUV, entry.UVMinMax.xy, entry.UVMinMax.zw);
return texture(MainAtlas, vec3(atlasUV, entry.Layer));
}
void main() {

View File

@@ -9,9 +9,19 @@ layout(location = 0) in Fragment {
layout(location = 0) out vec4 Frame;
struct AtlasEntry {
vec4 UVMinMax;
uint Layer;
uint Flags;
uint _Pad0;
uint _Pad1;
};
const uint ATLAS_ENTRY_VALID = 1u;
uniform layout(set = 0, binding = 0) sampler2DArray MainAtlas;
layout(set = 0, binding = 1) readonly buffer MainAtlasLayoutObj {
vec3 Color;
AtlasEntry Entries[];
} MainAtlasLayout;
uniform layout(set = 1, binding = 0) sampler2DArray LightMap;
@@ -19,6 +29,39 @@ layout(set = 1, binding = 1) readonly buffer LightMapLayoutObj {
vec3 Color;
} LightMapLayout;
void main() {
Frame = vec4(1);
vec4 atlasColor(uint texId, vec2 uv)
{
uv = mod(uv, 1);
AtlasEntry entry = MainAtlasLayout.Entries[texId];
if((entry.Flags & ATLAS_ENTRY_VALID) == 0u)
return vec4(((int(gl_FragCoord.x / 128) + int(gl_FragCoord.y / 128)) % 2) * vec3(1, 0, 1), 1);
vec2 baseUV = vec2(uv.x, 1.0f - uv.y);
vec2 atlasUV = mix(entry.UVMinMax.xy, entry.UVMinMax.zw, baseUV);
atlasUV = clamp(atlasUV, entry.UVMinMax.xy, entry.UVMinMax.zw);
return texture(MainAtlas, vec3(atlasUV, entry.Layer));
}
void main() {
vec2 uv;
switch(fragment.Place) {
case 0:
uv = fragment.GeoPos.xz; break;
case 1:
uv = fragment.GeoPos.xy; break;
case 2:
uv = fragment.GeoPos.zy; break;
case 3:
uv = fragment.GeoPos.xz*vec2(-1, -1); break;
case 4:
uv = fragment.GeoPos.xy*vec2(-1, 1); break;
case 5:
uv = fragment.GeoPos.zy*vec2(-1, 1); break;
default:
uv = vec2(0);
}
Frame = atlasColor(fragment.VoxMTL, uv);
}