tparisi / WebGLBook

Code Examples for Tony Parisi's Book, WebGL Up and Running
520 stars 303 forks source link

earth-shader.js - Does not render ShaderMaterial() #4

Open FullstackJack opened 11 years ago

FullstackJack commented 11 years ago

After updating my Sim.js with the objectIntersects() method call, I was able to get earth-lit.js to work, however, the next example, earth-shader.js, does not render properly. Using the custom ShaderMaterial(), it only renders the clouds. When I switch that chunk of code for a MeshPhongMaterial() as coded in earth-lit.js, I'm able to render the earth surface, of course without specularity and bump map. Something is wrong with the ShaderMaterial() setup. earth-shader js_clouds

jlehto commented 11 years ago

The book's code works if you use the older Three.js in the libs folder. Starting from r50 upwards, it's much simpler, just set the maps as properties of MeshPhongMaterial, like this: var material = new THREE.MeshPhongMaterial({ map: earthSurfaceMap, normalMap: earthNormalMap, specularMap: earthSpecularMap}); that's it, no need of uniforms or computeTangents().