About Store Forum Documentation Contact
Donations:
289$/mo



Post Reply 
Material to sphere?
Author Message
andargor Offline
Member

Post: #1
Material to sphere?
I'm trying to apply the attached material to a sphere, but the top and bottom are "square". I guess since the image uses a cylindrical projection and Esenthel expects a cube format, this is the problem?

Is any function available to convert from cylindrical to cube?


Attached File(s) Image(s)
   
05-18-2011 10:52 PM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #2
RE: Material to sphere?
For the life of me, I can't seem to be able to create a cube map. For testing purposes, I've tried putting skybox.jpg through the Converter to get a cube map, and all I get on a sphere is solid blue.

Is there an example somewhere on the use of cube maps?
05-19-2011 02:57 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #3
RE: Material to sphere?
Do I have to use a technique like render to texture for this to work?
05-19-2011 10:39 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: Material to sphere?
EsenthelEngineSDK\Tutorials\Source\Advanced\2 - Animation, Physics, Rendering\Rendering\02 - Sky.cpp
05-20-2011 12:59 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #5
RE: Material to sphere?
Thanks, but as I mentioned, I already tried the skybox technique. I know how to create a skybox.

What I don't know: How do I load a cube map onto a shape like a box or sphere? The closest I get is the same texture pasted on all 6 faces.

I've tried:

- Import
- ImportCube
- fromCube
- toCube
- createCube

without success. Either a black shape or one color, not every face with the appropriate texture side.


EDIT: I've found the MeshBase textMap method, which seems to to the trick of wrapping the texture, if I use a ball map.
Almost there!

I've got a strange artefact on the spherical texture, a big line running on the side (see attached picture).

I'm using this code:

PHP Code:
moonmat.reset();
moonmat.base_0.require("Data/Mtrl/CelestialBody/Moon/MOON8K.gfx");
moonmat.validate();

MeshBasemb ball.parts.New().base.create(Ball(10),VTX_TEX0|VTX_NRM|VTX_TNG);
mb.texMap(Ball());

ball.setMaterial(&moonmat).move(Vec(20,20,20)).setRender().setBox(); 


Attached File(s) Image(s)
   
(This post was last modified: 05-20-2011 02:04 AM by andargor.)
05-20-2011 01:15 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #6
RE: Material to sphere?
Perhaps cube maps are only supported for skyboxes. I can think of two options:

  1. Create the box/ball inside of a modeling program, like 3DS Max, and change the UV coordinates that way
  2. Figure out how to manually update the coordinates of a box/ball through code in EE and tinker with them until they are right, assuming this is possible to do
Or, try Google.

If you need to put this texture on a box, that would be real easy to do in 3DS Max.
05-20-2011 06:22 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #7
RE: Material to sphere?
I've used HDR Shop and CubeMapGen to create cube maps during my testing, but again the problem is applying the texture, the cube code doesn't work (except for skyboxes).

If I could get rid of that strange line with the spherical texture mapping, I would be ok for now. Eventually I will probably need cube mapping since the texture is more evenly distributed and looks better.
(This post was last modified: 05-20-2011 01:33 PM by andargor.)
05-20-2011 01:32 PM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #8
RE: Material to sphere?
Does something like this help? (Using the texture you gave)


Attached File(s)
.7z  Moon.7z (Size: 127.1 KB / Downloads: 7)
(This post was last modified: 05-20-2011 06:46 PM by llynx.)
05-20-2011 06:45 PM
Find all posts by this user Quote this message in a reply
Kobaltic Offline
Member

Post: #9
RE: Material to sphere?
The best way and easiest way is to load the sphere into 3ds max. Apply a UV map (not the UV unwrap). Change the setting to to sphere and change the size to the best looking size. Also your texture doesn't look tiled, so you may get an undesired effect.
(This post was last modified: 05-20-2011 08:30 PM by Kobaltic.)
05-20-2011 08:28 PM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #10
RE: Material to sphere?
(05-20-2011 06:45 PM)llynx Wrote:  Does something like this help? (Using the texture you gave)

