Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (593) Games in Android Showcase (168) games submitted by our members Games in WIP (646) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Texturing a sphere, creating a cube map - the proper way?  (Read 2827 times) 0 Members and 1 Guest are viewing this topic.
Kerai

Junior Devvie

Medals: 4

 « Posted 2013-05-18 14:08:38 »

So I've been looking into spheres and this seems to be a wild subject... couldn't find at least one place that would agree on any proper way to do this.

People say spheres sould be textured with cube maps, and not Mercator streched textures. (like ones NASA gives)

I found this blog post https://mycodingwrongs.wordpress.com/2010/07/24/reprojecting-blue-marble/
The guy reprojected Mercator texture onto Gnomonic cube map.

I was able to texture a sphere with that cube map he gave. I'm not sure if I created that mesh correctly, but it looks quite good.
example: http://dev.keraj.net/sphere/ (press
• on numpad to add more vertices, press V to see wireframe)

1. But I don't know how he did that. How did he reproject from Mercator to Gnomonic. He gave a link to wolfram page on Gnomonic projection, but I am not sure how use that.

2. What if I want to create my own cube map? (ie. procedurally, out of perlin noise, or even manually)

I hope some of you guys been through this and can give me some advices, maybe even some code.
I would really like to know what are good ways to mesh a sphere and texture it procedurally correctly.
relminator
 « Reply #1 - Posted 2013-05-18 14:44:04 »

Spheres are quadric shapes which means they can be generated by its bands and rings.

Say number od bands id 20, x or s is:

2pi/20 * texture repeat number.

I forgot the parametric equation for a sphere but it's something like:

 1  2  3 `x = sin(p) * cos(t)y = sin(p) * sin(t)z = cos(p)`

That 2pi above is your p and t.

Sample here:

rel.phatcode.net/junk.php?id=55

Sorry using phone to post.
Roquen
 « Reply #2 - Posted 2013-05-18 15:02:01 »

Short answer: Cube map is easiest and cheapest.  Any simple mapping of a 2D texture to a sphere has aweful texture coverage which is also non-uniform.  Imagine wrapping a square piece of rubber around a ball and you'll get a rough idea (being a rectangle doesn't really help).
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Riven (11 views) 2015-07-03 11:22:16 deepthought (41 views) 2015-06-30 15:39:44 deepthought (45 views) 2015-06-30 15:39:09 deepthought (55 views) 2015-06-30 15:36:52 Za\'Anzabar (24 views) 2015-06-29 05:44:54 TritonDreyja (41 views) 2015-06-24 17:10:40 CopyableCougar4 (40 views) 2015-06-23 00:34:45 BurntPizza (44 views) 2015-06-21 20:36:46 cookiecompiler (86 views) 2015-06-11 15:42:53 cookiecompiler (49 views) 2015-06-11 15:41:14
 princec 34x wessles 24x BurntPizza 19x opiop65 18x CopyableCougar4 18x Riven 15x nsigma 15x theagentd 15x EgonOlsen 14x KaiHH 14x SauronWatchesYou 11x KevinWorkman 11x sunburn 11x NegativeZero 10x ags1 10x DavidBVal 10x
 How Do I Expand My Game?by bashfrog2015-06-14 11:34:43List of Learning Resources2015-05-31 05:37:30Intersection Methodsby Roquen2015-05-29 08:19:33List of Learning Resources2015-05-05 10:20:32How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org