Skip to content

Commit 94a1949

Browse files
committed
gltf node input port descriptions
1 parent ca4841e commit 94a1949

File tree

4 files changed

+40
-72
lines changed

4 files changed

+40
-72
lines changed

formats/gltf/nodes.go

Lines changed: 33 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,15 @@ func (gmnd TextureNodeData) Description() string {
143143

144144
type MaterialNode = nodes.Struct[MaterialNodeData]
145145

146+
// https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-material
147+
146148
type MaterialNodeData struct {
147-
Color nodes.Output[coloring.WebColor]
148-
ColorTexture nodes.Output[string]
149-
MetallicFactor nodes.Output[float64]
150-
RoughnessFactor nodes.Output[float64]
151-
MetallicRoughnessTexture nodes.Output[string]
152-
EmissiveFactor nodes.Output[coloring.WebColor]
149+
Color nodes.Output[coloring.WebColor] `description:"The factors for the base color of the material. This value defines linear multipliers for the sampled texels of the base color texture."`
150+
ColorTexture nodes.Output[string] `description:"The base color texture. The first three components (RGB) MUST be encoded with the sRGB transfer function. They specify the base color of the material. If the fourth component (A) is present, it represents the linear alpha coverage of the material. Otherwise, the alpha coverage is equal to 1.0. The material.alphaMode property specifies how alpha is interpreted. The stored texels MUST NOT be premultiplied. When undefined, the texture MUST be sampled as having 1.0 in all components."`
151+
MetallicFactor nodes.Output[float64] `description:"The factor for the metalness of the material. This value defines a linear multiplier for the sampled metalness values of the metallic-roughness texture."`
152+
RoughnessFactor nodes.Output[float64] `description:"The factor for the roughness of the material. This value defines a linear multiplier for the sampled roughness values of the metallic-roughness texture."`
153+
MetallicRoughnessTexture nodes.Output[string] `description:"The metallic-roughness texture. The metalness values are sampled from the B channel. The roughness values are sampled from the G channel. These values MUST be encoded with a linear transfer function. If other channels are present (R or A), they MUST be ignored for metallic-roughness calculations. When undefined, the texture MUST be sampled as having 1.0 in G and B components."`
154+
EmissiveFactor nodes.Output[coloring.WebColor] `description:"The factors for the emissive color of the material. This value defines linear multipliers for the sampled texels of the emissive texture."`
153155

154156
// Extensions
155157
IndexOfRefraction nodes.Output[float64]
@@ -256,88 +258,64 @@ type MaterialTransmissionExtensionNodeData struct {
256258
Texture nodes.Output[PolyformTexture] `description:"A texture that defines the transmission percentage of the surface, stored in the R channel. This will be multiplied by transmissionFactor."`
257259
}
258260

259-
func (gmvend MaterialTransmissionExtensionNodeData) Out() nodes.StructOutput[PolyformTransmission] {
260-
transmission := PolyformTransmission{}
261-
262-
if gmvend.Factor != nil {
263-
transmission.Factor = gmvend.Factor.Value()
261+
func (node MaterialTransmissionExtensionNodeData) Out() nodes.StructOutput[PolyformTransmission] {
262+
transmission := PolyformTransmission{
263+
Factor: nodes.TryGetOutputValue(node.Factor, 0.),
264264
}
265265

266-
if gmvend.Texture != nil {
267-
v := gmvend.Texture.Value()
266+
if node.Texture != nil {
267+
v := node.Texture.Value()
268268
transmission.Texture = &v
269269
}
270270

271271
return nodes.NewStructOutput(transmission)
272272
}
273273

274-
func (gmvend MaterialTransmissionExtensionNodeData) Description() string {
274+
func (node MaterialTransmissionExtensionNodeData) Description() string {
275275
return "The KHR_materials_transmission extension provides a way to define glTF 2.0 materials that are transparent to light in a physically plausible way. That is, it enables the creation of transparent materials that absorb, reflect and transmit light depending on the incident angle and the wavelength of light. Common uses cases for thin-surface transmissive materials include plastics and glass."
276276
}
277277

278278
type MaterialVolumeExtensionNode = nodes.Struct[MaterialVolumeExtensionNodeData]
279279

280280
type MaterialVolumeExtensionNodeData struct {
281-
ThicknessFactor nodes.Output[float64]
282-
AttenuationDistance nodes.Output[float64]
283-
AttenuationColor nodes.Output[coloring.WebColor]
281+
ThicknessFactor nodes.Output[float64] `description:"The thickness of the volume beneath the surface. The value is given in the coordinate space of the mesh. If the value is 0 the material is thin-walled. Otherwise the material is a volume boundary. The doubleSided property has no effect on volume boundaries. Range is [0, +inf)."`
282+
AttenuationDistance nodes.Output[float64] `description:"Density of the medium given as the average distance that light travels in the medium before interacting with a particle. The value is given in world space. Range is (0, +inf)."`
283+
AttenuationColor nodes.Output[coloring.WebColor] `description:"The color that white light turns into due to absorption when reaching the attenuation distance."`
284284
}
285285

286-
func (gmvend MaterialVolumeExtensionNodeData) Out() nodes.StructOutput[PolyformVolume] {
287-
var thickness float64
286+
func (node MaterialVolumeExtensionNodeData) Out() nodes.StructOutput[PolyformVolume] {
288287
var attenutationDistance *float64
289-
attenuationColor := coloring.White()
290-
291-
if gmvend.ThicknessFactor != nil {
292-
thickness = gmvend.ThicknessFactor.Value()
293-
}
294-
295-
if gmvend.AttenuationDistance != nil {
296-
v := gmvend.AttenuationDistance.Value()
288+
if node.AttenuationDistance != nil {
289+
v := node.AttenuationDistance.Value()
297290
attenutationDistance = &v
298291
}
299292

300-
if gmvend.AttenuationColor != nil {
301-
attenuationColor = gmvend.AttenuationColor.Value()
302-
}
303-
304293
return nodes.NewStructOutput(PolyformVolume{
305-
ThicknessFactor: thickness,
306-
AttenuationColor: attenuationColor,
294+
ThicknessFactor: nodes.TryGetOutputValue(node.ThicknessFactor, 0),
295+
AttenuationColor: nodes.TryGetOutputValue(node.AttenuationColor, coloring.White()),
307296
AttenuationDistance: attenutationDistance,
308297
})
309298
}
310299

311-
func (gmvend MaterialVolumeExtensionNodeData) Description() string {
300+
func (node MaterialVolumeExtensionNodeData) Description() string {
312301
return "By default, a glTF 2.0 material describes the scattering properties of a surface enclosing an infinitely thin volume. The surface defined by the mesh represents a thin wall. The volume extension makes it possible to turn the surface into an interface between volumes. The mesh to which the material is attached defines the boundaries of an homogeneous medium and therefore must be manifold. Volumes provide effects like refraction, absorption and scattering. Scattering is not subject of this extension."
313302
}
314303

315304
type MaterialAnisotropyExtensionNode = nodes.Struct[MaterialAnisotropyExtensionNodeData]
316305

317306
type MaterialAnisotropyExtensionNodeData struct {
318-
AnisotropyStrength nodes.Output[float64]
319-
AnisotropyRotation nodes.Output[float64]
307+
AnisotropyStrength nodes.Output[float64] `description:"The anisotropy strength. When the anisotropy texture is present, this value is multiplied by the texture's blue channel."`
308+
AnisotropyRotation nodes.Output[float64] `description:"The rotation of the anisotropy in tangent, bitangent space, measured in radians counter-clockwise from the tangent. When the anisotropy texture is present, this value provides additional rotation to the vectors in the texture."`
320309
}
321310

322-
func (gmvend MaterialAnisotropyExtensionNodeData) Out() nodes.StructOutput[PolyformAnisotropy] {
323-
var strength float64
324-
var rotation float64
325-
326-
if gmvend.AnisotropyStrength != nil {
327-
strength = gmvend.AnisotropyStrength.Value()
328-
}
329-
330-
if gmvend.AnisotropyRotation != nil {
331-
rotation = gmvend.AnisotropyRotation.Value()
332-
}
333-
311+
func (node MaterialAnisotropyExtensionNodeData) Out() nodes.StructOutput[PolyformAnisotropy] {
334312
return nodes.NewStructOutput(PolyformAnisotropy{
335-
AnisotropyStrength: strength,
336-
AnisotropyRotation: rotation,
313+
AnisotropyStrength: nodes.TryGetOutputValue(node.AnisotropyStrength, 0),
314+
AnisotropyRotation: nodes.TryGetOutputValue(node.AnisotropyRotation, 0),
337315
})
338316
}
339317

340-
func (gmvend MaterialAnisotropyExtensionNodeData) Description() string {
318+
func (node MaterialAnisotropyExtensionNodeData) Description() string {
341319
return "This extension defines the anisotropic property of a material as observable with brushed metals for example. An asymmetric specular lobe model is introduced to allow for such phenomena. The visually distinct feature of that lobe is the elongated appearance of the specular reflection."
342320
}
343321

@@ -348,24 +326,13 @@ type MaterialClearcoatExtensionNodeData struct {
348326
ClearcoatRoughnessFactor nodes.Output[float64]
349327
}
350328

351-
func (gmcend MaterialClearcoatExtensionNodeData) Out() nodes.StructOutput[PolyformClearcoat] {
352-
var strength float64
353-
var rotation float64
354-
355-
if gmcend.ClearcoatFactor != nil {
356-
strength = gmcend.ClearcoatFactor.Value()
357-
}
358-
359-
if gmcend.ClearcoatRoughnessFactor != nil {
360-
rotation = gmcend.ClearcoatRoughnessFactor.Value()
361-
}
362-
329+
func (node MaterialClearcoatExtensionNodeData) Out() nodes.StructOutput[PolyformClearcoat] {
363330
return nodes.NewStructOutput(PolyformClearcoat{
364-
ClearcoatFactor: strength,
365-
ClearcoatRoughnessFactor: rotation,
331+
ClearcoatFactor: nodes.TryGetOutputValue(node.ClearcoatFactor, 0),
332+
ClearcoatRoughnessFactor: nodes.TryGetOutputValue(node.ClearcoatRoughnessFactor, 0),
366333
})
367334
}
368335

369-
func (gmcend MaterialClearcoatExtensionNodeData) Description() string {
336+
func (node MaterialClearcoatExtensionNodeData) Description() string {
370337
return "A clear coat is a common technique used in Physically-Based Rendering to represent a protective layer applied to a base material."
371338
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"typescript": "^4.7.4"
3535
},
3636
"dependencies": {
37-
"@elicdavis/node-flow": "^0.1.2",
37+
"@elicdavis/node-flow": "^0.1.3",
3838
"@mkkellogg/gaussian-splats-3d": "^0.4.7",
3939
"@types/three": "^0.174.0",
4040
"three": "^0.174.0"

website/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export interface NodeOutput {
22
type: string;
3+
description?: string;
34
}
45

56
export interface NodeInput {
67
type: string;
78
isArray: boolean;
8-
description: string;
9+
description?: string;
910
}
1011

1112
export interface NodeType {

0 commit comments

Comments
 (0)