Faces of (pseudo-)sphere

60 views
Skip to first unread message

Harlan Gilbert

unread,
May 12, 2022, 8:19:51 PM5/12/22
to Glowscript Users
Dear Bruce,

We are running a simulation of a person moving around a sphere, showing first person view
It looks very jagged, because the sphere is simulated using a polyhedron. 

Forgive me for asking, but:
Is it at all possible to increase the number of triangles used, either generally (which might increase lag times for some people, so maybe not optimal), or by adding an attribute to control this?

Otherwise we can live with the roughness.

Thanks for considering,
Harlan

Bruce Sherwood

unread,
May 12, 2022, 9:39:32 PM5/12/22
to Glowscript Users
You can do it yourself. Just make a compound of a large number of triangles. Compounds are stored in GPU memory, so they can be displayed fast. 

Bruce 

Harlan Gilbert

unread,
May 13, 2022, 9:33:29 AM5/13/22
to glowscri...@googlegroups.com
Ah, yes... However, I am using the textures.earth to simulate motion around the Earth.  I think that won't work on a compound, will it?


On Thu, May 12, 2022 at 9:39 PM Bruce Sherwood <bruce.s...@gmail.com> wrote:
You can do it yourself. Just make a compound of a large number of triangles. Compounds are stored in GPU memory, so they can be displayed fast. 

Bruce 

--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glowscript-users/CA%2BWuaSd4CtWQUwkgUxT0-KTOs73_fXsLVOWCLW3JJxOvAWF1BQ%40mail.gmail.com.


--
Harlan Gilbert, Ph.D.
High School Chair and Math, Physics, Computer Science, and Philosophy Teacher
Green Meadow Waldorf High School
Chestnut Ridge, NY 10977

Bruce Sherwood

unread,
May 13, 2022, 12:42:02 PM5/13/22
to Glowscript Users
I think this excerpt from the documentation on triangles and quads is relevant:

texpos: If you intend to apply a texture or bumpmap to a mesh object, you must specify in the mesh how you want the texture to be mapped onto your object. You might want the texture to occupy only a portion of the object, or be stretched or distorted in some way. This is done by specifying "texel" coordinates, given as texpos vectors in the vertex objects.

Texel coordinates for a surface texture are specified by an "x" and a "y", both ranging from 0 to 1 if the entire texture is to be displayed, left to right and bottom to top. (In many discussions texel coordinates are referred to as "u" and "v", or as "s" and "t".) In anticipation that WebGL will eventually enable 3D textures, which permit filling a textured volume, VPython requires that in texpos elements the third component must be zero.

For example, to fill a quad with a texture, the texpos vectors in the vertex objects v0, v1, v2, and v3 would be vec(0,0,0), vec(1,0,0), vec(1,1,0), vec(0,1,0), no matter what the 3D pos attributes are. If you want only the lower quarter of the texture to fill the quad, the texpos vectors would be vec(0,0,0), vec(0.5,0,0), vec(0.5,0.5,0), vec(0,0.5,0). Note that <0,0,0> is at the lower left, and <1,1,0> is at the upper right.

The compound rule on textures is this:

Currently objects in a compound can have their own values of coloropacityshininess, and emissive, but they cannot have individual textures or bumpmaps, which can only be specified for the combined object, and which affect all of the compounded objects.

Currently label objects, lights, and objects based on curve objects (curve, helix) cannot be compounded. However, trianglesquads, and even other compounds can be compounded. Also, a compound object can be cloned to make additional copies.

So try a simple test case, but this sounds like it should be possible, since just one (Earth) texture is to be applied to all the triangles or quads.

Bruce

Harlan Gilbert

unread,
May 14, 2022, 9:58:16 PM5/14/22
to glowscri...@googlegroups.com
I started working on this, but then noticed that the documentation states that the z-coordinate of the "texel" must be zero, which means that 3D  textures cannot be applied effectively to 3-D objects.
Ah, well...

--

