Terragen SkySphere ???

I was wondering if there’s a way to create a texture for a SkySphere with Terragen and then apply this texture to a hemisphere or sphere using MilkShape or Blender.

So, could someone please help me, by showing me how to do this ???

THX

i havent heared about skyspheres… but it’s easy to create a skybox :slight_smile: . there are a number of tutorials you can find when googling. those are not directly for panda but they work too.

en.wikipedia.org/wiki/Skybox_%28video_games%29

I did managed to create a SkyCube using Terragen, a script for Terragen and MilkShape… but when I imported the textured cube in Panda… the texture was no longer seamless… There were bright white lines where the polygons of the cube joined…

I guess this is caused by the light in the scene… any clues???

Well, not exactly an answer to your question, but perhaps this is useful for you.

I prefer sky spheres or sky domes over sky boxes, since it easier to move clouds around on a sphere than on a box. The following script creates a textured sky dome (the upper part of a hemisphere, from zenith down to about 45 degrees). It can be used with a tileable sky/cloud texture.

I don’t create a full hemisphere because I don’t like the vertical parts at the horizon, and even with scaling in horizontal dimension you have these vertical parts. A hemisphere would be ok for starfields since the stars a very very far away, while clouds usually have a finite altitude. 45 degrees would be a cloud altitude of about 6000km if I am right.

This approach works well with tileable, moving cloud textures, but if you want to have parts of the horizon (distant mountains etc.) on you sky then it won’t help you.

Usage: just load the model, re-parent it somewhere, and scale it to your camera’s far distance (actually, a bit less). Oh, and move it around with your camera.

enn0x

from pandac.PandaModules import EggData
from pandac.PandaModules import EggPolygon
from pandac.PandaModules import EggTexture
from pandac.PandaModules import EggVertex
from pandac.PandaModules import EggVertexPool
from pandac.PandaModules import Filename
from pandac.PandaModules import Point2D
from pandac.PandaModules import Point3D

import math
import os

nrows = 6
ncols = 16
uvscale = 2.8
texture = 'clouds.png'

sqrt2 = math.sqrt( 2.0 )

def makePoly( g, vlist ):
    _poly = EggPolygon( )

    for _v in vlist:
        _poly.addVertex( _v )

    g.addChild( _poly )

def makeVertex( x, y, z, u, v ):
    _v = EggVertex( )

    _v.setPos( Point3D( x, y, z ) )
    _v.setUv( Point2D( u, v ) )

    vp.addVertex( _v )
    return _v

# egg data
vp = EggVertexPool( 'sky' )

data = EggData( )
data.addChild( vp )
data.setCoordinateSystem( 1 ) # CS_zup_right

# vertices
zenith = makeVertex( 0.0, 0.0, sqrt2 - 1.0, 0.0, 0.0 )
vertices = { }
for j in range( 1, nrows + 1 ):
    for i in range( ncols ):
        phi = math.radians( 360.0 / ncols * i )
        theta = math.radians( 45.0 / nrows * j )

        x = sqrt2 * math.sin( theta ) * math.cos( phi )
        y = sqrt2 * math.sin( theta ) * math.sin( phi )
        z = sqrt2 * math.cos( theta ) - 1.0

        factor = uvscale
        u = x * factor
        v = y * factor

        vertices[ ( j, i ) ] = makeVertex( x, y, z, u, v )

# triangles ( first row )
for i in range( ncols ):
    v1 = zenith
    v2 = vertices[ ( 1, ( i + 1 ) % ncols ) ]
    v3 = vertices[ ( 1, i ) ]

    makePoly( data, [ v1, v2, v3 ] )

# quads ( other rows )
for j in range( 1, nrows ):
    for i in range( ncols ):
        i0 = i
        i1 = ( i + 1 ) % ncols
        j0 = j
        j1 = j + 1

        v1 = vertices[ ( j0, i0 ) ]
        v2 = vertices[ ( j0, i1 ) ]
        v3 = vertices[ ( j1, i1 ) ]
        v4 = vertices[ ( j1, i0 ) ]

        makePoly( data, [ v1, v2, v3, v4 ] )

# texture
tex = EggTexture( 'clouds', texture )
tex.setMagfilter( EggTexture.FTLinearMipmapLinear )
tex.setMinfilter( EggTexture.FTLinearMipmapLinear )

n = data.getFirstChild( )
while n:
    if type( n ) == EggPolygon:
        n.addTexture( tex )
    n = data.getNextChild( )

# save
data.writeEgg( Filename( 'sky.egg' ) )

# egg2bam
os.system( 'egg2bam sky.egg -o sky.bam' )

WHOOA!!! Thanks enn0x!!! this script really helped… I now have a perfectly working sky… except now I don’t have tileable sky textures… but that shouldn’t be a big problem