Skip to content

Commit 528721a

Browse files
committed
dawn: fix gui image, color picker, and solid color, fix font, fix scene rendering icons; fix fetching submodules from parent project
1 parent d2bfd3f commit 528721a

File tree

24 files changed

+223
-101
lines changed

24 files changed

+223
-101
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ if(WIN32)
1515
message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
1616
endif()
1717

18-
execute_process(COMMAND "bash" "${CMAKE_CURRENT_LIST_DIR}/submodules.sh" WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)
19-
2018
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2119
include(cage_all)
2220

2321
if(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
2422
cage_default_init() # standalone build
2523
else()
24+
cage_fetch_cage_externals()
2625
cage_disable_source_build()
2726
cage_build_configuration()
2827
endif()

cmake/cage_all.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include(cage_default_init)
77
include(cage_directory_link)
88
include(cage_disable_source_build)
99
include(cage_embed_file)
10+
include(cage_fetch_cage_externals)
1011
include(cage_ide_category)
1112
include(cage_ide_sort_files)
1213
include(cage_ide_startup_project)

cmake/cage_default_init.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
macro(cage_default_init)
3+
cage_fetch_cage_externals()
34
cage_disable_source_build()
45
cage_build_configuration()
56
cage_build_destination()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
function(cage_fetch_cage_externals)
3+
execute_process(COMMAND "bash" "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../submodules.sh" WORKING_DIRECTORY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/.." COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)
4+
endfunction(cage_fetch_cage_externals)
5+

data/cage/shaders/engine/fragment.glsl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ vec4 lighting(Material material)
158158
// emissive
159159
res.rgb += material.albedo * material.emissive;
160160

161+
#ifdef Normals
161162
if (dot(normal, normal) > 0.5) // lighting enabled
162163
{
163164
float ssao = 1;
@@ -197,6 +198,7 @@ vec4 lighting(Material material)
197198
}
198199
}
199200
}
201+
#endif // Normals
200202

201203
if (material.fade < 0.5)
202204
res.a = material.opacity;
@@ -278,6 +280,8 @@ Material loadMaterial()
278280
// additionally applies normal map
279281
void updateNormal()
280282
{
283+
#ifdef Normals
284+
281285
normal = normalize(varNormal);
282286

283287
#if defined(MaterialTexRegular) || defined(MaterialTexArray) || defined(MaterialTexCube)
@@ -299,4 +303,10 @@ void updateNormal()
299303
}
300304
else
301305
normal = vec3(0);
306+
307+
#else
308+
309+
normal = vec3(0);
310+
311+
#endif // Normals
302312
}

data/cage/shaders/engine/vertex.glsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ void propagateInputs()
2020
{
2121
varInstanceId = gl_InstanceIndex;
2222
varPosition = inPosition;
23+
#ifdef Normals
2324
varNormal = inNormal;
25+
#else
26+
varNormal = vec3(0);
27+
#endif // Normals
2428
varUv = inUv;
2529
}
2630

data/cage/shaders/gui/colorPicker.glsl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ void main()
2121
{
2222
gl_Position.z = 0;
2323
gl_Position.w = 1;
24-
gl_Position.xy = uniPos.xy + (uniPos.zw - uniPos.xy) * inUv;
25-
varUv = inUv;
24+
gl_Position.xy = uniPos.xy + (uniPos.zw - uniPos.xy) * inPosition.xy;
25+
varUv.x = inUv.x;
26+
varUv.y = 1 - inUv.y;
2627
}
2728

2829

