From a03eec7cd900dafe5b0e39d55045fed84fe45a21 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 15 Aug 2019 11:24:27 -0400 Subject: [PATCH 1/2] KHR_texture_transform shouldn't emulate sampler repeat options. --- Source/Scene/processPbrMaterials.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Source/Scene/processPbrMaterials.js b/Source/Scene/processPbrMaterials.js index 9dd5ec113dc0..865cca3d8cf7 100644 --- a/Source/Scene/processPbrMaterials.js +++ b/Source/Scene/processPbrMaterials.js @@ -90,14 +90,8 @@ define([ function addTextureCoordinates(gltf, textureName, generatedMaterialValues, defaultTexCoord, result) { var texCoord; if (defined(generatedMaterialValues[textureName + 'Offset'])) { - var textureIndex = generatedMaterialValues[textureName].index; - var sampler = gltf.samplers[gltf.textures[textureIndex].sampler]; - - var repeatS = sampler.wrapS === WebGLConstants.REPEAT ? 'true' : 'false'; - var repeatT = sampler.wrapT === WebGLConstants.REPEAT ? 'true' : 'false'; - texCoord = textureName + 'Coord'; - result.fragmentShaderMain += ' vec2 ' + texCoord + ' = computeTexCoord(' + defaultTexCoord + ', ' + textureName + 'Offset, ' + textureName + 'Rotation, ' + textureName + 'Scale, ' + repeatS + ', ' + repeatT + ');\n'; + result.fragmentShaderMain += ' vec2 ' + texCoord + ' = computeTexCoord(' + defaultTexCoord + ', ' + textureName + 'Offset, ' + textureName + 'Rotation, ' + textureName + 'Scale);\n'; } else { texCoord = defaultTexCoord; } @@ -551,7 +545,7 @@ define([ '}\n\n'; fragmentShader += - 'vec2 computeTexCoord(vec2 texCoords, vec2 offset, float rotation, vec2 scale, bool repeatS, bool repeatT) \n' + + 'vec2 computeTexCoord(vec2 texCoords, vec2 offset, float rotation, vec2 scale) \n' + '{\n' + ' rotation = -rotation; \n' + ' mat3 transform = mat3(\n' + @@ -559,8 +553,6 @@ define([ ' -sin(rotation) * scale.y, cos(rotation) * scale.y, 0.0, \n' + ' offset.x, offset.y, 1.0); \n' + ' vec2 transformedTexCoords = (transform * vec3(fract(texCoords), 1.0)).xy; \n' + - ' transformedTexCoords.x = repeatS ? fract(transformedTexCoords.x) : clamp(transformedTexCoords.x, 0.0, 1.0); \n' + - ' transformedTexCoords.y = repeatT ? fract(transformedTexCoords.y) : clamp(transformedTexCoords.y, 0.0, 1.0); \n' + ' return transformedTexCoords; \n' + '}\n\n'; From 7c1736e6303d70f7e669cc753e05f3861aceb8f7 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 15 Aug 2019 11:33:29 -0400 Subject: [PATCH 2/2] CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 316cf359b41b..f3a94113ad6d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ Change Log ##### Fixes :wrench: Disabled HDR by default to improve visual quality in most standard use cases. Set `viewer.scene.highDynamicRange = true` to re-enable it. [#7966](https://github.com/AnalyticalGraphicsInc/cesium/issues/7966) +* Fixed a crash when a glTF model used `KHR_texture_transform` without a sampler defined. [#7916](https://github.com/AnalyticalGraphicsInc/cesium/issues/7916) ### 1.60 - 2019-08-01