Removes old matrices from sky rendering in shader path.
Tested By: Stan Differential Revision: https://code.wildfiregames.com/D2943 This was SVN commit r23952.
This commit is contained in:
parent
36c1566640
commit
4c1847d3db
@ -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
|
||||
END
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
<vertex file="arb/sky.vp">
|
||||
<stream name="pos"/>
|
||||
<stream name="uv0"/>
|
||||
<uniform name="transform" loc="0" type="mat4"/>
|
||||
</vertex>
|
||||
|
||||
<fragment file="arb/sky.fp">
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
<technique>
|
||||
<require shaders="arb"/>
|
||||
<pass shader="arb/sky"/>
|
||||
<pass shader="arb/sky"/>
|
||||
</technique>
|
||||
|
||||
<technique>
|
||||
<require shaders="glsl"/>
|
||||
<pass shader="glsl/sky"/>
|
||||
<pass shader="glsl/sky"/>
|
||||
</technique>
|
||||
|
||||
</effect>
|
||||
|
@ -5,12 +5,10 @@ varying vec3 v_tex;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ varying vec3 v_tex;
|
||||
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;
|
||||
}
|
||||
|
@ -3,7 +3,9 @@
|
||||
|
||||
<vertex file="glsl/sky.vs">
|
||||
<stream name="pos"/>
|
||||
<stream name="uv0"/>
|
||||
<attrib name="a_vertex" semantics="gl_Vertex"/>
|
||||
<attrib name="a_uv0" semantics="gl_MultiTexCoord0"/>
|
||||
</vertex>
|
||||
|
||||
<fragment file="glsl/sky.fs"/>
|
||||
|
@ -198,7 +198,8 @@ void SkyManager::RenderSky()
|
||||
#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 @@ void SkyManager::RenderSky()
|
||||
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 @@ void SkyManager::RenderSky()
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user