ScratchData LogoScratchData
Back to DadOfMrLog's profile

Shaded globe using pen

DADadOfMrLog•Created January 17, 2014
Shaded globe using pen
680
523
17229 views
View on Scratch

Instructions

Several people have asked if it might be possible to render a shaded sphere with the pen - so I decided to have a go... === ARROW KEYS to rotate direction light is coming from === I've included this as a new component for structures in the 3D framework, but thought it might be handy to have packaged up separately, for import into your own projects.

Description

The 3D Framework now has Globe components (v0.45 on) 3D STUDIO HERE: http://scratch.mit.edu/studios/202972 --------------------------------------------------------------- This works by drawing lots of ellipses (well, parts of ellipses). The ellipses are drawn from either the darkest or lightest point on the globe (depending which is furthest from the viewer), and increase in size up to mid-brightness. Then the ellipses shrink again to the opposite point. Each ellipse is a constant brightness. As usual, in order to get reasonable performance, several compromises have to be made: 1) The penwidth is small where the shade changes most quickly (so the shade change looks reasonably smooth), but becomes larger at certain places (so it can get away with fewer ellipses). 2) The ellipses are drawn using not too many straight sides - from some angles it's fairly easy to see that. 3) Because the ellipses overlap slightly, and the direction of shade change depends on whether the brightest or darkest point is closest to the viewer, there can be a slightly abrupt change in the shading as the light source goes from being slightly in front to slightly behind the globe. But at times it also doesn't look quite so good without some overlapping. 4) The slightly brighter 'bright spot', in the direction of the light source, makes it look a little like some specular reflection. However, if you know anything about that, you'll see it's clearly in the wrong place! But getting that right would be a fair bit of extra work, so this is another compromise between performance and looking reasonable...

Project Details

Project ID16727490
CreatedJanuary 17, 2014
Last ModifiedMay 15, 2020
SharedJanuary 17, 2014
Visibilityvisible
CommentsAllowed