8#include "graphics/shaders/mesh3d_toon_frag_spv.inc"
9#include "graphics/shaders/mesh3d_toon_vert_spv.inc"
11#include "stylize/shaders/anime_mesh_frag_spv.inc"
12#include "stylize/shaders/anime_mesh_wgsl.inc"
13#include "stylize/shaders/cartoon_post_frag_spv.inc"
14#include "stylize/shaders/impasto_mesh_frag_spv.inc"
15#include "stylize/shaders/impasto_mesh_vert_spv.inc"
16#include "stylize/shaders/impasto_mesh_wgsl.inc"
17#include "stylize/shaders/ink_mesh_frag_spv.inc"
18#include "stylize/shaders/ink_post_frag_spv.inc"
19#include "stylize/shaders/pixel_post_frag_spv.inc"
20#include "stylize/shaders/stylize_mesh_vert_spv.inc"
21#include "stylize/shaders/watercolor_post_frag_spv.inc"
22#include "stylize/shaders/xray_mesh_frag_spv.inc"
23#include "stylize/shaders/ysa_mesh_frag_spv.inc"
24#include "stylize/shaders/ysa_mesh_wgsl.inc"
34const std::array<StyleDefinition, 8> kStyles = {{
45std::vector<uint32_t> copySpv(
const uint32_t *data,
size_t count) {
46 return std::vector<uint32_t>(data, data +
count);
53const char *kXrayMeshVertWgsl = R
"wgsl(
55 @location(0) pos: vec3f,
56 @location(1) normal: vec3f,
57 @location(2) uv: vec2f,
71 lights: array<Light3D, 8>,
78 @builtin(position) pos: vec4f,
79 @location(0) vNormal: vec3f,
80 @location(1) vUV: vec2f,
81 @location(2) vTint: vec4f,
82 @location(3) vWorldPos: vec3f,
83 @location(4) vCameraPos: vec3f,
85@group(0) @binding(0) var<uniform> ubo: Frame;
86fn inverse3x3(m: mat3x3f) -> mat3x3f {
87 let a = m[0].x; let b = m[1].x; let c = m[2].x;
88 let d = m[0].y; let e = m[1].y; let f = m[2].y;
89 let g = m[0].z; let h = m[1].z; let i = m[2].z;
90 let det = a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g);
92 vec3f((e * i - f * h) / det, (f * g - d * i) / det, (d * h - e * g) / det),
93 vec3f((c * h - b * i) / det, (a * i - c * g) / det, (b * g - a * h) / det),
94 vec3f((b * f - c * e) / det, (c * d - a * f) / det, (a * e - b * d) / det),
98fn vs_main(in: VSIn) -> VSOut {
100 out.pos = ubo.mvp * vec4f(in.pos, 1.0);
101 let world = ubo.model * vec4f(in.pos, 1.0);
102 out.vWorldPos = world.xyz;
103 let nrm = transpose(inverse3x3(mat3x3f(ubo.model[0].xyz, ubo.model[1].xyz, ubo.model[2].xyz))) * in.normal;
104 out.vNormal = normalize(nrm);
106 out.vTint = ubo.tint;
107 out.vCameraPos = ubo.cameraPos.xyz;
112const char *kXrayMeshFragWgsl = R
"wgsl(
125 lights: array<Light3D, 8>,
132 @location(0) vNormal: vec3f,
133 @location(1) vUV: vec2f,
134 @location(2) vTint: vec4f,
135 @location(3) vWorldPos: vec3f,
136 @location(4) vCameraPos: vec3f,
138@group(0) @binding(0) var<uniform> ubo: Frame;
139@group(0) @binding(7) var mainSamp: sampler;
140@group(0) @binding(9) var sceneDepth: texture_depth_2d;
143 @location(0) color: vec4f,
147fn fs_main(in: FSIn, @builtin(position) fragPos: vec4f) -> FSOut {
148 let color = ubo.texBomb.xyz;
149 let alpha = clamp(ubo.texBomb.w, 0.0, 1.0);
150 let bias = max(ubo.parallax.x, 0.0);
151 let screenW = max(ubo.parallax.y, 1.0);
152 let screenH = max(ubo.parallax.z, 1.0);
153 let rimStrength = clamp(ubo.parallax.w, 0.0, 1.0);
154 let rimPower = max(ubo.clipInfo.z, 0.1);
156 let uv = fragPos.xy / vec2f(screenW, screenH);
157 let sceneZ = textureSampleLevel(sceneDepth, mainSamp, uv, 0.0);
158 let charZ = fragPos.z;
159 let occ = smoothstep(sceneZ, sceneZ + bias, charZ);
163 let N = normalize(in.vNormal);
164 let V = normalize(in.vCameraPos - in.vWorldPos);
165 let rim = pow(clamp(1.0 - max(dot(N, V), 0.0), 0.0, 1.0), rimPower);
166 let edge = mix(1.0, rim, rimStrength);
168 out.color = vec4f(color, alpha * edge * occ);
176 const auto it = std::find_if(kStyles.begin(), kStyles.end(), [&](
const StyleDefinition &def) {
177 return style == def.id;
179 if (it != kStyles.end())
return &*it;
188 if (
index < 0)
return {};
189 if (
index <
int(kStyles.size()))
return kStyles[size_t(
index)].id;
195 if (!def)
return false;
196 if (feature ==
"post")
return def->
post;
197 if (feature ==
"mesh")
return def->
mesh;
198 if (feature ==
"cpu")
return def->
cpu;
199 if (feature ==
"depth")
return def->
depth;
200 if (feature ==
"normal")
return def->
normal;
201 if (feature ==
"gbuffer")
return def->
depth || def->
normal;
207const StyleParameterDesc kImpastoParams[] = {
208 {
"strokeScale", 0.65f, 0.1f, 32.0f},
209 {
"normalStrength", 0.88f, 0.0f, 3.0f},
210 {
"colorVariation", 0.32f, 0.0f, 0.8f},
211 {
"parallax", 0.06f, 0.0f, 0.15f},
212 {
"reflectionStrength", 0.78f, 0.0f, 2.0f},
213 {
"sdfShadowStrength", 0.0f, 0.0f, 1.0f},
214 {
"shadowR", 0.24f, 0.0f, 1.0f},
215 {
"shadowG", 0.18f, 0.0f, 1.0f},
216 {
"shadowB", 0.48f, 0.0f, 1.0f},
217 {
"rimStrength", 0.7f, 0.0f, 3.0f},
218 {
"rimErosion", 0.8f, 0.0f, 1.0f},
219 {
"packedBrush", 0.0f, 0.0f, 1.0f},
220 {
"layer", 0.0f, 0.0f, 3.0f},
221 {
"shellWidth", 0.045f, 0.0f, 0.2f},
222 {
"shellOffset", 0.0f, -0.2f, 0.2f},
223 {
"smoothNormalMode", 0.0f, 0.0f, 2.0f},
224 {
"occlusionStrength", 0.0f, 0.0f, 1.0f},
225 {
"occlusionRadius", 0.8f, 0.01f, 4.0f},
226 {
"sdfFloorY", 0.0f, -1000.0f, 1000.0f},
227 {
"sdfOwner", 0.0f, 0.0f, 4.0f},
228 {
"sdfSphereAX", 0.0f, -1000.0f, 1000.0f},
229 {
"sdfSphereAY", 0.0f, -1000.0f, 1000.0f},
230 {
"sdfSphereAZ", 0.0f, -1000.0f, 1000.0f},
231 {
"sdfSphereASize", 0.0f, 0.0f, 1000.0f},
232 {
"sdfSphereBX", 0.0f, -1000.0f, 1000.0f},
233 {
"sdfSphereBY", 0.0f, -1000.0f, 1000.0f},
234 {
"sdfSphereBZ", 0.0f, -1000.0f, 1000.0f},
235 {
"sdfSphereBSize", 0.0f, 0.0f, 1000.0f},
236 {
"sdfBoxX", 0.0f, -1000.0f, 1000.0f},
237 {
"sdfBoxY", 0.0f, -1000.0f, 1000.0f},
238 {
"sdfBoxZ", 0.0f, -1000.0f, 1000.0f},
239 {
"sdfBoxSize", 0.0f, 0.0f, 1000.0f},
241const StyleParameterDesc kYsaParams[] = {
242 {
"lightMidpoint", 0.f, -1.f, 1.f},
243 {
"lightSmoothness", 0.1f, 0.00001f, 1.f},
244 {
"ambientR", 0.254717f, 0.f, 1.f},
245 {
"ambientG", 0.254717f, 0.f, 1.f},
246 {
"ambientB", 0.254717f, 0.f, 1.f},
247 {
"shadowPower", 0.5f, 0.f, 1.f},
248 {
"shadowSmoothness", 1.f, 0.00001f, 1.f},
249 {
"specularStrength", 0.f, 0.f, 4.f},
250 {
"specularMidpoint", 0.9f, -1.f, 1.f},
251 {
"specularSmoothness", 0.1f, 0.00001f, 1.f},
252 {
"specularR", 1.f, 0.f, 4.f},
253 {
"specularG", 1.f, 0.f, 4.f},
254 {
"specularB", 1.f, 0.f, 4.f},
255 {
"rimStrength", 0.f, 0.f, 4.f},
256 {
"rimMidpoint", 0.6f, 0.f, 1.f},
257 {
"rimSmoothness", 0.1f, 0.00001f, 1.f},
258 {
"rimDynamic", 0.5f, 0.f, 1.f},
259 {
"rimR", 1.f, 0.f, 4.f},
260 {
"rimG", 0.f, 0.f, 4.f},
261 {
"rimB", 0.f, 0.f, 4.f},
262 {
"alphaClip", 0.f, 0.f, 1.f},
263 {
"rimHideOnShadow", 1.f, 0.f, 1.f},
264 {
"linearLighting", 0.f, 0.f, 1.f},
266const StyleParameterDesc kAnimeParams[] = {
267 {
"shadowThreshold", -0.08f, -1.f, 1.f},
268 {
"shadowSoftness", 0.035f, 0.001f, 0.5f},
269 {
"shadowStrength", 1.f, 0.f, 1.f},
270 {
"rimStrength", 0.19f, 0.f, 1.f},
271 {
"skin", 0.f, 0.f, 1.f},
272 {
"hair", 0.f, 0.f, 1.f},
273 {
"skinDetail", 1.f, 0.f, 1.f},
274 {
"specularStrength", 0.22f, 0.f, 1.f},
275 {
"specularPower", 32.f, 1.f, 128.f},
276 {
"shadowR", 0.64f, 0.f, 1.f},
277 {
"shadowG", 0.66f, 0.f, 1.f},
278 {
"shadowB", 0.79f, 0.f, 1.f},
279 {
"fillGradient", 0.08f, 0.f, 1.f},
280 {
"unlit", 0.f, 0.f, 1.f},
281 {
"surfaceSpecular", 0.f, 0.f, 1.f},
282 {
"castShadowStrength", 1.f, 0.f, 1.f},
284const StyleParameterDesc kCartoonParams[] = {
285 {
"bands", 3.f, 1.f, 16.f}, {
"outlineStrength", 1.15f, 0.f, 4.f},
286 {
"outlineThreshold", 0.12f, 0.f, 1.f}, {
"posterize", 5.f, 1.f, 32.f},
287 {
"softEdge", 0.08f, 0.f, 1.f}, {
"outlineWidth", 1.5f, 0.5f, 8.f},
288 {
"shadowLift", 0.12f, 0.f, 1.f}, {
"rimPower", 2.8f, 0.1f, 16.f},
289 {
"rimStrength", 0.55f, 0.f, 2.f},
291const StyleParameterDesc kWatercolorParams[] = {
292 {
"blurAmount", 2.4f, 0.f, 12.f}, {
"edgeDarken", 2.f, 0.f, 5.f},
293 {
"paperStrength", 0.65f, 0.f, 1.f}, {
"distortion", 0.85f, 0.f, 3.f},
294 {
"bleed", 0.62f, 0.f, 1.f}, {
"saturation", 0.9f, 0.f, 2.f},
295 {
"granulation", 0.65f, 0.f, 1.f},
297const StyleParameterDesc kInkParams[] = {
298 {
"inkContrast", 1.35f, 0.f, 4.f}, {
"washLevels", 5.f, 1.f, 16.f},
299 {
"edgeThreshold", 0.18f, 0.f, 1.f}, {
"diffusion", 3.5f, 0.f, 12.f},
300 {
"paperR", 0.96f, 0.f, 1.f}, {
"paperG", 0.93f, 0.f, 1.f},
301 {
"paperB", 0.86f, 0.f, 1.f}, {
"inkDensity", 0.75f, 0.f, 2.f},
302 {
"edgeStrength", 1.1f, 0.f, 4.f}, {
"contrast", 1.25f, 0.f, 4.f},
303 {
"rimBoost", 0.65f, 0.f, 2.f},
305const StyleParameterDesc kPixelParams[] = {
306 {
"pixelSize", 5.f, 1.f, 64.f}, {
"paletteSteps", 6.f, 2.f, 32.f},
307 {
"ditherStrength", 0.18f, 0.f, 1.f}, {
"toonBands", 3.f, 1.f, 16.f},
308 {
"sharpness", 1.f, 0.f, 2.f}, {
"outline", 0.9f, 0.f, 4.f},
310const StyleParameterDesc kXrayParams[] = {
311 {
"colorR", 1.f, 0.f, 1.f}, {
"colorG", 0.62f, 0.f, 1.f},
312 {
"colorB", 0.12f, 0.f, 1.f}, {
"bias", 0.0002f, 0.f, 0.02f},
313 {
"rimPower", 2.2f, 0.1f, 16.f}, {
"rimStrength", 0.7f, 0.f, 2.f},
314 {
"alpha", 0.82f, 0.f, 1.f},
318const StyleParameterDesc *paramAt(
const StyleParameterDesc (&
params)[N],
int index) {
319 return index < 0 || index >= int(N) ? nullptr : &
params[size_t(
index)];
324 if (style ==
"impasto")
return int(std::size(kImpastoParams));
325 if (style ==
"ysa")
return int(std::size(kYsaParams));
326 if (style ==
"anime")
return int(std::size(kAnimeParams));
327 if (style ==
"cartoon")
return int(
sizeof(kCartoonParams) /
sizeof(kCartoonParams[0]));
328 if (style ==
"watercolor")
return int(
sizeof(kWatercolorParams) /
sizeof(kWatercolorParams[0]));
329 if (style ==
"ink")
return int(
sizeof(kInkParams) /
sizeof(kInkParams[0]));
330 if (style ==
"pixel")
return int(
sizeof(kPixelParams) /
sizeof(kPixelParams[0]));
331 if (style ==
"xray")
return int(
sizeof(kXrayParams) /
sizeof(kXrayParams[0]));
337 return desc ?
desc->id : std::string{};
341 if (style ==
"impasto")
return paramAt(kImpastoParams,
index);
342 if (style ==
"ysa")
return paramAt(kYsaParams,
index);
343 if (style ==
"anime")
return paramAt(kAnimeParams,
index);
344 if (style ==
"cartoon")
return paramAt(kCartoonParams,
index);
345 if (style ==
"watercolor")
return paramAt(kWatercolorParams,
index);
346 if (style ==
"ink")
return paramAt(kInkParams,
index);
347 if (style ==
"pixel")
return paramAt(kPixelParams,
index);
348 if (style ==
"xray")
return paramAt(kXrayParams,
index);
354 for (
int i = 0; i <
count; ++i) {
369 if (style ==
"cartoon") {
370 shader->declareFloat(
"bands");
371 shader->declareFloat(
"outlineStrength");
372 shader->declareFloat(
"outlineThreshold");
373 shader->declareFloat(
"posterize");
374 shader->declareFloat(
"texelW");
375 shader->declareFloat(
"texelH");
376 shader->declareFloat(
"time");
377 shader->declareFloat(
"softEdge");
378 shader->declareFloat(
"outlineWidth");
379 shader->declareFloat(
"shadowLift");
380 shader->sendFloat(
"bands", 3.f);
381 shader->sendFloat(
"outlineStrength", 1.15f);
382 shader->sendFloat(
"outlineThreshold", 0.12f);
383 shader->sendFloat(
"posterize", 5.f);
384 shader->sendFloat(
"texelW", 1.f / 256.f);
385 shader->sendFloat(
"texelH", 1.f / 256.f);
386 shader->sendFloat(
"time", 0.f);
387 shader->sendFloat(
"softEdge", 0.08f);
388 shader->sendFloat(
"outlineWidth", 1.5f);
389 shader->sendFloat(
"shadowLift", 0.12f);
392 if (style ==
"watercolor") {
393 shader->declareFloat(
"blurAmount");
394 shader->declareFloat(
"edgeDarken");
395 shader->declareFloat(
"paperStrength");
396 shader->declareFloat(
"distortion");
397 shader->declareFloat(
"bleed");
398 shader->declareFloat(
"saturation");
399 shader->declareFloat(
"texelW");
400 shader->declareFloat(
"texelH");
401 shader->declareFloat(
"time");
402 shader->declareFloat(
"granulation");
403 shader->sendFloat(
"blurAmount", 2.4f);
404 shader->sendFloat(
"edgeDarken", 2.0f);
405 shader->sendFloat(
"paperStrength", 0.65f);
406 shader->sendFloat(
"distortion", 0.85f);
407 shader->sendFloat(
"bleed", 0.62f);
408 shader->sendFloat(
"saturation", 0.9f);
409 shader->sendFloat(
"texelW", 1.f / 256.f);
410 shader->sendFloat(
"texelH", 1.f / 256.f);
411 shader->sendFloat(
"time", 0.f);
412 shader->sendFloat(
"granulation", 0.65f);
415 if (style ==
"ink") {
416 shader->declareFloat(
"inkContrast");
417 shader->declareFloat(
"washLevels");
418 shader->declareFloat(
"edgeThreshold");
419 shader->declareFloat(
"diffusion");
420 shader->declareFloat(
"paperR");
421 shader->declareFloat(
"paperG");
422 shader->declareFloat(
"paperB");
423 shader->declareFloat(
"inkDensity");
424 shader->declareFloat(
"texelW");
425 shader->declareFloat(
"texelH");
426 shader->declareFloat(
"time");
427 shader->declareFloat(
"edgeStrength");
428 shader->sendFloat(
"inkContrast", 1.35f);
429 shader->sendFloat(
"washLevels", 5.f);
430 shader->sendFloat(
"edgeThreshold", 0.18f);
431 shader->sendFloat(
"diffusion", 3.5f);
432 shader->sendFloat(
"paperR", 0.96f);
433 shader->sendFloat(
"paperG", 0.93f);
434 shader->sendFloat(
"paperB", 0.86f);
435 shader->sendFloat(
"inkDensity", 0.75f);
436 shader->sendFloat(
"texelW", 1.f / 256.f);
437 shader->sendFloat(
"texelH", 1.f / 256.f);
438 shader->sendFloat(
"time", 0.f);
439 shader->sendFloat(
"edgeStrength", 1.1f);
442 if (style ==
"pixel") {
443 shader->declareFloat(
"pixelSize");
444 shader->declareFloat(
"paletteSteps");
445 shader->declareFloat(
"ditherStrength");
446 shader->declareFloat(
"toonBands");
447 shader->declareFloat(
"sharpness");
448 shader->declareFloat(
"texelW");
449 shader->declareFloat(
"texelH");
450 shader->declareFloat(
"time");
451 shader->declareFloat(
"screenW");
452 shader->declareFloat(
"screenH");
453 shader->declareFloat(
"outline");
454 shader->sendFloat(
"pixelSize", 5.f);
455 shader->sendFloat(
"paletteSteps", 6.f);
456 shader->sendFloat(
"ditherStrength", 0.18f);
457 shader->sendFloat(
"toonBands", 3.f);
458 shader->sendFloat(
"sharpness", 1.f);
459 shader->sendFloat(
"texelW", 1.f / 256.f);
460 shader->sendFloat(
"texelH", 1.f / 256.f);
461 shader->sendFloat(
"time", 0.f);
462 shader->sendFloat(
"screenW", 256.f);
463 shader->sendFloat(
"screenH", 256.f);
464 shader->sendFloat(
"outline", 0.9f);
467 throw eve::Exception(
"bindPostUniforms: unknown style '%s'", style.c_str());
472 if (style ==
"impasto") {
473 for (
const auto ¶m : kImpastoParams) {
474 shader->declareFloat(param.id);
475 shader->sendFloat(param.id, param.defaultValue);
479 if (style ==
"ysa") {
480 for (
const auto ¶m : kYsaParams) {
481 shader->declareFloat(param.id);
482 shader->sendFloat(param.id, param.defaultValue);
486 if (style ==
"anime") {
487 for (
const auto ¶m : kAnimeParams) {
488 shader->declareFloat(param.id);
489 shader->sendFloat(param.id, param.defaultValue);
499 if (style ==
"cartoon") {
500 shader->declareFloat(
"bands");
501 shader->declareFloat(
"rimPower");
502 shader->declareFloat(
"rimStrength");
503 shader->declareFloat(
"posterize");
504 shader->sendFloat(
"bands", 4.f);
505 shader->sendFloat(
"rimPower", 2.8f);
506 shader->sendFloat(
"rimStrength", 0.55f);
507 shader->sendFloat(
"posterize", 6.f);
510 if (style ==
"ink") {
511 shader->declareFloat(
"washLevels");
512 shader->declareFloat(
"edgeThreshold");
513 shader->declareFloat(
"inkDensity");
514 shader->declareFloat(
"contrast");
515 shader->declareFloat(
"paperR");
516 shader->declareFloat(
"paperG");
517 shader->declareFloat(
"paperB");
518 shader->declareFloat(
"rimBoost");
519 shader->sendFloat(
"washLevels", 5.f);
520 shader->sendFloat(
"edgeThreshold", 0.35f);
521 shader->sendFloat(
"inkDensity", 0.9f);
522 shader->sendFloat(
"contrast", 1.25f);
523 shader->sendFloat(
"paperR", 0.93f);
524 shader->sendFloat(
"paperG", 0.90f);
525 shader->sendFloat(
"paperB", 0.82f);
526 shader->sendFloat(
"rimBoost", 0.65f);
529 if (style ==
"xray") {
530 shader->declareFloat(
"colorR");
531 shader->declareFloat(
"colorG");
532 shader->declareFloat(
"colorB");
533 shader->declareFloat(
"bias");
534 shader->declareFloat(
"screenW");
535 shader->declareFloat(
"screenH");
536 shader->declareFloat(
"rimPower");
537 shader->declareFloat(
"rimStrength");
538 shader->declareFloat(
"alpha");
539 shader->sendFloat(
"colorR", 1.f);
540 shader->sendFloat(
"colorG", 0.62f);
541 shader->sendFloat(
"colorB", 0.12f);
542 shader->sendFloat(
"bias", 0.0002f);
543 shader->sendFloat(
"screenW", 256.f);
544 shader->sendFloat(
"screenH", 256.f);
545 shader->sendFloat(
"rimPower", 2.2f);
546 shader->sendFloat(
"rimStrength", 0.7f);
547 shader->sendFloat(
"alpha", 0.82f);
550 throw eve::Exception(
"bindMeshUniforms: style '%s' has no mesh shader", style.c_str());
554 if (!gfx)
throw eve::Exception(
"createPostShader: null graphics");
557 if (!def)
throw eve::Exception(
"createPostShader: unknown style '%s'", style.c_str());
559 throw eve::Exception(
"createPostShader: style '%s' has no post technique", style.c_str());
568 throw eve::Exception(
"createPostShader: failed to create '%s' WGSL", style.c_str());
573 std::vector<uint32_t>
frag;
574 if (style ==
"cartoon")
575 frag = copySpv(cartoon_post_frag_spv, cartoon_post_frag_spv_count);
576 else if (style ==
"watercolor")
577 frag = copySpv(watercolor_post_frag_spv, watercolor_post_frag_spv_count);
578 else if (style ==
"ink")
579 frag = copySpv(ink_post_frag_spv, ink_post_frag_spv_count);
581 frag = copySpv(pixel_post_frag_spv, pixel_post_frag_spv_count);
585 throw eve::Exception(
"createPostShader: failed to create '%s'", style.c_str());
591 if (!gfx)
throw eve::Exception(
"createMeshShader: null graphics");
594 if (style ==
"impasto") {
599 copySpv(impasto_mesh_frag_spv, impasto_mesh_frag_spv_count));
601 throw eve::Exception(
"createMeshShader: failed to create impasto mesh shader");
606 if (style ==
"ysa") {
613 copySpv(ysa_mesh_frag_spv, ysa_mesh_frag_spv_count));
619 if (style ==
"anime") {
624 copySpv(anime_mesh_frag_spv, anime_mesh_frag_spv_count));
630 if (style ==
"cartoon") {
638 auto vert = copySpv(stylize_mesh_vert_spv, stylize_mesh_vert_spv_count);
639 auto frag = copySpv(mesh3d_toon_frag_spv, mesh3d_toon_frag_spv_count);
645 if (style ==
"ink") {
650 throw eve::Exception(
"createMeshShader: failed to create ink WGSL");
654 auto vert = copySpv(mesh3d_toon_vert_spv, mesh3d_toon_vert_spv_count);
655 auto frag = copySpv(ink_mesh_frag_spv, ink_mesh_frag_spv_count);
658 throw eve::Exception(
"createMeshShader: failed to create ink mesh shader");
662 if (style ==
"xray") {
667 throw eve::Exception(
"createMeshShader: failed to create xray mesh shader (wgsl)");
672 auto vert = copySpv(mesh3d_toon_vert_spv, mesh3d_toon_vert_spv_count);
673 auto frag = copySpv(xray_mesh_frag_spv, xray_mesh_frag_spv_count);
676 throw eve::Exception(
"createMeshShader: failed to create xray mesh shader");
682 "createMeshShader: style '%s' has no mesh variant (use watercolor/pixel as post)",
EVENGINE_API_FOUNDATION public API.
virtual std::string getBackendName() const =0
Renderer backend id used by sibling modules (e.g. Gpgpu).
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
virtual Shader * newShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a 2D custom shader from WGSL source (WebGPU backend). Empty vert → default textured vertex sha...
virtual Shader * newShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a custom 2D shader from SPIR-V words (vert + frag). Owned by Graphics. Vertex stage may be emp...
virtual Shader * newMeshShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a Mesh3D custom shader from WGSL source (WebGPU backend). The WGSL must declare the engine's F...
void setXray(bool x)
X-ray mesh shader. When true, drawMeshShader renders this mesh a second pass over the already-lit sce...
constexpr const char * kPixel
constexpr const char * kWatercolor
constexpr const char * kCommon
constexpr const char * kInk
constexpr const char * kMeshCommon
constexpr const char * kCartoon
constexpr const char * kInkMesh
constexpr const char * kCartoonMesh
graphics::Shader * createMeshShader(graphics::Graphics *gfx, const std::string &style)
Creates mesh shader.
void bindEffectMeshUniforms(graphics::Shader *shader, const std::string &style)
Binds effect mesh uniforms.
graphics::Shader * createEffectMeshShader(graphics::Graphics *gfx, const std::string &style)
Creates effect mesh shader.
bool styleSupports(const std::string &style, const std::string &feature)
Style supports.
std::string styleIdAt(int index)
Style id at.
bool isEffectStyle(const std::string &style)
True when style names one of the ported effect shaders.
graphics::Shader * createPostShader(graphics::Graphics *gfx, const std::string &style)
Creates post shader.
graphics::Shader * createEffectPostShader(graphics::Graphics *gfx, const std::string &style)
Creates effect post shader.
void bindMeshUniforms(graphics::Shader *shader, const std::string &style)
Binds mesh uniforms.
int effectStyleCount()
Effect style count.
int styleCount()
Style count.
int styleParamCount(const std::string &style)
Style param count.
void bindEffectPostUniforms(graphics::Shader *shader, const std::string &style)
Binds effect post uniforms.
void bindPostUniforms(graphics::Shader *shader, const std::string &style)
Binds post uniforms.
bool isKnownStyle(const std::string &style)
True when known style.
std::string effectStyleIdAt(int index)
Effect style id at.
const StyleDefinition * findEffectDefinition(const std::string &style)
Effect-only StyleDefinition lookup, or nullptr when unknown.
const StyleParameterDesc * findStyleParameter(const std::string &style, const std::string &name)
Finds style parameter.
std::string styleParamName(const std::string &style, int index)
Style param name.
int effectParamCount(const std::string &style)
Effect param count.
const StyleParameterDesc * styleParameterAt(const std::string &style, int index)
Style parameter at.
const StyleParameterDesc * effectParameterAt(const std::string &style, int index)
Effect parameter at.
const StyleDefinition * findStyleDefinition(const std::string &style)
Return a built-in definition, or nullptr when the id is unknown.
Immutable capability metadata for one built-in stylization recipe.
Tooling metadata for one user-facing float parameter.