---
You received this message because you are subscribed to a topic in the Google Groups "Glowscript Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/glowscript-users/ONc36MeK5pA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to glowscript-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glowscript-users/f06ffa42-e4ed-4127-8460-d86ace8406a3n%40googlegroups.com.

Bruce Sherwood

unread,
May 14, 2022, 10:39:31 PM5/14/22
to Glowscript Users
No, it's just that we require the z element because it is conceivable that some day we will support "voxels", which are 3D "textures".

Bruce 

Harlan Gilbert

unread,
May 14, 2022, 11:55:15 PM5/14/22
to Glowscript Users
Well, I have a result of sorts...
Serious problems remain:
1) the texture maps about 8 times over the surface of the sphere, which I don't understand
2) It is very distorted in places

It seems that I cannot get the texture to map properly onto a mesh object without the z-component being taken into account

Question: Is textures.earth not a 3-D texture? How does it wrap around a sphere object properly?...I wonder how this is implemented, and whether it is applicable to a mesh object...

Thanks for any thoughts about any of this!

Best regards,
Harlan

Harlan Gilbert

unread,
May 15, 2022, 6:35:04 PM5/15/22
to Glowscript Users
I've brought it to duplicating the map only twice: once on the front, once on the back.  A big improvement on eight times.
(Fixed when I noticed that texel ranges from 0-1, not -1 to 1)

I'd love to know how the texture manages to map onto a sphere object, given that the z-component is purposefully ignored.

Bruce Sherwood

unread,
May 15, 2022, 10:08:47 PM5/15/22
to Glowscript Users
Since you have already managed to wrap the Earth image around the sphere, albeit twice at the moment, it would seem that you DO know "how the texture manages to map onto a sphere object'. I repeat that the z component is currently not used at all.

Bruce

Harlan Gilbert

unread,
May 15, 2022, 11:08:55 PM5/15/22
to glowscri...@googlegroups.com
Sorry to be so troublesome here, but what puzzles me is that while
sphere(texture=textures.earth)
maps the Earth correctly, just once around, onto the sphere, I cannot achieve this with a mesh.

In fact, I cannot imagine how this is achieved for the sphere object without the mapping somehow taking the z-coordinate into account, as clearly points with identical x and y coordinates on the sphere (but opposite z-coordinates) are somehow being mapped to different parts of the Earth.

I cannot imagine how to achieve this with the mesh.

Harlan

On Sun, May 15, 2022 at 10:08 PM Bruce Sherwood <bruce.s...@gmail.com> wrote:
Since you have already managed to wrap the Earth image around the sphere, albeit twice at the moment, it would seem that you DO know "how the texture manages to map onto a sphere object'. I repeat that the z component is currently not used at all.

Bruce

--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glowscript-users/1e940fb4-aed1-4e32-b950-283bc01a7cccn%40googlegroups.com.

Bruce Sherwood

unread,
May 16, 2022, 11:33:53 AM5/16/22
to Glowscript Users
I don't understand the problem. First, I'll repeat that the z component of texture coordinates is at present irrelevant; just set it to zero. It's there only because there exists in computer graphics an entity called a "voxel" which is 3D texture; that is, a transparent sphere could in principle in the future have different colors at different locations inside the sphere. So please forget about z.

Second, a VPython texture is a 2D object, even when it is wrapped around a 3D object. On Earth you can specify a location with just two numbers: longitude ("x") and latitude ("y"), and the same location scheme is used for the other planets whose radii differ from ours.

Bruce

Harlan Gilbert

unread,
May 16, 2022, 12:40:18 PM5/16/22
to glowscri...@googlegroups.com
Thank you, Bruce; you gave me the key here; the texture is mapped based on longitude and latitude (each scaled 0->1), which means the texture is actually a cylindrical projection of the globe.

That's the key information I did not know.  Thank you!   All good now!

Harlan


--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.

Bruce Sherwood

unread,
May 16, 2022, 7:00:47 PM5/16/22
to Glowscript Users
I should comment that when I'm tired, I describe locations in terms of loungeitude and lassitude....

Bruce
Reply all
Reply to author
Forward
0 new messages