Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

raea character: a head worn as a part drawn as skin; the skin shader compiles with its tile off

shinyobjectz673479e573d8
diff --git a/sdk/character/src/character/drawing.tsx b/sdk/character/src/character/drawing.tsx
index 71fb7944..241226f1 100644
--- a/sdk/character/src/character/drawing.tsx
+++ b/sdk/character/src/character/drawing.tsx
@@ -133,6 +133,10 @@ export interface CharacterPart {
morphs?: Record<string, number>;
/** its cloth: a baked simulation of its vertices in its bind pose and the frame drawn (<Model cloth>, docs/cloth.md) */
cloth?: { src: string; frame: number };
+ /** its "skin" material's settings over the Character's `skin` (its maps and the fine relief's scale are its own: a
+ * head's UVs aren't the body's), drawn when the Character's `skin` is on. A head part (one with eye joints) is drawn
+ * as skin then without it, with the Character's settings and maps beside its own glb */
+ skin?: Exclude<CharacterProps["skin"], boolean | undefined>;
/** <MeshStandardMaterial> re-covering its materials, as the body's children do */
children?: ReactNode;
}
@@ -229,9 +233,12 @@ export function Character(props: CharacterProps) {
const head = part.joints?.some((j) => j === "LeftEye" || j === "eye_l") ?? false;
const lids = props.gaze && head ? lidsFor(skel, p) : 0;
const pm = lids > 0 ? { ...part.morphs, blink_left: Math.min(1, (part.morphs?.blink_left ?? 0) + lids), blink_right: Math.min(1, (part.morphs?.blink_right ?? 0) + lids) } : part.morphs;
+ // (a head worn as a part is the skin most seen: drawn as the body's is, or its face was plain plastic, 11-17)
+ const sk = props.skin && !ghost && (part.skin || head) ? { ...(typeof props.skin === "object" ? props.skin : {}), ...part.skin } : undefined;
return (
<Model key={id} name={`${name}-${id}`} src={part.src} bones={part.joints ? Object.fromEntries(part.joints.filter((j) => j in bones).map((j) => [j, bones[j]])) : bones} scale={k} {...(glitch ? { glitch } : {})} {...pass} {...(pm && Object.keys(pm).length ? { morphs: pm } : {})} {...(part.cloth ? { cloth: part.cloth } : {})}>
{head && !ghost && cornea()}
+ {sk && skinMaterial(sk, part.src.replace(/\/[^/]*$/, ""))}
{part.children}
{id.includes("hair") && props.hair !== false && hairMaterial(props.hair)}
</Model>
diff --git a/sdk/character/src/character/skin.ts b/sdk/character/src/character/skin.ts
index b1579e71..17687500 100644
--- a/sdk/character/src/character/skin.ts
+++ b/sdk/character/src/character/skin.ts
@@ -46,9 +46,13 @@ fn surface(in: VertexOutput, pbr: ptr<function, PbrInput>) {
let dtex = skin_stored(textureSample(tex_detail, samp_detail, in.uv).rgb) * 2.0 - 1.0;
// (the shader's textures share one sampler, which clamps: the tile wraps by fract, its mip level kept from the
// unwrapped coordinates' derivatives, so no seam line where it wraps)
+ // (@if takes the one statement after it: with the tile off (microMap: false), mtex and grain read an msamp that
+ // was never declared, and the shader didn't compile, 11-17)
@if(SKIN_MICRO)
let msamp = textureSampleGrad(tex_micro, samp_micro, fract(p), dq1, dq2);
+@if(SKIN_MICRO)
let mtex = skin_stored(msamp.rgb) * 2.0 - 1.0;
+@if(SKIN_MICRO)
let grain = msamp.a * 2.0 - 1.0; // (alpha is never colour-decoded)
var N = normalize((*pbr).N);
// the directions in which u and v grow on the surface (Schuler, "Normal Mapping Without Precomputed Tangents"),