source code from rotating earth shader blog post
Shri

Gio,

I didn't see a download link in your first blog post regarding the rotating earth shader demo.

Is there any way you can post the source code from that ?

If I can see it all in one or two files, it would make it easier to follow how the whole thing goes together.

thanks,

Shri

P.S. tell your wife I thought the first blog post was super cool !

All 2 Comments
Gio

Haha thanks for the comment Shri :)

 

I have added a link right at the bottom of the blog post. It was done in the editor so if you want to look at the source directly without opening in the editor it's not going to be very readable, but essentially it boils down to this:

 

  1. Create a sprite with the earth.jpg texture
  2. Set a custom pixel shader for that sprite (you can do that in code with Sprite.setPixelShader), using the source code provided. Importantly, also set a shader uniform {lightDir: 'vec3'}
  3. The sprite should have a lightDir property that is an array (the editor does this for you automatically when you set the shader uniform)
  4. Create a global onMouseDown function (in app.js) to change light direction
foxcode

The spinning earth is pretty cool. Might we see some space based games with lots of 3d planets soon?

Post a reply
Add Attachment
Submit Reply
Login to Reply