mirror of
https://github.com/storytold/spark.git
synced 2026-10-17 00:12:59 +00:00
Add modifiers normalColor and depthColor. Add examples/debug-color to show how to use them on SplatMeshes. (#58)
This commit is contained in:
committed by
GitHub
parent
a83c99eb86
commit
690e09ac95
@@ -70,6 +70,13 @@ export const hashVec4 = <T extends ValueTypes>(
|
||||
): DynoVal<"vec4"> => {
|
||||
return new HashVec4({ value });
|
||||
};
|
||||
export const normalizedDepth = (
|
||||
z: DynoVal<"float">,
|
||||
zNear: DynoVal<"float">,
|
||||
zFar: DynoVal<"float">,
|
||||
): DynoVal<"float"> => {
|
||||
return new NormalizedDepth({ z, zNear, zFar }).outputs.depth;
|
||||
};
|
||||
|
||||
export class DynoRemapIndex
|
||||
extends Dyno<{ from: "int"; to: "int"; index: "int" }, { index: "int" }>
|
||||
@@ -404,3 +411,31 @@ export class HashVec4<T extends ValueTypes>
|
||||
return new DynoOutput(this, "hash");
|
||||
}
|
||||
}
|
||||
|
||||
export class NormalizedDepth
|
||||
extends Dyno<
|
||||
{ z: "float"; zNear: "float"; zFar: "float" },
|
||||
{ depth: "float" }
|
||||
>
|
||||
implements HasDynoOut<"float">
|
||||
{
|
||||
constructor({
|
||||
z,
|
||||
zNear,
|
||||
zFar,
|
||||
}: { z: DynoVal<"float">; zNear: DynoVal<"float">; zFar: DynoVal<"float"> }) {
|
||||
super({
|
||||
inTypes: { z: "float", zNear: "float", zFar: "float" },
|
||||
outTypes: { depth: "float" },
|
||||
inputs: { z, zNear, zFar },
|
||||
statements: ({ inputs, outputs }) => [
|
||||
`float clamped = clamp(${inputs.z}, ${inputs.zNear}, ${inputs.zFar});`,
|
||||
`${outputs.depth} = (log2(clamped + 1.0) - log2(${inputs.zNear} + 1.0)) / (log2(${inputs.zFar} + 1.0) - log2(${inputs.zNear} + 1.0));`,
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
dynoOut(): DynoValue<"float"> {
|
||||
return new DynoOutput(this, "depth");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user