How to contribute

Hello,



I've made an alternative CompositeSphere (PrettyCompositeSphere) that does have many advantages.

My problem is that I don't know how to post and contribute it.





What's better with my sphere?

This:

It does not look like a lemon when seen from special points of view.

It has similar low triangle count as the original CompositeSphere.

It can be configured in a user-friendly way (maximum edge length & sphere radius).

It does have less problems with texture coordinates.

It is correctly oriented (every triangle CCW-oriented).

It can switch to CW-orientation by simply using a negative number for the radius.





I would like to contribute this to the com.jme.scene.shapes package, if you like.

I've tested it thoroughly already.

Please send it by email (see - http://jmonkeyengine.com/index.php?option=com_contact&catid=4&Itemid=3) and we’ll have a look.  Thanks!

What technique have you used for the ‘pretty’ sphere? Something like 3D-Studios Geosphere?

I have done something like it but couldn’t imagine a nice way for texture mapping:

The lower two lines show sphere constructed from octa- and dodecahedron.



The first line shows some normal spheres. (last and first sphere are distorted due to perspective)

Well, I know this technique of building geospheres.

Once I built an icosahedron-based geosphere (like the one in your last row - which isn't dodecahedron but icosahedron-based).

But I had problems in finding an explicit and fast way of building the sphere - the best I could imagine was the simple iterative way of building such geospheres. Maybe with octahedron-based spheres it might be possible to find a simple formula for it (or I was not good enough in math to do it with icosahedrons).



The technique I used was my own invention - I did not find it anywhere on the net or in a book.

The sphere is simply a reduced version of a much more sophisticated sphere that I use for planetary simulations.

I had the idea several weeks ago and since then I fine-tuned it a little bit.



The problem with texturing curved objects is well known.

I solved the problem of generating texture coordinates in a quite simple way (since my sphere was originally designed for a similar purpose).

For geospheres like the ones shown in your picture you would need to calculate polar coordinate angles from the unit vectors around the center of the object and then calculate u,v coordinates from these angles (phi & theta / lattitude & longitude) - I know that this is possible and have already done this (but maybe it is even possible to do this in a more efficient way). To get the angles, use simple triangle-math with the unit vectors (divide by radius to get unit vectors).

Make u,v like this:

You simply let v start at the north pole with v=0 and let it be v=1 at the south pole ( phi from 0 to PI / lattitude from +0.5PI to -0.5PI ).

And then you let go u from 0 to 1 inside the whole angle range ( theta from 0 to 2PI / longitude from 0 to 2PI ).



Of course, you will also need distorted textures to texture the sphere afterwards.

I could write you a tool to make perspective-warp textures from normal rectangular textures - but maybe you find some on the net.

It is even possible to paint the same image several times on the surface - but this either looks bad or need deep thoughts on improvement.





Ok, have fun with that sphere … (sent it by mail to one of the developers)

by the way:

There is also an orthographic projection mode in GL (and jME).

In the newer SimpleGame implementations you can simply hit F2 to go into ORTHO mode …  :slight_smile:

Ogli said:

by the way:
There is also an orthographic projection mode in GL (and jME).
In the newer SimpleGame implementations you can simply hit F2 to go into ORTHO mode ...

LOL  :smiley:

Hm,

maybe I did not discover the philosopher's stone.

The linear interpolation of the texture in the graphics hardware still causes problems and visual artifacts (especially near the pole region) if you do not have a specially distorted texture and if the resolution of the sphere is quite low.



After further testing, I also found, that the original jME Sphere looks a little better for very low resolutions of the Sphere.

Fixing some triangle orientation problems in CompositeSphere it would still look good - for lower resolutions.





Maybe I should look for my old C+±Icosahedron-OpenGL-Sphere and port it to jME.

Or I could help irrisor generating the texture coordinates - the necessary functions are already implemented in my planet sim

(vector to phi & theta / vector to lattitude & longitude ).



The overall problem with those "geo"-spheres is, that you have no general information relation between angles and triangles - this is, why I dropped this approach for my project.

But - they look quite beautiful, those geospheres (though they also have problems near the pole, at higher resolutions).





EDIT:

My old Icosahedron-Sphere has two methods that I found very usefull then:

1.

A method that can compute the total number of vertices for a given iteration number (for example: iteration = 0 -> 20 Vertices).

2.

A method that can determine, which iteration hast to be used in order to have a certain maximum edge length.



I was very proud on these methods, but maybe you already have them implemented? - if not, I would be willing to share them.

hehe, yes I was too lazy to use the ortho mode because when simply hitting F2 the spheres were too small…



But maybe I even shouldn't have posted that screenshot as my original question got lost:

irrisor said:

What technique have you used for the 'pretty' sphere?

(you described benefits but not what causes them)

As for that methods: I needed #1, too, so it's in.

And regarding texture-coords: yes, I know one could map it like you described, but that's the same way the normal sphere does it and as you said it does not look well at the poles.

Hmm, maybe that topic name should be changed :)
irrisor said:

But maybe I even shouldn't have posted that screenshot as my original question got lost:
irrisor said:

What technique have you used for the 'pretty' sphere?

(you described benefits but not what causes them)


Hm, well, this should not be such a secret either.
You can look into the source code of PrettyCompositeSphere. I do not know the nicks of two of the people on the contact page that renanse posted the link for, but I sent all three of them the code. And I sent you a message to the link with the latest version.

The algorithm is quite simple - it generates triangle strips around the sphere with triangles that have a maximum edge length, which the user can specify.
The triangle strips are generated explicitly (strip by strip). The only limitation for the sphere to look good is, that along theta (longitude) every strip has a binary number of triange-pairs (a power of two). By making it this way, the resolution in a triangle strip (i.e. the number of triangle pairs along one strip) can change without causing visual artifacts when that happens - if one triangle strip knows that it needs more triangles inside itself then in the last strip (above or underneeth), it uses a special pattern to connect to the other triangle strips (its neighboors).

Well, I think you won't be happy with this explanation - maybe a look into that source code will help you.
irrisor said:

And regarding texture-coords: yes, I know one could map it like you described, but that's the same way the normal sphere does it and as you said it does not look well at the poles.


You could overcome this problem by using one of these ways:
1.
Use a very high resolution for the sphere (not such a good idea for real time apps).
2.
Make a special texture that collapses in the last row and is made for a special resolution of the sphere (first / last rows in image fall into one point). You must find out, for which texture coordinates these "last rows" begin (for PrettyCompositeSphere not such a big problem) and then you must modify these pixel rows in the texture image so that the linear interpolation does not produce artifacts anymore.
3.
Use a totally different texture mapping: Use "triangle images" for the geosphere (you could let every triangle show the whole texture image - that way, you could generate a "ground" texture all over the sphere, but it would only be usefull when regarding a very big sphere ( a planet for example 8) ) or a sphere with very large triangles (low resolution) - for that purpose the geospheres should be perfect. The only problem: You hardly find any triangle images over the net.  :D
(You would "just" need triangle textures which are rotational invariant - to avoid seams.)

I think, now that I became curious - I will implement method number 2.
Of course, method number 2 could also be used for geospheres but you would need to find out all texture coords for the first and last row of triangles and then adjust the texture image (this would not be a simple transformation anymore - like with method number 2 for PrettyCompositeSphere).

just got so curious…what are you going to use the "extremely pretty next-gen"-spheres for?  :slight_smile:

I imagine two directions:



1.

A Geosphere (for example the icosahedron-based one) for low-poly generic spheres - for example transparent energy shields in games.



2.

A sophisticated successor of the PrettyCompositeSphere for planetary simulations and space games (this is, what I'm actually doing in my free time).

cool!

Well, seems like I did not discover the holy grail at all.

For good looking textures it needs several improvements ( a fragment shader or a tool to distord the whole texture image before mapping ).



So it seems either elegant geometry or not soo bad looking textures ( jME Sphere with lots of radial samples ).



BUT:

Maybe the current maintainer of the jME CompositeSphere could review it - when activating backface culling, I discovered that the orientation of the triangle fans differs and that the triangle strips have clockwise orientation (seems to me).

ogli, I am studying global earth simulation and tessellation, Can you share me a copy of your source code, maybe some papers.

thanks!

my email: mailabing@163.com