data/cage/shaders/gui/image.glsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
$include ../functions/sampleTextureAnimation.glsl
3-
42
layout(std140, set = 2, binding = 0) uniform Global
53
{
64
vec4 uniPos; // x1, y1, x2, y2
@@ -28,6 +26,8 @@ void main()
2826

2927
$define shader fragment
3028

29+
$include ../functions/sampleTextureAnimation.glsl
30+
3131
layout(location = 0) out vec4 outColor;
3232

3333
vec4 delinearize(vec4 ca)
@@ -53,7 +53,7 @@ vec4 desaturateDisabled(vec4 ca)
5353

5454
#ifdef Animated
5555

56-
layout(binding = 0) uniform sampler2DArray texImg;
56+
layout(set = 2, binding = 1) uniform sampler2DArray texImg;
5757

5858
void main()
5959
{
@@ -64,7 +64,7 @@ void main()
6464

6565
#else
6666

67-
layout(binding = 0) uniform sampler2D texImg;
67+
layout(set = 2, binding = 1) uniform sampler2D texImg;
6868

6969
void main()
7070
{

sources/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ file(GLOB_RECURSE cage-core-sources "libcore/*" "include/cage-core/*")
1010
add_library(cage-core SHARED ${cage-core-sources})
1111
target_compile_features(cage-core PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
1212
target_include_directories(cage-core PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
13-
target_link_libraries(cage-core PRIVATE zlib libzstd_static simplefilewatcher fastnoise hsluv png_static cage-jpeg tiff tiffxx tinyexr stb xatlas pmp dualmc dr_libs ogg vorbis vorbisfile vorbisenc samplerate assimp bc7enc_rdo avir quickhull iwasm_static uni-algo cpr)
13+
target_link_libraries(cage-core PRIVATE zlib libzstd_static simplefilewatcher fastnoise hsluv png_static cage-jpeg tiff tiffxx tinyexr stb xatlas pmp dualmc dr_libs ogg vorbis vorbisfile vorbisenc samplerate assimp bc7enc_rdo avir quickhull iwasm_static uni-algo cpr absl_log)
1414
target_link_libraries(cage-core PUBLIC svector unordered_dense plf)
1515
if (cage_use_steam_sockets)
1616
target_link_libraries(cage-core PRIVATE GameNetworkingSockets::GameNetworkingSockets)

sources/asset-processor/texture.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,7 @@ namespace
194194
void fillAlphaChannel(Image *img)
195195
{
196196
CAGE_ASSERT(img->channels() == 4);
197-
const uint32 w = img->width();
198-
const uint32 h = img->height();
199-
for (uint32 y = 0; y < h; y++)
200-
for (uint32 x = 0; x < w; x++)
201-
img->value(x, y, 3, 1);
197+
imageFill(img, 3, 1);
202198
}
203199

204200
void overrideColorConfig(AlphaModeEnum alpha, GammaSpaceEnum gamma)
@@ -216,6 +212,13 @@ namespace
216212

217213
void performDownscale(const uint32 downscale, bool volume3D)
218214
{
215+
const auto &update = [&](uint32 w)
216+
{
217+
w = max(w / downscale, 1u);
218+
w = (w + 3) & ~3u; // round up to next multiple of 4
219+
return w;
220+
};
221+
219222
if (volume3D)
220223
{ // downscale image as a whole
221224
CAGE_LOG(SeverityEnum::Info, "assetProcessor", Stringizer() + "downscaling whole image (3D)");
@@ -225,7 +228,7 @@ namespace
225228
{ // downscale each image separately
226229
CAGE_LOG(SeverityEnum::Info, "assetProcessor", Stringizer() + "downscaling each slice separately");
227230
for (auto &it : images.parts)
228-
imageResize(+it.image, max(it.image->width() / downscale, 1u), max(it.image->height() / downscale, 1u));
231+
imageResize(+it.image, update(it.image->width()), update(it.image->height()));
229232
}
230233
}
231234

@@ -355,8 +358,9 @@ namespace
355358
for (const auto &layer : face.second)
356359
size += layer.second->data.size();
357360

361+
const uint32 faces = level.second.size();
358362
const uint32 layers = level.second.at(0).size();
359-
ser << Vec3i(level.second.at(0).at(0)->resolution, layers);
363+
ser << Vec3i(level.second.at(0).at(0)->resolution, faces * layers);
360364
ser << size;
361365
for (const auto &face : level.second)
362366
for (const auto &layer : face.second)
@@ -386,8 +390,9 @@ namespace
386390
for (const auto &layer : face.second)
387391
size += layer.second->rawViewU8().size();
388392

393+
const uint32 faces = level.second.size();
389394
const uint32 layers = level.second.at(0).size();
390-
ser << Vec3i(level.second.at(0).at(0)->resolution(), layers);
395+
ser << Vec3i(level.second.at(0).at(0)->resolution(), faces * layers);
391396
ser << size;
392397
for (const auto &face : level.second)
393398
for (const auto &layer : face.second)

0 commit comments

Comments
 (0)