OGLSkinnedSurfaceShader.kl¶
Types¶
OGLSkinnedSurfaceShader (object)¶
バージョン 1.12.0 で追加.
The OGLSkinnedSurfaceShader inherits the OGLSurfaceShader. It extends the OGLSurfaceShader for shading skinned geometries. The Skinned geometries should have a SkinningAttribute attribute applied containing the vertex ids and skin weights.
The SkinningAttribute attribute is converted to a packed vec4 struct by the InlineDrawing system. Each element in the vec4 packs an index and weight, enabling up to 4 joints per vertex to be used in the deformation.
注釈
The FbxCharacter loads skinning data from Fbx files. See the FbxCharacter.kl file for examples of generating
注釈
For arbitrary number of joints to be used per vertex, use CPU based skinning. And example of this can be found in the Character.
Uniforms¶
Name | Type | Description | Default |
---|---|---|---|
u_light0Position | Vec3 | Position of the first light | Position of the camera |
u_light0Color | Color | Color of the first light | Color(1.0, 1.0, 1.0) |
u_ambientColor | Color | Ambient color component | Color(0.05, 0.05, 0.05) |
u_diffuseColor | Color | Diffuse color component | Color(0.0, 1.0, 0.0) |
u_specularColor | Color | Specular color component | Color(0.2, 0.2, 0.2) |
u_specularFactor | Color | Specular distribution factor | 16.0 |
u_normalIsTangent | Integer | Flag defining normal type | 0 |
u_doubleSided | Integer | Flag defining backface shading model | 0 |
Attributes¶
Name | Type | Description |
---|---|---|
positions | Vec3 | Geometry positions |
normals | Vec3 | Geometry normals |
skinningData | Vec4 | Skinning Data |
/*
** Example: SkinningShader :nooutput: InlineDrawing drawing = OGLInlineDrawing_GetInstance(); DrawingHandle handle(); FbxCharacter fbxCharacter(fbxFile);
*/
InlineShader skinnedSurfaceShader = null;
if(!drawing.hasShader('skinnedSurfaceShader')){
skinnedSurfaceShader = OGLSkinnedSurfaceShader('skinnedSurfaceShader');
drawing.registerShader(skinnedSurfaceShader);
}
else
skinnedSurfaceShader = drawing.getShader('skinnedSurfaceShader');
InlineMaterial characterMaterial = skinnedSurfaceShader.getOrCreateMaterial(fbxCharacter.getName() + "_Material");
characterMaterial.setUniform(InlineUniform('u_diffuseColor', Color(1.0, 0.0, 0.0)));
InlineMatrixArrayTexture poseTexture(fbxCharacter.getName() + "_PoseTexture", fbxCharacter.getSkinningMatrices());
for(Integer geom=0; geom<fbxCharacter.getNumGeometries(); geom++){
InlineMeshShape skinShape(fbxCharacter.getName() + "_" + geom, fbxCharacter.getGeometry(geom));
InlineInstance skinInstance = SimpleInlineInstance(fbxCharacter.getName() + "_" + geom, handle.rootTransform, skinShape, characterMaterial);
skinInstance.setInstanceUniform(InlineUniform('skinningMatrices', poseTexture));
skinInstance.setInstanceUniform(InlineUniform('bindShapeTransform', fbxCharacter.getBindShapeTransform(geom)));
}
// Update the pose of the character before rendering.
ClipPose pose = characters[index].getPose();
pose.evaluate(time);
poseTexture.update(characters[index].getSkinningMatrices());
Methods¶
OGLSkinnedSurfaceShader ( in OGLSkinnedSurfaceShader other ) | |
OGLSkinnedSurfaceShader ( in String name ) | |
OGLSkinnedSurfaceShader () | |
OGLSkinnedSurfaceShader | clone ? () |