So I'm planning to replace the background rectangle by a skybox. But I don't know how to get rid of the visible edges and corners of the cube. Is this possible, or should I use a skysphere instead?
Here's my simple example:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" GLBase="1" CameraPosition="0 0 0" FileVersion="2">
<OnLoaded>
<SpawnModel Model="Model_Background" SpawnStyle="1"/>
</OnLoaded>
<Content>
<Mesh Name="Mesh_Skybox">
<Producers>
<MeshBox Scale="10 10 10"/>
</Producers>
</Mesh>
<Mesh Name="Mesh_Skysphere">
<Producers>
<MeshBox Scale="1 0.5 1" XCount="18" YCount="12" Grid2DOnly="255"/>
<MeshExpression AutoNormals="0">
<Expression>
<![CDATA[//
float E, A, K, X, Y, Z;
// Convert range to radians
E = v.Y*PI; // Elevation
A = v.X*PI; // Azimuth
// Convert spherical coordinates into cartesian
K = cos(E);
X = sin(A)*K;
Y = sin(E);
Z = cos(A)*K;
// Assign coordinates
v.X = X;
v.Y = Y;
v.Z = Z;
n.X = X;
n.Y = Y;
n.Z = Z;]]>
</Expression>
</MeshExpression>
<MeshTransform Scale="10 10 10"/>
</Producers>
</Mesh>
<Model Name="Model_Background" Comment="Sky, stars and space clouds" Rotation="33.7335 31.8522 0" RotationVelocity="0.02 0.02 0">
<OnRender>
<UseMaterial Material="Material_Clouds"/>
<RenderMesh Mesh="Mesh_Skybox"/>
</OnRender>
</Model>
<Material Name="Material_Clouds" Shading="1" Light="0" ZBuffer="0" DrawBackFace="255" Shader="TextureShader">
<Textures>
<MaterialTexture Texture="Bitmap_Clouds"/>
</Textures>
</Material>
<Bitmap Name="Bitmap_Clouds" Height="32">
<Producers>
<BitmapNoise Name="BackgroundNoise" Offset="0.1159" Persistence="0.2" ZHeight="165.4777" Tile="255"/>
</Producers>
</Bitmap>
<Shader Name="TextureShader">
<VertexShaderSource>
<![CDATA[//
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
uniform mat4 modelViewProjectionMatrix;
attribute vec4 position; // vertex position
attribute vec2 texCoord; // texture coordinates
varying vec2 t;
void main()
{
gl_Position = modelViewProjectionMatrix * position;
t = texCoord;
}]]>
</VertexShaderSource>
<FragmentShaderSource>
<![CDATA[//
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D tex1;
varying vec2 t;
void main()
{
gl_FragColor = vec4(texture2D(tex1, t).rgb, 1.0);
}]]>
</FragmentShaderSource>
</Shader>
</Content>
</ZApplication>