Home Technical Talk

Abstract skybox creation

polycounter lvl 19
Offline / Send Message
MikeF polycounter lvl 19
Just wondering if anyone has some tools or tips to create a more abstract skybox based off an image like this http://sokpok.com/wp-content/uploads/2014/10/abstract%20colors%20wallpaper-cBtx.jpg . I've only ever really dealt with generating something realistic using teragen or manually stitching some panoramas but i'm not really sure how to go about making something like this seamless so any tips would be much appreciated!

Replies

  • EarthQuake
    Options
    Offline / Send Message
    Should be pretty easy, make sure it tiles horizontally, and then paint solid colors along the top and bottom and it will map seamlessly to a sphere. Ratio should be 2:1.

    Alternatively, make it tile horizontally, then apply it to a sphere and 3d paint the tops and bottoms to be seamless.
  • MikeF
    Options
    Offline / Send Message
    MikeF polycounter lvl 19
    Ah good idea, i hadnt thought of using 3D paint. Thanks EQ
  • RN
    Options
    Offline / Send Message
    RN sublime tool
    It's a bit old, but there's SkyPaint:
    http://www.skypaint.com/

    It has a tutorial with CryEngine:
    http://docs.cryengine.com/display/SDKDOC2/SkyPaint+Tutorial

    I'd love to hear about a more modern workflow that relies on one of the major 3D packages (Max, Maya, Blender etc.).
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    So assuming you want a cubemap instead, then 3d paint on a cube is a good idea.

    However, I'll give you another option.

    Open up Photoshop and create a new document 3x as high as you want the resolution for one cube face, and 4x as wide.
    Be sure your grid is set up to be power of 2 friendly. I recommend the main divisions being at least 1/4 of your single face resolution with 4 divisions each (or some other power of 2 to your liking). You'll need it later


    First thing: Paint your abstract texture, then make it tile horizontally. (Filter-other-offset (use half the total res in x, and have edge pixels wrap around. Then paint or clone stamp or whatever out the seam in the middle, being sure to not touch the edges of the piece)
    abstract_Cube_part1.jpg

    Keep your main detail to the center area, but letting some drift up and down is fine. Just remember that only 1/4 of the bottom and top thirds will wind up being in the final texture.
    (uv layout for cube)abstract_Cube_part2.jpg

    Next, copy out a triangular section that is the full face width wide, and half the resolution high from the top and bottom thirds. This is where grid snap with 4 divisions per face comes in super handy. Easy selection with the polygonal lasso.
    abstract_Cube_part3.jpg

    Rotate all these sides together to for single squares where your top and bottom faces are:
    abstract_Cube_part4.jpg

    Fix up the resulting seams, bringing out or adding detail as you want, just DON'T TOUCH THE EDGES of your top and bottom faces. This results in a clean cube with whatever content you feel like painting in. So at this point you can use this as is if you've got an unwrapped cube, or you can export each face separately from Photoshop in a variety of manners.
    abstract_Cube_part5.jpg

    In the case of the below demo, I left the whole texture as one piece, and just added some extra buffer as appropriate to allow for mipmapping.
    abstract_Cube_finalTex.jpg
    Download the cube object.

    [sketchfab]32ff08d3482b410bbee8d765d2871478[/sketchfab]
  • Eric Chadwick
    Options
    Offline / Send Message
    Hey Vailias, that's a cool process. However it's missing the angular distortion you need, to make a perfect cubemap.

    It's visible in the Sketchfab example, as linear distortions in the corners. If it was mapped on a sphere you wouldn't need the distortion, because every surface would be equidistant from the camera. But, it's a cube, so...
  • MikeF
    Options
    Offline / Send Message
    MikeF polycounter lvl 19
    Thanks Vailias thats a great little writeup! I'll give it a shot sometime soon
  • RN
    Options
    Offline / Send Message
    RN sublime tool
    Thank you for that guide, Vailias.
    After some thinking, I believe the following is what's needed to add the perspective distortion to any cubemap image that you create like described above.

    1) Create a cube object in your favourite 3D program. Make it any size, and completely centre it in the scene.
    perspective_Distort1.png

    2) Tesselate \ subdivide each of the faces once to add a vertex on the center of each face.
    perspective_Distort2.png

    3) Connect the center vertex to the corner vertices, to ensure that the triangulation is correct.
    perspective_Distort3.png

    4) Reposition the center vertices such that their new position is their current position multiplied by the "square root of two."
    For example, the front face of my cube has its center vertex at [ 0, 50, 0 ]. Then I'll position this vertex at [ 0, 50 * sqr(2), 0 ].

    The result of 50 * sqrt(2) is 70.7106781, so this vertex should be relocated to [ 0, 70.7106781, 0 ].
    You would do this for all the center vertices. The top center vertex, for example, was [ 0, 0, 50 ] and now it's [ 0, 0, 70.7106781 ].
    perspective_Distort4.png

    5) Map each face of the cube with the corresponding cubemap texture that you created. Make sure their orientations are right (you might need to rotate some of textures).
    Make sure that all textures \ materials are SELF ILLUMINATED, so that the brightness from the textures is preserved.
    perspective_Distort5.png

    6) FLIP the geometry of the cube, so all faces are facing in.

    7) Position a camera at [ 0, 0, 0 ] (so it's inside and in the centre of the cube ) and set its FOV (field-of-view) value to 90º degrees. If you display the camera frustum, you'll see that it aligns with the cube face.

    Set the rendering size to a square power of two, like 512x512, 1024x1024 etc.
    perspective_Distort6.png

    8) Render each cube face by orienting the camera appropriately. These rendered faces are now distorted and can be reassembled into a cubemap texture to be used in-game.
    perspective_Distortion.gif

    - - - - -

    I've tried to do the same with the Displace or Pinch filters found in image editing software, but I realised that these filters are linear and you also need "perspective correction" which is something that you only find in 3D software rendering.

    The only way to manually add perspective distortion for making cubemap textures from scratch that I found is by means of the above, using a 3D program.
  • Eric Chadwick
    Options
    Offline / Send Message
    Hey that's a cool trick Kryzon!

    Though if you're working in 3ds Max, a faster/easier way is to put a camera at the origin, construct your scene however you like around it (sphere with a equirectangular pano on it, and 3d paint the seams, layer other maps or geom inside it, etc.), then use the Reflect/Refract map to automatically render the cube faces (as outlined here on the wiki). I've used that method many times to edit/render cubes.

    Edit... if doing Kryzon's method, Reflect/Refract will automate steps 7 and 8.
  • RN
    Options
    Offline / Send Message
    RN sublime tool
    Oh I see, so the Reflect/Refract material already prepares a 90º FOV camera and renders each face.
    So I imagine a possible workflow is:

    1) Create the abstract cubemap as per Valias' post.

    2) Add some distortion to the textures using the modified cube from my post (it's still an approximation, it's not perfect).

    3) On step #7, use the Reflect\Refract material automatic rendering of cubemaps to image files.
  • Eric Chadwick
    Options
    Offline / Send Message
    Sure. Except it's easier to start with Vailias's first step, map it onto a flipped sphere, paint out the seams with 3D paint, then render with Reflect/Refract.

    The Reflect/Refract adds the angular distortion for you, as long as your source looks seamless when you look at it through the "origin" camera.

    Like, don't put that map on a cube, first thing.

    What's cool is you can layer multiple cubemaps together in Max if you want. Map them onto nested cubes, and use step #2 here http://wiki.polycount.com/wiki/Cube_map#Cubemap_Seams to avoid cubemap seams, then use Opacity mapping with a 2nd UV set to blend them however you like.

    And you can layer them with latlong panos too. It's pretty cool.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    :) Good call Eric.

    I was trying to find an "all ps" way of doing it.
    Also I think some games still wind up using a cubemap for a skybox, or at least for reflections. Especially if they're not in the photo-real PBR Category of art direction, so its still important to be able to make a decent cube map.

    ANyhow, I got some decent results by just using photoshop's "spherize" filter. (ALso, protip, if all those layers making the top and bottom are smart objects, they all reference the same image data, so you can apply filters and such and update everything at once without redoing the masking)

    However, projecting from a mapped sphere onto the cube via render to texture definitely gives the smoothest results, But you'll want to create the texture to take the spherical distortion into account ahead of time.
    Examples:
    Photoshop spherize
    abstract_Cube_Distorted.jpg
    [sketchfab]823ef763b11648d7b0f0af76abf6974c[/sketchfab]
    3ds max bake from sphere textured with original horizontally tiling texture onto single smoothing group cube:
    abstract_Cube_SphereProjection.jpg
    [sketchfab]f3a667d3c5cd4c8d83eabfa60567072d[/sketchfab]


    Now the map to sphere and project option definitely has some serious upsides, in that you only need the texture to tile one way, and there's less fixing later.

    But also, that if you're rendering to texture anyway, you can render multiple objects in a scene out, and so make even better use of the 3d software.
  • Justin Meisse
    Options
    Offline / Send Message
    Justin Meisse polycounter lvl 18
    lol, I'm trying to share my test but I don't know how to use sketchfab properly, I'm getting seams and I don't know how to place the camera in the center! It looks good in Unity. <edit> here's my Unity build, there's some jank near the bottom but I was really tired last night and might have goofed some things up.

    [SKETCHFAB]0974ba6fc94c4fdc867e9ba093d1a0cd[/SKETCHFAB]
  • RN
    Options
    Offline / Send Message
    RN sublime tool
    There's that famous problem when you map your texture to a sphere: the details near the poles become "pinched."

    First, the "Polar Coordinates" filter found in Photoshop and GIMP can be useful here as a preview of how your texture will look when mapped on a sphere. You can use this Polar Coordinates filter to see your texture "mapped" on a circle and fix the pinching manually by painting on top of it.
    The GIMP filter has a "Map from top" option that allows you to choose between the top and bottom poles, but with Photoshop you need to flip the texture vertically and use the filter on the flipped version to be able to do that.

    Additionally, Paul Bourke presents a method to distort a texture in order to compensate for the pinching when you map it to a sphere.

    A person implemented Paul's algorithm in Lua, and I ported it to Python as a Python-Fu plugin for GIMP that you can get here:
    https://www.dropbox.com/s/bkkv40yad9at53u/polarCorrection.py?dl=1

    The plugin uses Paul's algorithm to do this:
    spherical_Distortion.png

    That distorted version, when mapped on a sphere, looks [generally] better on the poles.
    sphere_Distortion.png

    (The sphere on the right is the one with the corrected texture.)

    If you use 3ds max and you don't want to download GIMP just to use that script, there's a 3ds max plugin that does the same. It's available as an Utility:
    http://pxfactory.eu/plug/sc/sc.html

    - - - - -
    So with this in hand, you can create a rectangular texture with a square size or in a 2 : 1 ratio, for example, and paint it with your abstract graphics.
    Then you run that spherical-map-correction plugin with GIMP or Max and offset the image horizontally by half the width so you can see and fix the seam that appears, then offset it back to normal.

    Optionally, now you can use the Polar Coordinates built-in filters to see your texture warped as a circle and retouch the pole area, but know that this filter BLURS the entire texture (it loses detail when you go back and forth) and you might want to restore the details around the middle region by keeping an intact copy of the texture before using the Polar Coordinates filter, to lay on top afterwards.Sometimes just painting on the poles with the Polar Coordinates filter will solve the pinching.


    Then you can finally proceed to your 3D program where you'll map the texture to a sphere and 3D paint it some more if you want.
    Then you can render the sphere to a cubemap etc.

    - - - - -
    The difference here is that by working on an image editing program you'll probably have more control over the brushes and details in the texture than if you went straight to 3D painting.
  • Justin Meisse
    Options
    Offline / Send Message
    Justin Meisse polycounter lvl 18
    I actually painted on a subdivided cube with a spherefy modifier on it, so I didn't get any pinching at the poles.
  • RN
    Options
    Offline / Send Message
    RN sublime tool
    Well that is simpler (in a good way).
    I wish I had thought of that before trying the image editing route.
  • Justin Meisse
    Options
    Offline / Send Message
    Justin Meisse polycounter lvl 18
    I think something I did in the rendering caused that weird pinching in the corner, I was doing your cube method until I saw Eric mention that the reflect/refract adds the angular distortion. I was sleepy so I might have mashed methods together, I will try some more experiments this weekend!
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Well if nothing else I think we've shown there are quite a few ways to make a serviceable abstract skybox. :D
  • RN
    Options
    Offline / Send Message
    RN sublime tool
    I've been investigating some other methods but haven't found anything worth the time.
    The quickest ways (and fortunately, with the best results) to make a skybox out of digital painting material seem to be either...

    - Directly painting on the geometry, which can be a geosphere or subdivided cube with a "spherify" modifier, using a 3D paint tool such as 3D-Coat or Blender's texture painting tool. The geometry needs to be UV-mapped with uniform texel density before you texture-paint on it.

    - Painting texture assets and assembling a 3D scene to use them, and render the scene to a cubemap. Then you paint over any seams that appear in the cubemap texture, like this article demonstrates:
    https://judegodin.wordpress.com/2011/12/06/how-the-hell-do-i-make-a-cubemap/
  • Eric Chadwick
    Options
    Offline / Send Message
    Oooh, nice tutorial, thanks for the link.
Sign In or Register to comment.