-
Notifications
You must be signed in to change notification settings - Fork 5
Material Usage
Yuki Shimada edited this page Dec 3, 2022
·
4 revisions
Rhodonite has many material classes. To generate them, use the MaterialHelper object.
const material = Rn.MaterialHelper.createPbrUberMaterial()
Shader parameters are done for the Material class that holds the shader.
material.setParameter(Rn.ShaderSemantics.BaseColorFactor, Rn.Vector4.fromCopy4(1, 1, 1, 1));
To pass the texture to the shader, do the following
material.setTextureParameter(Rn.ShaderSemantics.BaseColorTexture, rnTexture);
The created materials can be used in Primitive and MeshHelper class methods.
const primitive = Rn.Primitive.createPrimitive({
indices: indices,
attributeSemantics: [Rn.VertexAttribute.Position.XYZ],
attributes: [positions],
primitiveMode: Rn.PrimitiveMode.Lines,
});
primitive.material = mateiral;
const sphere = Rn.MeshHelper.createSphere({
radius: 1,
widthSegments: 10,
heightSegments: 10,
material: material
})