Tools for creating cubic textures ? [SOLVED]

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
TheOtherGuy
Gnoblar
Posts: 20
Joined: Mon Jun 16, 2008 2:35 am
Location: New Zealand

Tools for creating cubic textures ? [SOLVED]

Post by TheOtherGuy »

I am looking for a tool to assist with the creation of cubic textures - like the textures in Media/packs/cubemap.zip/cubemap_*.jpg
All I really need is something that updates the appropriate boundaries eg. painting the 'west' edge of the 'front' texture updates the 'east' edge of the 'left' texture etc.
A GIMP plugin et al. would be ideal.

Is anyone aware of a tool that can do this? :?
Last edited by TheOtherGuy on Sun Aug 03, 2008 4:41 am, edited 3 times in total.
User avatar
Boriszko
Gnoblar
Posts: 5
Joined: Tue Jul 01, 2008 10:51 am
Location: The Netherlands

Re: Tools for creating cubic textures ?

Post by Boriszko »

TheOtherGuy wrote:I am looking for a tool to assist with the creation of cubic textures - like the textures in Media/packs/cubemap.zip/cubemap_*.jpg
All I really need is something that updates the appropriate boundaries eg. painting the 'west' edge of the 'front' texture updates the 'east' edge of the 'left' texture etc.
A GIMP plugin et al. would be ideal.

Is anyone aware of a tool that can do this? :?
I guess texture painting software like Deep Paint 3D will work although they might be overkill in your case.
TheOtherGuy
Gnoblar
Posts: 20
Joined: Mon Jun 16, 2008 2:35 am
Location: New Zealand

Post by TheOtherGuy »

I guess texture painting software like Deep Paint 3D will work although they might be overkill in your case.
Thanks Borisko - but I'm not sure that is what I am looking for.


What I am trying to do is create textures that map seamlessly when applied to the six faces of a cube. This is effectively a skybox looking from the outside of the cube, rather than from the inside.

It would appear that 'skyboxes' are generally created by making a 3D scene and rendering with the camera pointed in the direction of each cube face.

All I am trying to do is generate some cubic 'rock', 'dirt' and 'water' textures. The easiest way to create these textures may actually be to generate them procedurally by blending of a few layers of 3D perlin noise.

If anyone else has any solutions that they would like to share, feedback would be appreciated...
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

TheOtherGuy wrote:
It would appear that 'skyboxes' are generally created by making a 3D scene and rendering with the camera pointed in the direction of each cube face.
That's pretty much the sum total, yeah. Removing seams is a bit trickier but can be done. Google probably has tips on it.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2060
Joined: Thu Feb 26, 2004 12:11 am
Location: Toronto, Canada
x 4
Contact:

Post by Falagard »

I'd suggest using Terragen or Bryce 3D to generate the cubemaps instead of trying to make your own perlin noise generator...

There are tutorials on how to use these two programs to create skyboxes, just Google it.
TheOtherGuy
Gnoblar
Posts: 20
Joined: Mon Jun 16, 2008 2:35 am
Location: New Zealand

Post by TheOtherGuy »

Given a single tileable 2D texture http://en.wikibooks.org/wiki/Blender_3D ... d_a_skybox
has a method which can produce a texture for each cube face.
Basically you texture the inside of a sphere and environment map this on to the faces of a cube.

This seems to work, however note that the textures created are no longer fully tileable (ie. you can't do texture repetitions across one face).

Downloading Terragen to have a look see there now... :)
TheOtherGuy
Gnoblar
Posts: 20
Joined: Mon Jun 16, 2008 2:35 am
Location: New Zealand

Tools for creating cubic textures [SOLVED]

Post by TheOtherGuy »

To clarify - I'm not trying to make a skybox. I have a cube that has been 'spherized' http://mathproofs.blogspot.com/2005/07/ ... phere.html and am trying to generate textures for it - 2D 'tileable' textures don't map seamlessly on all faces.

Looks like blender can actually do what I require.
http://wiki.blender.org/index.php/Manua ... l_Textures
If I apply the desired procedural texture to the inside of an icosphere and environment map the output to a unit cube, the generated textures are 'cubic'.

This works reasonably well with little evidence of seams, however as previously stated the generated textures for each face are no longer tileable. I can't think of a way to retain tileablility, which remains a side issue - cranking the resolution of output textures is a short term solution.
User avatar
Boriszko
Gnoblar
Posts: 5
Joined: Tue Jul 01, 2008 10:51 am
Location: The Netherlands

Re: Tools for creating cubic textures [SOLVED]

Post by Boriszko »

TheOtherGuy wrote:To clarify - I'm not trying to make a skybox. I have a cube that has been 'spherized' http://mathproofs.blogspot.com/2005/07/ ... phere.html and am trying to generate textures for it - 2D 'tileable' textures don't map seamlessly on all faces.

Looks like blender can actually do what I require.
http://wiki.blender.org/index.php/Manua ... l_Textures
If I apply the desired procedural texture to the inside of an icosphere and environment map the output to a unit cube, the generated textures are 'cubic'.

