-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Add BasisTextureLoader example #16553
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3a33a47
Add BasisTextureLoader example
takahirox 76002f1
Add gamma configuration to BasisTextureLoader example
takahirox 9767cf5
Remove texture.flipY from BasisTextureLoader
takahirox c66f949
Move texture.encoding configuration from BasisTextureLoader to its ex…
takahirox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <title>three.js webgl - basis texture loader</title> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> | ||
| <style> | ||
| body { | ||
| margin: 0px; | ||
| background-color: #050505; | ||
| color: #fff; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| a { color: #e00 } | ||
|
|
||
| #info { | ||
| position: absolute; | ||
| top: 0px; | ||
| width: 100%; | ||
| color: #ffffff; | ||
| padding: 5px; | ||
| font-family: Monospace; | ||
| font-size: 13px; | ||
| text-align: center; | ||
| z-index: 1000; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
|
|
||
| <div id="info"> | ||
| <a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl - basis texture loader<br /> | ||
| <a href="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/binomialLLC/basis_universal" target="_blank">Basis Universal GPU Texture Codec</a> | ||
| </div> | ||
|
|
||
| <script src="../build/three.js"></script> | ||
| <script src="js/loaders/BasisTextureLoader.js"></script> | ||
|
|
||
| <script> | ||
|
|
||
| var camera, scene, renderer; | ||
| var mesh; | ||
|
|
||
| var clock = new THREE.Clock(); | ||
|
|
||
| init(); | ||
| animate(); | ||
|
|
||
| function init() { | ||
|
|
||
| renderer = new THREE.WebGLRenderer( { antialias: true } ); | ||
| renderer.setPixelRatio( window.devicePixelRatio ); | ||
| renderer.setSize( window.innerWidth, window.innerHeight ); | ||
| renderer.gammaOutput = true; | ||
| renderer.gammaFactor = 2.2; | ||
| document.body.appendChild( renderer.domElement ); | ||
|
|
||
| camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 2000 ); | ||
| camera.position.z = 500; | ||
|
|
||
| scene = new THREE.Scene(); | ||
|
|
||
| var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 ); | ||
| var material = new THREE.MeshBasicMaterial(); | ||
|
|
||
| mesh = new THREE.Mesh( geometry, material ); | ||
|
|
||
| scene.add( mesh ); | ||
|
|
||
| var loader = new THREE.BasisTextureLoader(); | ||
| loader.setTranscoderPath( 'js/libs/basis/' ); | ||
| loader.detectSupport( renderer ); | ||
|
|
||
| loader.load( 'textures/compressed/kodim20.basis', function ( texture ) { | ||
|
|
||
| texture.encoding = THREE.sRGBEncoding; | ||
| material.map = texture; | ||
| material.needsUpdate = true; | ||
|
|
||
| } ); | ||
|
|
||
| window.addEventListener( 'resize', onWindowResize, false ); | ||
|
|
||
| } | ||
|
|
||
| function onWindowResize() { | ||
|
|
||
| camera.aspect = window.innerWidth / window.innerHeight; | ||
| camera.updateProjectionMatrix(); | ||
|
|
||
| renderer.setSize( window.innerWidth, window.innerHeight ); | ||
|
|
||
| } | ||
|
|
||
| function animate() { | ||
|
|
||
| requestAnimationFrame( animate ); | ||
|
|
||
| var delta = clock.getDelta() * 0.5; | ||
|
|
||
| mesh.rotation.x += delta; | ||
| mesh.rotation.y += delta; | ||
|
|
||
| renderer.render( scene, camera ); | ||
|
|
||
| } | ||
|
|
||
| </script> | ||
|
|
||
| </body> | ||
| </html> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BasisTextureLoader currently marks all textures as sRGB:
three.js/examples/js/loaders/BasisTextureLoader.js
Lines 144 to 151 in b39de78
We should probably remove that, and the
flipY=falsepreset, which both made sense in the original Basis example but not so much in a general-purpose texture loader.My suggestion for this PR would be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flipY = truedoesn't seem to work for compressed texture and defaultCompressedTexture.flipYisfalse. Removing from the loader looks right direction. Updated.Updated.
Thanks, I missed them. Updated.