Progress
Moderators: winston, another_commander
- Killer Wolf
- ---- E L I T E ----
- Posts: 2279
- Joined: Tue Jan 02, 2007 12:38 pm
-
- Quite Grand Sub-Admiral
- Posts: 6683
- Joined: Wed Feb 28, 2007 7:54 am
- Killer Wolf
- ---- E L I T E ----
- Posts: 2279
- Joined: Tue Jan 02, 2007 12:38 pm
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
As of r3121, Oolite supports cube map textures.
A cube map texture consists of six images, representing the sides of a cube. Instead of associating colours with 2D points on a plane, it associates colours with 3D vectors from the centre of the cube. As such, it has a colour for every possible direction.
There are two major uses for cube map textures:
Cube maps can also be used for any texture in a custom shader.However, they are currently not supported in the default shader, so any model using a cube map for the diffuse map must also have a custom shader.
In a shader, a cube map is used much like a 2D texture, except:
To specify a cube map in shipdata.plist, use the new cube_map boolean attribute:
In order for a texture to be loaded as a cube map, its height must be exactly six times its width (which should be a power of two). If it isn’t, it will be treated as a 2D texture, and your shader won’t work. The six faces are stacked on top of each other in the following order: +X, -X, +Y, -Y, +Z, -Z (see example).
Example OXP (requires trunk, dur)
A cube map texture consists of six images, representing the sides of a cube. Instead of associating colours with 2D points on a plane, it associates colours with 3D vectors from the centre of the cube. As such, it has a colour for every possible direction.
There are two major uses for cube map textures:
- Mapping textures onto roughly spherical shapes, such as planets or asteroids. At some point, this will be supported for planets in Oolite.
- Representing the environment, for reflection and refraction effects. Griff has already experimented with fake reflections using normal textures; cube maps can help do it better.
Cube maps can also be used for any texture in a custom shader.
In a shader, a cube map is used much like a 2D texture, except:
- The sampler must be of type samplerCube instead of sampler2D.
- The texture lookup is done with the function textureCube() instead of texture2D().
- The texture coordinates must be a vec3 instead of a vec2.
Code: Select all
varying vec3 vNormal;
uniform samplerCube uCubeMap;
void main()
{
gl_FragColor = textureCube(uCubeMap, vNormal);
}
Code: Select all
diffuse_map = { name = "ahruman_earth_cube_map.png"; cube_map = yes; };
Example OXP (requires trunk, dur)
Last edited by JensAyton on Mon Apr 05, 2010 2:34 pm, edited 1 time in total.
E-mail: [email protected]
- DaddyHoggy
- Intergalactic Spam Assassin
- Posts: 8515
- Joined: Tue Dec 05, 2006 9:43 pm
- Location: Newbury, UK
- Contact:
Fantastic Ahruman - it's just getting better and better!
Oolite Life is now revealed hereSelezen wrote:Apparently I was having a DaddyHoggy moment.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Other stuff from this weekend:
- Oolite will now complain about polygons with more (or less) than three sides, instead of just ignoring all but the first three vertices (and potentially crashing if there were more than 16).
- Debris models are once again resized randomly.
- Dictionary-form texture specifiers are now supported in diffuse_map, etc. in shader mode. (Previously the code erroneously required them to be strings, and dropped them if they weren’t.)
- (As mentioned elsewhere) Colours that are considered insufficiently bright for lasers now get the right hue when brightened.
- (As mentioned elsewhere, Mac-specific) No longer freeze when attempting to control iTunes while it’s showing a modal dialog.
Last edited by JensAyton on Sun Apr 04, 2010 11:19 pm, edited 1 time in total.
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Oh, I forgot something: there is currently no graceful fallback for cube maps on systems that don’t support them; they will simply be loaded as 2D textures. This only affects the non-shader case, since cube maps are a requirement for GLSL support. My intended fix for this is to convert the texture to a lat/long map, and provide a python script to generate appropriate texture coordinates.
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Because of Oolite’s whacky coordinate system, the texture in the example was mirrored. Flipping the coordinates about when converting the model isn’t helpful in this case, so I’ve updated the example. (To flip a cube map, flip the entire image horizontally, then swap the +X and -X parts.)
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
As of r2123, cube maps are supported in the default shader (for diffuse_map only).
E-mail: [email protected]
- Killer Wolf
- ---- E L I T E ----
- Posts: 2279
- Joined: Tue Jan 02, 2007 12:38 pm
-
- Quite Grand Sub-Admiral
- Posts: 6683
- Joined: Wed Feb 28, 2007 7:54 am
I had no problems with the cubemap test. I could see an asteroid with the world map wrapped seamlessly around it.Killer Wolf wrote:i dumped that cube map test into my trunk but it's not working for me. I used a script to spawn a couple of them on exit from the station. they were on the scanner but i couldn't see anything visually, although my missile manage to lock onto one :-/
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Please paste the [rendering.opengl.extensions] report from your log.Killer Wolf wrote:i dumped that cube map test into my trunk but it's not working for me. I used a script to spawn a couple of them on exit from the station. they were on the scanner but i couldn't see anything visually, although my missile manage to lock onto one :-/
E-mail: [email protected]
- Killer Wolf
- ---- E L I T E ----
- Posts: 2279
- Joined: Tue Jan 02, 2007 12:38 pm