Some more conversion
This commit is contained in:
parent
3a55bbe796
commit
42482e0c41
@ -25,7 +25,7 @@ void main()
|
||||
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
|
||||
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
|
||||
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = 1.;
|
||||
}
|
||||
|
@ -1,6 +1,14 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
@ -23,6 +31,8 @@ varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||
uv = Texcoord;
|
||||
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
|
||||
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
|
||||
|
@ -1,5 +1,15 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
uniform mat4 TextureMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
@ -11,9 +21,11 @@ in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec3 Normal;
|
||||
@ -27,6 +39,9 @@ varying vec2 uv_bis;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
color = Color.zyxw;
|
||||
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
|
@ -6,17 +6,17 @@ uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 normal;
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec3 normal;
|
||||
varying vec3 nor;
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
float rim = 1.0 - dot(normal, vec3(0., 0., -1));
|
||||
float rim = 1.0 - dot(nor, vec3(0., 0., -1));
|
||||
rim = smoothstep(0.5, 1.5, rim) * 0.35;
|
||||
|
||||
vec4 color = texture(Albedo, uv);
|
||||
|
@ -1,25 +0,0 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
uniform mat4 TextureMatrix;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec2 Texcoord;
|
||||
in vec4 Color;
|
||||
out vec2 uv;
|
||||
out vec3 normal;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec3 Normal;
|
||||
attribute vec2 Texcoord;
|
||||
attribute vec4 Color;
|
||||
varying vec2 uv;
|
||||
varying vec3 normal;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
normal = (TransposeInverseModelView * vec4(Normal, 0)).xyz;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
}
|
@ -1,7 +1,14 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform samplerCube tex;
|
||||
uniform mat4 invproj;
|
||||
uniform vec2 screen;
|
||||
uniform mat4 TransposeViewMatrix;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
@ -15,12 +22,12 @@ varying vec3 nor;
|
||||
void main() {
|
||||
vec3 fpos = gl_FragCoord.xyz / vec3(screen, 1.);
|
||||
vec4 xpos = 2.0 * vec4(fpos, 1.0) - 1.0;
|
||||
xpos = invproj * xpos;
|
||||
xpos = InverseProjectionMatrix * xpos;
|
||||
|
||||
xpos.xyz /= xpos.w;
|
||||
vec3 viewSampleDir = reflect(xpos.xyz, nor);
|
||||
// Convert sampleDir in world space (where tex was generated)
|
||||
vec4 sampleDir = TransposeViewMatrix * vec4(viewSampleDir, 0.);
|
||||
vec4 sampleDir = transpose(InverseViewMatrix) * vec4(viewSampleDir, 0.);
|
||||
vec4 detail0 = texture(tex, sampleDir.xyz);
|
||||
|
||||
FragColor = vec4(detail0.xyz, 1.);
|
||||
|
@ -1,5 +1,13 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform samplerCube tex;
|
||||
uniform mat4 InvProjView;
|
||||
uniform vec2 screen;
|
||||
|
||||
|
||||
@ -14,7 +22,7 @@ void main(void)
|
||||
{
|
||||
vec3 eyedir = gl_FragCoord.xyz / vec3(screen, 1.);
|
||||
eyedir = 2.0 * eyedir - 1.0;
|
||||
vec4 tmp = (InvProjView * vec4(eyedir, 1.));
|
||||
vec4 tmp = (InverseViewMatrix * InverseProjectionMatrix * vec4(eyedir, 1.));
|
||||
eyedir = tmp.xyz / tmp.w;
|
||||
vec4 color = texture(tex, eyedir);
|
||||
FragColor = vec4(color.xyz, 1.);
|
||||
|
@ -1,41 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 the SuperTuxKart team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec2 Texcoord;
|
||||
attribute vec2 SecondTexcoord;
|
||||
varying vec2 uv;
|
||||
varying vec2 uv_bis;
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
uv = Texcoord;
|
||||
uv_bis = SecondTexcoord;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
}
|
@ -1,4 +1,13 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
@ -14,5 +23,5 @@ varying vec4 color;
|
||||
void main(void)
|
||||
{
|
||||
color = Color.zyxw;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
|
||||
}
|
||||
|
@ -464,6 +464,7 @@ void IrrDriver::renderSolidSecondPass()
|
||||
GroupedSM<SM_SPLATTING>::reset();
|
||||
GroupedSM<SM_UNLIT>::reset();
|
||||
GroupedSM<SM_DETAILS>::reset();
|
||||
GroupedSM<SM_UNTEXTURED>::reset();
|
||||
setTexture(0, m_rtts->getRenderTarget(RTT_TMP1), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, m_rtts->getRenderTarget(RTT_TMP2), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(2, m_rtts->getRenderTarget(RTT_SSAO), GL_NEAREST, GL_NEAREST);
|
||||
@ -497,6 +498,10 @@ void IrrDriver::renderSolidSecondPass()
|
||||
for (unsigned i = 0; i < GroupedSM<SM_DETAILS>::MeshSet.size(); i++)
|
||||
drawDetailledObjectPass2(*GroupedSM<SM_DETAILS>::MeshSet[i], GroupedSM<SM_DETAILS>::MVPSet[i]);
|
||||
|
||||
glUseProgram(MeshShader::UntexturedObjectShader::Program);
|
||||
for (unsigned i = 0; i < GroupedSM<SM_UNTEXTURED>::MeshSet.size(); i++)
|
||||
drawUntexturedObject(*GroupedSM<SM_UNTEXTURED>::MeshSet[i], GroupedSM<SM_UNTEXTURED>::MVPSet[i]);
|
||||
|
||||
}
|
||||
|
||||
void IrrDriver::renderTransparent()
|
||||
@ -1328,7 +1333,7 @@ void IrrDriver::renderSkybox()
|
||||
glBindVertexArray(MeshShader::SkyboxShader::cubevao);
|
||||
glDisable(GL_CULL_FACE);
|
||||
assert(SkyboxTextures.size() == 6);
|
||||
core::matrix4 transform = irr_driver->getProjViewMatrix();
|
||||
|
||||
core::matrix4 translate;
|
||||
translate.setTranslation(camera->getAbsolutePosition());
|
||||
|
||||
@ -1336,7 +1341,7 @@ void IrrDriver::renderSkybox()
|
||||
const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
|
||||
core::matrix4 scale;
|
||||
scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
|
||||
transform *= translate * scale;
|
||||
core::matrix4 transform = translate * scale;
|
||||
core::matrix4 invtransform;
|
||||
transform.getInverse(invtransform);
|
||||
|
||||
@ -1345,7 +1350,7 @@ void IrrDriver::renderSkybox()
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glUseProgram(MeshShader::SkyboxShader::Program);
|
||||
MeshShader::SkyboxShader::setUniforms(transform, invtransform, core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 0);
|
||||
MeshShader::SkyboxShader::setUniforms(transform, core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 0);
|
||||
glDrawElements(GL_TRIANGLES, 6 * 6, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,10 +39,10 @@ class ObjectPass1Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_normal;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_tex;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_tex);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_tex);
|
||||
};
|
||||
|
||||
class ObjectRefPass1Shader
|
||||
@ -50,10 +50,10 @@ class ObjectRefPass1Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_TIMV, uniform_tex;
|
||||
static GLuint uniform_MM, uniform_TM, uniform_IMM, uniform_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_texture);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_texture);
|
||||
};
|
||||
|
||||
class GrassPass1Shader
|
||||
@ -72,10 +72,10 @@ class NormalMapShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_tangent, attrib_bitangent;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_normalMap;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_normalMap;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_normalMap);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_normalMap);
|
||||
};
|
||||
|
||||
class InstancedObjectPass1Shader
|
||||
@ -116,11 +116,11 @@ class ObjectPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix);
|
||||
};
|
||||
|
||||
class InstancedObjectPass2Shader
|
||||
@ -152,11 +152,11 @@ class DetailledObjectPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo, TU_detail;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix);
|
||||
};
|
||||
|
||||
class ObjectRimLimitShader
|
||||
@ -164,11 +164,11 @@ class ObjectRimLimitShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const core::matrix4 &TextureMatrix);
|
||||
};
|
||||
|
||||
class UntexturedObjectShader
|
||||
@ -176,10 +176,10 @@ class UntexturedObjectShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_screen, uniform_ambient;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix);
|
||||
};
|
||||
|
||||
class ObjectUnlitShader
|
||||
@ -187,11 +187,11 @@ class ObjectUnlitShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP;
|
||||
static GLuint uniform_MM;
|
||||
static GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix);
|
||||
};
|
||||
|
||||
class ObjectRefPass2Shader
|
||||
@ -199,11 +199,11 @@ class ObjectRefPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix);
|
||||
};
|
||||
|
||||
class GrassPass2Shader
|
||||
@ -235,11 +235,11 @@ class SphereMapShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TVM, uniform_invproj, uniform_screen;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_screen;
|
||||
static GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const core::vector2df& screen);
|
||||
};
|
||||
|
||||
class SplattingShader
|
||||
@ -247,11 +247,11 @@ class SplattingShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix);
|
||||
};
|
||||
|
||||
class CausticsShader
|
||||
@ -403,11 +403,11 @@ class SkyboxShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position;
|
||||
static GLuint uniform_MVP, uniform_InvProjView, uniform_tex, uniform_screen;
|
||||
static GLuint uniform_MM, uniform_tex, uniform_screen;
|
||||
static GLuint cubevao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &InvProjView, const core::vector2df &screen, unsigned TU_tex);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &screen, unsigned TU_tex);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -145,19 +145,21 @@ void STKAnimatedMesh::render()
|
||||
{
|
||||
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
|
||||
TransposeInverseModelView = computeTIMV(AbsoluteTransformation);
|
||||
core::matrix4 invmodel;
|
||||
AbsoluteTransformation.getInverse(invmodel);
|
||||
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||
{
|
||||
GroupedFPSM<FPSM_DEFAULT>::MeshSet.push_back(GeometricMesh[FPSM_DEFAULT][i]);
|
||||
GroupedFPSM<FPSM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedFPSM<FPSM_DEFAULT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedFPSM<FPSM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_DEFAULT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||
{
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MeshSet.push_back(GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -165,39 +167,42 @@ void STKAnimatedMesh::render()
|
||||
|
||||
if (irr_driver->getPhase() == SOLID_LIT_PASS)
|
||||
{
|
||||
core::matrix4 invmodel;
|
||||
AbsoluteTransformation.getInverse(invmodel);
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
|
||||
{
|
||||
GroupedSM<SM_DEFAULT>::MeshSet.push_back(ShadedMesh[SM_DEFAULT][i]);
|
||||
GroupedSM<SM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_DEFAULT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_DEFAULT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
|
||||
{
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MeshSet.push_back(ShadedMesh[SM_ALPHA_REF_TEXTURE][i]);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
|
||||
{
|
||||
GroupedSM<SM_RIMLIT>::MeshSet.push_back(ShadedMesh[SM_RIMLIT][i]);
|
||||
GroupedSM<SM_RIMLIT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_RIMLIT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_RIMLIT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_RIMLIT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_UNLIT])
|
||||
{
|
||||
GroupedSM<SM_UNLIT>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_UNLIT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_UNLIT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_UNLIT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_UNLIT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_DETAILS])
|
||||
{
|
||||
GroupedSM<SM_DETAILS>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_DETAILS>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_DETAILS>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_DETAILS>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_DETAILS>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -269,7 +269,7 @@ void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelMatrix, const core::matrix4 &InverseModelMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
@ -279,14 +279,14 @@ void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
||||
assert(mesh.textures[1]);
|
||||
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
|
||||
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
|
||||
MeshShader::NormalMapShader::setUniforms(ModelMatrix, InverseModelMatrix, 0);
|
||||
|
||||
assert(mesh.vao_first_pass);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
@ -306,7 +306,7 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
|
||||
MeshShader::SphereMapShader::setUniforms(ModelViewProjectionMatrix, irr_driver->getViewMatrix().getTransposed(), TransposeInverseModelView, irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height));
|
||||
MeshShader::SphereMapShader::setUniforms(ModelMatrix, InverseModelMatrix, core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height));
|
||||
|
||||
assert(mesh.vao_second_pass);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
@ -476,14 +476,14 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
MeshShader::UntexturedObjectShader::setUniforms(ModelViewProjectionMatrix);
|
||||
MeshShader::UntexturedObjectShader::setUniforms(ModelMatrix);
|
||||
|
||||
assert(mesh.vao_second_pass);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
|
@ -90,7 +90,7 @@ template<enum GeometricMaterial T>
|
||||
std::vector<core::matrix4> GroupedFPSM<T>::TIMVSet;
|
||||
|
||||
void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
||||
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
||||
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelMatrix, const core::matrix4 &InverseModelMatrix);
|
||||
void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
||||
void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir);
|
||||
|
||||
|
@ -336,26 +336,28 @@ void STKMeshSceneNode::render()
|
||||
glDisable(GL_CULL_FACE);
|
||||
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
|
||||
TransposeInverseModelView = computeTIMV(AbsoluteTransformation);
|
||||
core::matrix4 invmodel;
|
||||
AbsoluteTransformation.getInverse(invmodel);
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||
{
|
||||
|
||||
GroupedFPSM<FPSM_DEFAULT>::MeshSet.push_back(GeometricMesh[FPSM_DEFAULT][i]);
|
||||
GroupedFPSM<FPSM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedFPSM<FPSM_DEFAULT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedFPSM<FPSM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_DEFAULT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||
{
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MeshSet.push_back(GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_NORMAL_MAP].size(); i++)
|
||||
{
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::MeshSet.push_back(GeometricMesh[FPSM_NORMAL_MAP][i]);
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
if (!GeometricMesh[FPSM_GRASS].empty())
|
||||
@ -373,54 +375,64 @@ void STKMeshSceneNode::render()
|
||||
if (reload_each_frame)
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
core::matrix4 invmodel;
|
||||
AbsoluteTransformation.getInverse(invmodel);
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
|
||||
{
|
||||
GroupedSM<SM_DEFAULT>::MeshSet.push_back(ShadedMesh[SM_DEFAULT][i]);
|
||||
GroupedSM<SM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_DEFAULT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_DEFAULT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
|
||||
{
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MeshSet.push_back(ShadedMesh[SM_ALPHA_REF_TEXTURE][i]);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
|
||||
{
|
||||
GroupedSM<SM_RIMLIT>::MeshSet.push_back(ShadedMesh[SM_RIMLIT][i]);
|
||||
GroupedSM<SM_RIMLIT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_RIMLIT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_RIMLIT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_RIMLIT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_SPHEREMAP].size(); i++)
|
||||
{
|
||||
GroupedSM<SM_SPHEREMAP>::MeshSet.push_back(ShadedMesh[SM_SPHEREMAP][i]);
|
||||
GroupedSM<SM_SPHEREMAP>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_SPHEREMAP>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_SPHEREMAP>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_SPHEREMAP>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_SPLATTING])
|
||||
{
|
||||
GroupedSM<SM_SPLATTING>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_SPLATTING>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_SPLATTING>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_SPLATTING>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_SPLATTING>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_UNLIT])
|
||||
{
|
||||
GroupedSM<SM_UNLIT>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_UNLIT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_UNLIT>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_UNLIT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_UNLIT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_DETAILS])
|
||||
{
|
||||
GroupedSM<SM_DETAILS>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_DETAILS>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
GroupedSM<SM_DETAILS>::TIMVSet.push_back(TransposeInverseModelView);
|
||||
GroupedSM<SM_DETAILS>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_DETAILS>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_UNTEXTURED])
|
||||
{
|
||||
GroupedSM<SM_UNTEXTURED>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_UNTEXTURED>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_UNTEXTURED>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
if (!ShadedMesh[SM_GRASS].empty())
|
||||
@ -433,11 +445,6 @@ void STKMeshSceneNode::render()
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_CAUSTICS].size(); i++)
|
||||
drawSolidPass2(*ShadedMesh[SM_CAUSTICS][i], SM_CAUSTICS);
|
||||
|
||||
if (!ShadedMesh[SM_UNTEXTURED].empty())
|
||||
glUseProgram(MeshShader::UntexturedObjectShader::Program);
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_UNTEXTURED].size(); i++)
|
||||
drawSolidPass2(*ShadedMesh[SM_UNTEXTURED][i], SM_UNTEXTURED);
|
||||
|
||||
if (reload_each_frame)
|
||||
glEnable(GL_CULL_FACE);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user