Index: ps/trunk/binaries/data/mods/public/shaders/arb/sky.vp
===================================================================
--- ps/trunk/binaries/data/mods/public/shaders/arb/sky.vp
+++ ps/trunk/binaries/data/mods/public/shaders/arb/sky.vp
@@ -3,11 +3,13 @@
ATTRIB position = vertex.position;
ATTRIB uv = vertex.texcoord[0];
-DP4 result.position.x, state.matrix.mvp.row[0], position;
-DP4 result.position.y, state.matrix.mvp.row[1], position;
-DP4 result.position.z, state.matrix.mvp.row[2], position;
-DP4 result.position.w, state.matrix.mvp.row[3], position;
+PARAM transform[4] = { program.local[0..3] };
+
+DP4 result.position.x, transform[0], position;
+DP4 result.position.y, transform[1], position;
+DP4 result.position.z, transform[2], position;
+DP4 result.position.w, transform[3], position;
MOV result.texcoord, uv;
-END
\ No newline at end of file
+END
Index: ps/trunk/binaries/data/mods/public/shaders/arb/sky.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/shaders/arb/sky.xml
+++ ps/trunk/binaries/data/mods/public/shaders/arb/sky.xml
@@ -3,6 +3,8 @@
+
+
Index: ps/trunk/binaries/data/mods/public/shaders/effects/sky_simple.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/shaders/effects/sky_simple.xml
+++ ps/trunk/binaries/data/mods/public/shaders/effects/sky_simple.xml
@@ -3,12 +3,12 @@
-
+
-
+
Index: ps/trunk/binaries/data/mods/public/shaders/glsl/sky.fs
===================================================================
--- ps/trunk/binaries/data/mods/public/shaders/glsl/sky.fs
+++ ps/trunk/binaries/data/mods/public/shaders/glsl/sky.fs
@@ -5,12 +5,10 @@
void main()
{
-
- vec4 tex = textureCube(baseTex, v_tex);
+ vec4 tex = textureCube(baseTex, v_tex);
- float m = (1.0 - v_tex.y) - 0.75;
- m *= 4.0;
+ float m = (1.0 - v_tex.y) - 0.75;
+ m *= 4.0;
- gl_FragColor = (v_tex.y > 0.0) ? (tex * m) : tex;
-
+ gl_FragColor = (v_tex.y > 0.0) ? (tex * m) : tex;
}
Index: ps/trunk/binaries/data/mods/public/shaders/glsl/sky.vs
===================================================================
--- ps/trunk/binaries/data/mods/public/shaders/glsl/sky.vs
+++ ps/trunk/binaries/data/mods/public/shaders/glsl/sky.vs
@@ -4,8 +4,10 @@
attribute vec3 a_vertex;
attribute vec3 a_uv0;
+uniform mat4 transform;
+
void main()
{
- gl_Position = gl_ModelViewProjectionMatrix * vec4(a_vertex, 1.0);
- v_tex = gl_MultiTexCoord0.xyz;
+ gl_Position = transform * vec4(a_vertex, 1.0);
+ v_tex = a_uv0.xyz;
}
Index: ps/trunk/binaries/data/mods/public/shaders/glsl/sky.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/shaders/glsl/sky.xml
+++ ps/trunk/binaries/data/mods/public/shaders/glsl/sky.xml
@@ -3,7 +3,9 @@
+
+
Index: ps/trunk/source/renderer/SkyManager.cpp
===================================================================
--- ps/trunk/source/renderer/SkyManager.cpp
+++ ps/trunk/source/renderer/SkyManager.cpp
@@ -198,7 +198,8 @@
#else
// Draw the sky as a small box around the map, with depth write enabled.
- // This will be done before anything else is drawn so we'll be overlapped by everything else.
+ // This will be done before anything else is drawn so we'll be overlapped by
+ // everything else.
// Do nothing unless SetSkySet was called
if (m_SkySet.empty())
@@ -210,32 +211,56 @@
if (g_RenderingOptions.GetRenderPath() == RenderPath::FIXED)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
-
- // Translate so the sky center is at the camera space origin.
- CVector3D cameraPos = g_Renderer.GetViewCamera().GetOrientation().GetTranslation();
- glTranslatef(cameraPos.X, cameraPos.Y, cameraPos.Z);
-
- // Rotate so that the "left" face, which contains the brightest part of each
- // skymap, is in the direction of the sun from our light environment
- glRotatef(180.0f + RADTODEG(g_Renderer.GetLightEnv().GetRotation()), 0.0f, 1.0f, 0.0f);
-
- // Currently we have a hardcoded near plane in the projection matrix.
- glScalef(10.0f, 10.0f, 10.0f);
-
CShaderProgramPtr shader;
CShaderTechniquePtr skytech;
+ const CCamera& camera = g_Renderer.GetViewCamera();
+
if (g_RenderingOptions.GetRenderPath() == RenderPath::SHADER)
{
skytech = g_Renderer.GetShaderManager().LoadEffect(str_sky_simple);
skytech->BeginPass();
shader = skytech->GetShader();
shader->BindTexture(str_baseTex, m_SkyCubeMap);
+
+ // Translate so the sky center is at the camera space origin.
+ CMatrix3D translate;
+ translate.SetTranslation(camera.GetOrientation().GetTranslation());
+
+ // Currently we have a hardcoded near plane in the projection matrix.
+ CMatrix3D scale;
+ scale.SetScaling(10.0f, 10.0f, 10.0f);
+
+ // Rotate so that the "left" face, which contains the brightest part of
+ // each skymap, is in the direction of the sun from our light
+ // environment.
+ CMatrix3D rotate;
+ rotate.SetYRotation(M_PI + g_Renderer.GetLightEnv().GetRotation());
+
+ shader->Uniform(
+ str_transform,
+ camera.GetViewProjection() * translate * rotate * scale);
}
else
{
+ glMatrixMode(GL_MODELVIEW);
+ // Modify current matrix that already contains view part.
+ glPushMatrix();
+
+ // Translate so the sky center is at the camera space origin.
+ CVector3D cameraPos = camera.GetOrientation().GetTranslation();
+ glTranslatef(cameraPos.X, cameraPos.Y, cameraPos.Z);
+
+ // Rotate so that the "left" face, which contains the brightest part of
+ // each skymap, is in the direction of the sun from our light
+ // environment.
+ glRotatef(
+ 180.0f + RADTODEG(g_Renderer.GetLightEnv().GetRotation()),
+ 0.0f, 1.0f, 0.0f);
+
+ // Currently we have a hardcoded near plane in the projection matrix.
+ glScalef(10.0f, 10.0f, 10.0f);
+
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_CUBE_MAP);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_SkyCubeMap);
@@ -290,9 +315,9 @@
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
glDisable(GL_TEXTURE_CUBE_MAP);
glEnable(GL_TEXTURE_2D);
- }
- glPopMatrix();
+ glPopMatrix();
+ }
if (g_RenderingOptions.GetRenderPath() == RenderPath::FIXED)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);