Thanks! I notice you don't get the ugly bar on the side, like when I do it with code. I wonder why...
(05-20-2011 08:28 PM)Kobaltic Wrote:  The best way and easiest way is to load the sphere into 3ds max. Apply a UV map (not the UV unwrap). Change the setting to to sphere and change the size to the best looking size. Also your texture doesn't look tiled, so you may get an undesired effect.

That would be great, I will however want to generate dynamic planet maps in the future, with random elements. So I can't use 3ds max (or Blender in my case).

However, I'll take the hint about the UV map and experiment with that to get rid of the ugly bar on my attempt above.

Also, curiosity about using cube maps with code on things other than skyboxes is killing me. grin
(This post was last modified: 05-20-2011 10:59 PM by andargor.)
05-20-2011 10:55 PM
Find all posts by this user Quote this message in a reply
Kobaltic Offline
Member

Post: #11
RE: Material to sphere?
You can set the UV map on the sphere but then have the engine use a different texture for the procedural generation. As long as the textures are similar in size it shouldn't be a problem.

I know you programmers love to program everything, but the guys that make 3ds max, maya and photoshop really got you beat. You should take advantage of what they can offer.
05-22-2011 01:27 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #12
RE: Material to sphere?
(05-22-2011 01:27 AM)Kobaltic Wrote:  You can set the UV map on the sphere but then have the engine use a different texture for the procedural generation. As long as the textures are similar in size it shouldn't be a problem.

I know you programmers love to program everything, but the guys that make 3ds max, maya and photoshop really got you beat. You should take advantage of what they can offer.

I could probably say something in reverse for graphic artists, but I have too much respect grin grin grin

Anyway, perhaps Esenthel can tell me if the ball texMap is bugged? How do I get rid of the line? Nothing I try works.
05-22-2011 07:34 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #13
RE: Material to sphere?
If you add a ball in mesh editor, apply the material, and set texture mapping to Ball, you don't see any line; however, the very top and bottom are messed up like in your screenshot.

Mesh > Add > Ball
Mesh > Texture Operations > Set Texture Mapping > Ball
05-22-2011 09:36 AM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #14
RE: Material to sphere?
Whay don't use 3d software. If you have create function you will load mesh instead of create a ball. Then you can apply any texture you want and add scale. But you need to make good uv map, and to this make texture.
Quote:http://en.wikipedia.org/wiki/File:UVMapping.png
You need to make opposite site in model.
Result:


Attached File(s) Image(s)
   

.zip  Sphere.zip (Size: 157.3 KB / Downloads: 8)
(This post was last modified: 05-22-2011 12:23 PM by Seba.)
05-22-2011 11:48 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #15
RE: Material to sphere?
(05-22-2011 09:36 AM)Driklyn Wrote:  If you add a ball in mesh editor, apply the material, and set texture mapping to Ball, you don't see any line; however, the very top and bottom are messed up like in your screenshot.

Mesh > Add > Ball
Mesh > Texture Operations > Set Texture Mapping > Ball

I noticed that too. There must be some step I'm missing in code.

(05-22-2011 11:48 AM)Seba Wrote:  Whay don't use 3d software. If you have create function you will load mesh instead of create a ball. Then you can apply any texture you want and add scale. But you need to make good uv map, and to this make texture.
Quote:http://en.wikipedia.org/wiki/File:UVMapping.png
You need to make opposite site in model.
Result:

I loaded your mesh and applied the texture (actually a higher res one, like the big screenie above), and I don't get the line anymore, nor the messed up poles. Thanks!

There must be something missing in code, but in the meantime I can use the sphere mesh as a template and apply different materials in code.

The perfect marriage of graphic artist and programmer grin


Attached File(s) Image(s)
   
(This post was last modified: 05-22-2011 06:59 PM by andargor.)
05-22-2011 06:54 PM
Find all posts by this user Quote this message in a reply
Post Reply