|
@@ -12,6 +12,8 @@ export interface Material {
|
|
|
metalness: number,
|
|
|
/** Normalized to [0, 1] range */
|
|
|
roughness: number
|
|
|
+ /** Normalized to [0, 1] range */
|
|
|
+ bumpiness: number
|
|
|
}
|
|
|
|
|
|
export function Material(values?: Partial<Material>) {
|
|
@@ -19,29 +21,31 @@ export function Material(values?: Partial<Material>) {
|
|
|
}
|
|
|
|
|
|
export namespace Material {
|
|
|
- export const Zero: Material = { metalness: 0, roughness: 0 };
|
|
|
+ export const Zero: Material = { metalness: 0, roughness: 0, bumpiness: 0 };
|
|
|
|
|
|
export function toArray(material: Material, array: NumberArray, offset: number) {
|
|
|
array[offset] = material.metalness * 255;
|
|
|
array[offset + 1] = material.roughness * 255;
|
|
|
+ array[offset + 2] = material.bumpiness * 255;
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
- export function toString({ metalness, roughness }: Material) {
|
|
|
- return `M ${metalness.toFixed(2)} | R ${roughness.toFixed(2)}`;
|
|
|
+ export function toString({ metalness, roughness, bumpiness }: Material) {
|
|
|
+ return `M ${metalness.toFixed(2)} | R ${roughness.toFixed(2)} | B ${bumpiness.toFixed(2)}`;
|
|
|
}
|
|
|
|
|
|
export function getParam(info?: { isExpanded?: boolean, isFlat?: boolean }) {
|
|
|
return PD.Group({
|
|
|
metalness: PD.Numeric(0, { min: 0, max: 1, step: 0.01 }),
|
|
|
roughness: PD.Numeric(1, { min: 0, max: 1, step: 0.01 }),
|
|
|
+ bumpiness: PD.Numeric(0, { min: 0, max: 1, step: 0.01 }),
|
|
|
}, {
|
|
|
...info,
|
|
|
presets: [
|
|
|
- [{ metalness: 0, roughness: 1 }, 'Matte'],
|
|
|
- [{ metalness: 0, roughness: 0.2 }, 'Plastic'],
|
|
|
- [{ metalness: 0, roughness: 0.6 }, 'Glossy'],
|
|
|
- [{ metalness: 1.0, roughness: 0.6 }, 'Metallic'],
|
|
|
+ [{ metalness: 0, roughness: 1, bumpiness: 0 }, 'Matte'],
|
|
|
+ [{ metalness: 0, roughness: 0.2, bumpiness: 0 }, 'Plastic'],
|
|
|
+ [{ metalness: 0, roughness: 0.6, bumpiness: 0 }, 'Glossy'],
|
|
|
+ [{ metalness: 1.0, roughness: 0.6, bumpiness: 0 }, 'Metallic'],
|
|
|
]
|
|
|
});
|
|
|
}
|