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

KHR_texture_transform shouldn't emulate sampler repeat options #8076

Merged
merged 6 commits into from
Aug 16, 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 @@ -7,6 +7,7 @@ Change Log
* Added optional `index` parameter to `PrimitiveCollection.add`. [#8041](https://github.com/AnalyticalGraphicsInc/cesium/pull/8041)

##### Fixes :wrench:
* Fixed a crash when a glTF model used `KHR_texture_transform` without a sampler defined. [#7916](https://github.com/AnalyticalGraphicsInc/cesium/issues/7916)
* Fixed post-processing selection filtering to work for bloom. [#7984](https://github.com/AnalyticalGraphicsInc/cesium/issues/7984)
* Disabled HDR by default to improve visual quality in most standard use cases. Set `viewer.scene.highDynamicRange = true` to re-enable. [#7966](https://github.com/AnalyticalGraphicsInc/cesium/issues/7966)
* Fixed a bug that causes hidden point primitives to still appear on some operating systems. [#8043](https://github.com/AnalyticalGraphicsInc/cesium/issues/8043)
Expand Down
12 changes: 2 additions & 10 deletions Source/Scene/processPbrMaterials.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -551,16 +545,14 @@ 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' +
' cos(rotation) * scale.x, sin(rotation) * scale.x, 0.0, \n' +
' -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';

Expand Down