[HN Gopher] Sculpting the moon in R: Subdivision surfaces and di...
___________________________________________________________________
Sculpting the moon in R: Subdivision surfaces and displacement
mapping
Author : tylermw
Score : 115 points
Date : 2024-06-18 13:19 UTC (9 hours ago)
(HTM) web link (www.tylermw.com)
(TXT) w3m dump (www.tylermw.com)
| zippyman55 wrote:
| Nice! Love R!
| tylermw wrote:
| Thanks! Me too (Obviously)!
| malshe wrote:
| Looking forward to reading this post but just wanted to say that
| the work Tyler has done on ray tracing in R is phenomenal. I
| highly recommend checking out this package website:
| https://www.rayshader.com
| tylermw wrote:
| Thanks for the kind words! You can also see the
| documentation/examples for {rayrender}, the pathtracer I wrote
| for R, here:
|
| https://www.rayrender.net
|
| And the rasterizer/mesh manipulation package {rayvertex} here:
|
| https://www.rayvertex.com
| pneumic wrote:
| Nice post. R's quirks seem to put some people off but I've found
| that it's a relative joy for exploratory analysis and
| visualization like this, especially within RStudio.
|
| Recently I was tasked with grouping a large number of DNA
| oligonucleotides, and exploring the criteria by which to group
| them was a lot of fun using various R libraries. In the span of a
| few days I learned how to use k-means clustering, how to employ
| an UpSet plot, and how to build a phylogenetic tree.
| tylermw wrote:
| R is hands-down the best language for data manipulation,
| analysis, and visualization: it's a language truly centered
| around treating data as a first class citizen. That focus does
| make some traditional programming workflows more error prone
| (helpful interactive data analysis features like vector
| recycling, flexible automatic type conversion, and non-standard
| evaluation provide lots of footguns), but the last decade of
| language improvements (stringsAsFactors = FALSE!) and R
| packaging ecosystem improvements have made the situation much
| nicer. The flexibility and lispy expressiveness of the language
| make it really fun to develop in, once you've gotten over the
| initial quirks.
| pneumic wrote:
| 100% agree, especially on the lispy expressiveness. I love
| that I can build analysis pipelines in a functional style,
| which has always clicked with me more than other paradigms.
|
| Tidyverse is a godsend for at least getting initial data
| transformations sketched out and for gently introducing new
| users, but I do believe one should gain an understanding of
| how to do all of these things in plain R.
| steve1977 wrote:
| Have you used the Wolfram Language and if so, how would you
| compare the two?
| tylermw wrote:
| I have not. I started using R due to its open source
| codebase and ability to audit and understand exactly what
| its doing under the hood--being able to see how statistical
| formulae were implemented in code was invaluable in
| understanding and interpreting a package's analytical
| output.
| rscho wrote:
| I have. R is far less verbose and maps far better to data
| analysis. The Wolfram lang is far more expressive and
| powerful for symbolic computation. So basically, Wolfram
| for doing math Research, R for applied stats.
| cjk2 wrote:
| Is there a decent tutorial or book on getting over the hill?
| I can do some basic stuff in it but it's just not catching
| like other languages do.
| tylermw wrote:
| My personal favorite resource is "R for Data Science" by
| Hadley Wickham. It covers lots of nice data manipulation
| and visualization examples, and provides a good
| introduction to the tidyverse, which is a particular
| dialect of R that's well-suited for data analysis. It's
| available for free at:
|
| https://r4ds.hadley.nz/
|
| For more specialized analytical methods there are lots of
| textbooks out there that provide a deep dive into packages
| for a specific field (e.g. survival analysis, machine
| learning, time series), but for general data manipulation
| and visualization it's hard to beat R4DS.
| napoleongl wrote:
| An option to the Hadley book that also covers some nice
| statistical methods is Statistical Rethinking by McElreath.
| Not really available for free though but interesting read.
| kaeptnkrunch wrote:
| Nice
| Blahah wrote:
| Absolutely beautiful - both the clear explanation and the
| idiomatic (tidyverse style) R packages and code walkthrough. The
| combination of the two allowed me to read through and understand
| in one go. And I have immediate uses for the packages. Thanks!
| evilturnip wrote:
| In planetary rendering circles, the cubified sphere is a great
| method and I'm glad he went over that here.
|
| I should say you do get distortion where the cube faces meet at
| the edges. May or may not be a problem depending on how your
| texturing.
| tylermw wrote:
| I remapped the UV coords based on the spherical projection of
| the mesh after subdividing, so there should be minimal
| distortion, especially compared the UV sphere. There is a
| slightly higher density of vertices where the edges of the cube
| used to be, but it's small compared to the UV sphere's extreme
| convergence at the poles.
| washedup wrote:
| Amazing work. Simple, easy-to-use code. This must have been quite
| the effort. It's honestly stunning work. Also, good to see R is
| still alive and well!
| pixelpoet wrote:
| I would just directly ray trace it, no subdivision. Then it
| becomes something like 100 lines of code total, and is probably
| still faster than the subdiv approach.
|
| BTW I like to call that singularity at the pole god, because I
| often notice it in env maps as an arsehole in the sky :P
| phkahler wrote:
| Opensubdiv should be able to do this too. I wonder how much work
| it would be to glue that on. Maybe there's no benefit at this
| point? ;-)
| tylermw wrote:
| Opensubdiv would definitely be the robust, industry standard
| solution. However, R packages that are distributed on the CRAN
| have additional restrictions on required system libraries, so
| for portability I went with a bespoke implementation.
| CliffStoll wrote:
| In the 1970's, I had the honor of working with Bill Hartmann, Bob
| Strom, Gerard Kuiper, Clark Chapman and Ewen Whittaker, at
| Tucson's Lunar & Planetary Labs. They used large earthbased
| telescopes to photograph the moon's surface at many illumination
| angles and libation angles. The images were captured on glass
| plates.
|
| They physically projected these images onto a large plaster
| sphere; in turn, they rephotographed the images from different
| angles, to remove foreshortening and show the lunar surface as
| seen from directly above a crater.
|
| One result of this is the Rectified Lunar Atlas -- one of the
| guiding maps of the Apollo missions:
| https://sic.lpl.arizona.edu/collection/rectified-lunar-atlas
___________________________________________________________________
(page generated 2024-06-18 23:00 UTC)