Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vertex shader generation for draco-compressed RGB per-vertex color #7581

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Change Log
* Fixed an issue where polygons on terrain using rhumb lines where being rendered incorrectly. [#7538](https://github.com/AnalyticalGraphicsInc/cesium/pulls/7538)
* Fixed an issue with `EllipsoidRhumbLines.findIntersectionWithLongitude` when longitude was IDL. [#7551](https://github.com/AnalyticalGraphicsInc/cesium/issues/7551)
* Fixed an issue with ground polylines on globes that use ellipsoids other than WGS84. [#7552](https://github.com/AnalyticalGraphicsInc/cesium/issues/7552)
* Fixed an issue where Draco compressed models with RGB per-vertex color would not load in Cesium. [#7576](https://github.com/AnalyticalGraphicsInc/cesium/issues/7576)

### 1.54 - 2019-02-01

Expand Down
9 changes: 8 additions & 1 deletion Source/Scene/ModelUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,12 @@ define([
}
shader = variableType + ' ' + decodedAttributeVarName + ';\n' + shader;

// The gltf 2.0 COLOR_0 vertex attribute can be VEC4 or VEC3
var vec3Color = size === 3 && attributeSemantic === 'COLOR_0';
if (vec3Color) {
shader = replaceAllButFirstInString(shader, decodedAttributeVarName, 'vec4(' + decodedAttributeVarName + ', 1.0)');
}

// splice decode function into the shader
var decode = '';
if (quantization.octEncoded) {
Expand All @@ -618,9 +624,10 @@ define([
var decodeUniformVarNameMin = decodeUniformVarName + '_min';
shader = 'uniform float ' + decodeUniformVarNameNormConstant + ';\n' +
'uniform ' + variableType + ' ' + decodeUniformVarNameMin + ';\n' + shader;
var attributeVarAccess = vec3Color ? '.xyz' : '';
decode = '\n' +
'void main() {\n' +
' ' + decodedAttributeVarName + ' = ' + decodeUniformVarNameMin + ' + ' + attributeVarName + ' * ' + decodeUniformVarNameNormConstant + ';\n' +
' ' + decodedAttributeVarName + ' = ' + decodeUniformVarNameMin + ' + ' + attributeVarName + attributeVarAccess + ' * ' + decodeUniformVarNameNormConstant + ';\n' +
' ' + newMain + '();\n' +
'}\n';
}
Expand Down
213 changes: 213 additions & 0 deletions Specs/Data/Models/DracoCompression/BoxVertexColorsDracoRGB.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
{
"accessors": [
{
"componentType": 5123,
"count": 36,
"type": "SCALAR"
},
{
"componentType": 5126,
"count": 24,
"type": "VEC3"
},
{
"componentType": 5126,
"count": 24,
"type": "VEC3"
},
{
"componentType": 5126,
"count": 24,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
},
{
"componentType": 5126,
"count": 24,
"type": "VEC2"
}
],
"asset": {
"generator": "FBX2glTF",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 291
}
],
"buffers": [
{
"name": "BoxVertexColorsDracoRGB",
"byteLength": 292,
"uri": "data:application/octet-stream;base64,RFJBQ08CAgEBAAAACAwDCwAAA2+rFAEBEP8CNUFVBEs7K0acBPS3XVcEAAAA/wAAAgEAAQEAAQIJAwAAAgEACQMAAgIBAwkCAAMCAQEJAwABAwEBAQAJDwEIBwEgARgEAHoAggE8LscrycxCBfwIQmx3gBQoA6BlYwAAAAD/AAAAHekGMAjDNTqgF+43Iv5/PwgBAQEAAgMBQAEAoAIIAAAAAP8/AAAAAAC/AAAAvwAAAL8AAIA/DgUBAQANA5UEG20b3RYDJQkFr5XCIE4AsKoACAAApJoqAFOtAqDqVKurAlDVKgCsApDq1KkApgIMAAAAAQLAQAAAAAD/DwAAAAAAAAAAAAAAAIA/DAYDAQEBAQFAAQD/AwAA/wEAAP8CoUEKAA=="
}
],
"materials": [
{
"name": "Default",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.800000011920929,
0.800000011920929,
0.800000011920929,
1
],
"metallicFactor": 0.100000001490116,
"roughnessFactor": 0.990000005960464
},
"emissiveFactor": [
0,
0,
0
],
"alphaMode": "OPAQUE",
"doubleSided": false
}
],
"meshes": [
{
"name": "Cube",
"primitives": [
{
"attributes": {
"COLOR_0": 1,
"NORMAL": 2,
"POSITION": 3,
"TEXCOORD_0": 4
},
"indices": 0,
"material": 0,
"mode": 4,
"extensions": {
"KHR_draco_mesh_compression": {
"bufferView": 0,
"attributes": {
"COLOR_0": 0,
"NORMAL": 1,
"POSITION": 2,
"TEXCOORD_0": 3
}
}
}
}
]
}
],
"nodes": [
{
"children": [
1,
2,
3
],
"name": "RootNode",
"rotation": [
0,
0,
0,
1
],
"scale": [
1,
1,
1
],
"translation": [
0,
0,
0
]
},
{
"name": "Mesh",
"rotation": [
0,
0,
0,
1
],
"scale": [
1,
1,
1
],
"translation": [
0,
0,
0
]
},
{
"mesh": 0,
"name": "Cube",
"rotation": [
0,
0,
0,
1
],
"scale": [
1,
1,
1
],
"translation": [
0,
0,
0
]
},
{
"name": "Texture Group",
"rotation": [
0,
0,
0,
1
],
"scale": [
1,
1,
1
],
"translation": [
0,
0,
0
]
}
],
"samplers": [
{
"wrapS": 10497,
"wrapT": 10497
}
],
"scene": 0,
"scenes": [
{
"name": "Root Scene",
"nodes": [
0
]
}
],
"extensionsRequired": [
"KHR_draco_mesh_compression"
],
"extensionsUsed": [
"KHR_draco_mesh_compression"
]
}
Loading