This works reasonably well with little evidence of seams, however as previously stated the generated textures for each face are no longer tileable. I can't think of a way to retain tileablility, which remains a side issue - cranking the resolution of output textures is a short term solution.
I guess you can retain tileability by writing some kind of shader that perform the mapping transformation of the texture in real-time instead beforehand like inside of Blender.

Whether you should, is a tradeoff between the work of writing the shader and the somewhat higher system requirements (the costs) and the reduction in texture memory usage (the benefit). If your application uses a lot of those texture mapped on boxes as spheres at the same time causing insane texture memory requirements, it might be useful otherwise it is probably not worth the effort.
TheOtherGuy
Gnoblar
Posts: 20
Joined: Mon Jun 16, 2008 2:35 am
Location: New Zealand

Post by TheOtherGuy »

Well my interim measure blew out. By my calculations for a single 1024*1024 32bit texture with 6 faces and 5 mipmaps around 34Mb is used by each texture.
I guess you can retain tileability by writing some kind of shader that perform the mapping transformation of the texture in real-time instead beforehand like inside of Blender.
Unless I am missing something obvious this can't be done - textures get "ripped up diagonally" when trying to map to a cube. An attempt to explain this with ASCII is below. Each side is numbered. For a "2D tileable" texture sides 1, 3 should be seamless and so should sides 2, 4.
Look carefully at the sides that meet at each corner for each face. There doesn't seem to be any way other to map faces that touch seamlessly.

Code: Select all

      +--2--+
      |     |
      |     |
      4 UP  3
      |     |
      |     |
+--4--+--1--+--3--+
|     |     |     |
|     |     |     |
3 LF  2 FR  4  RT 1
|     |     |     |
|     |     |     |
+--1--+--3--+--2--+
      |     |
      |     |
      1 DN  2
      |     |
      |     |
      +--4--+
      |     |
      |     |
      3 BK  1
      |     |
      |     |
      +--2--+

I'm currently looking at generating 3D 64*64*64 pixel perlin textures for various noise types (fBm noise, abs noise, turbulence, veins, ...). These should be around 1.2Mb each at 32 bits with 5 mip maps.

From the 3D textures I should then be able to retrieve samples from each texture by sampling adjacent integer part of a given u, v, w coordinate point (+1, 0, -1 in 3D) where (u, v, w) range (0..64, 0..64, 0..64) and lerping the fractional part. This is effectively how classic perlin noise does gradient lookups. Using this method textures can be sampled in 3D and should scale nicely.

Materials could be created by sampling, colorizing and mixing various noise types - the Blender material node editor is a very good starting point for designing procedural textures.

Getting all this to work properly (let alone at animation frame rates) is non trivial. If anyone has any other ideas I would appreciate the feedback.
TheOtherGuy
Gnoblar
Posts: 20
Joined: Mon Jun 16, 2008 2:35 am
Location: New Zealand

Post by TheOtherGuy »

A brief follow up for anyone attempting similar methods:

It would appear that taking multiple samples of pre-calculated volume noise textures is not possible at high animation frame rates on D3D9b hardware - not on the ps_2_0 card (ATI Radeon 9550) I am currently using anyway. I have tried to mitigate this with an 'early z' pass, however when the entire screen is filled with a noise texture (up close) the pixel shader stalls the rest of the pipeline.

The issue lies with filtering. Ogre currently allows you to set filtering to none|bilinear|trilinear|anisotropic. This takes place 'under the hood' of the shader tex2D functions. On the card I'm using, when calling tex3D only the current z layer is filtered with (bilinear by default) leading to a nasty banding effect along the z axis.

I have seem oblique references to D3D9 hardware having no native support for quadrilinear filtering - can some one confirm this?

Without native hardware support I have set filtering to 'none' and am doing quadrilinear filtering of the seven adjacent pixels then blending/lerping to a nice 's curve' in a pixel shader. This requires eleven texture lookups (8 Tex3D volume texture lookups and 3 's curve' Tex1D lookups). Apparently there are additional hardware caching issues doing texture lookups on 'large' ( >= 32*32*32) volume textures. In addition to this, due to rounding issues with 8bit textures, I am using 32bit single channel floating point textures.
Doing a single pixel lookup of a noise texture takes a large number of instructions (keeping in mind that I am blending the results of multiple pixel lookups).
* A single pixel noise lookup with the ps_2_0 profile compiles to around 64 instructions.
* A single pixel noise lookup with the ps_2_x profile compiles to around 50 instructions
* A single pixel noise lookup with the fp30 profile compiles to around 34 instructions.
Examination of the code generated seems to reveal that ps_2 profiles actually convert tex3D commands to tex1D lookups while the fp30 does 'true' volume texture lookups. These pixel shader instruction counts are not too far behind doing 'true' noise generation entirely in the shader (sans precalculated noise textures).


After some further experimentation with methods of wrapping perlin noise, it should actually be possible to generate 6 2D textures for each face of a cube that tile both in two and three dimensions as I require. Unfortunately I still haven't gone far enough down this path to know if this will actually work... :?

Edit: Using 'wrapped' noise functions does what I require... :D
Post Reply