Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
e63ad2754d
@ -2,6 +2,7 @@ uniform float blueLmn[9];
|
|||||||
uniform float greenLmn[9];
|
uniform float greenLmn[9];
|
||||||
uniform float redLmn[9];
|
uniform float redLmn[9];
|
||||||
uniform sampler2D ntex;
|
uniform sampler2D ntex;
|
||||||
|
uniform mat4 TransposeViewMatrix;
|
||||||
|
|
||||||
#if __VERSION__ >= 130
|
#if __VERSION__ >= 130
|
||||||
in vec2 uv;
|
in vec2 uv;
|
||||||
@ -35,7 +36,9 @@ mat4 getMatrix(float L[9])
|
|||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||||
vec4 extendednormal = vec4(normal, 1.);
|
// Convert normal in world space (where SH coordinates were computed)
|
||||||
|
vec4 extendednormal = TransposeViewMatrix * vec4(normal, 1.);
|
||||||
|
extendednormal.w = 1.;
|
||||||
mat4 rmat = getMatrix(redLmn);
|
mat4 rmat = getMatrix(redLmn);
|
||||||
mat4 gmat = getMatrix(greenLmn);
|
mat4 gmat = getMatrix(greenLmn);
|
||||||
mat4 bmat = getMatrix(blueLmn);
|
mat4 bmat = getMatrix(blueLmn);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
uniform samplerCube tex;
|
uniform samplerCube tex;
|
||||||
uniform mat4 invproj;
|
uniform mat4 invproj;
|
||||||
uniform vec2 screen;
|
uniform vec2 screen;
|
||||||
|
uniform mat4 TransposeViewMatrix;
|
||||||
|
|
||||||
#if __VERSION__ >= 130
|
#if __VERSION__ >= 130
|
||||||
in vec3 nor;
|
in vec3 nor;
|
||||||
@ -17,7 +18,10 @@ void main() {
|
|||||||
xpos = invproj * xpos;
|
xpos = invproj * xpos;
|
||||||
|
|
||||||
xpos.xyz /= xpos.w;
|
xpos.xyz /= xpos.w;
|
||||||
vec4 detail0 = texture(tex, reflect(xpos.xyz, nor));
|
vec3 viewSampleDir = reflect(xpos.xyz, nor);
|
||||||
|
// Convert sampleDir in world space (where tex was generated)
|
||||||
|
vec4 sampleDir = TransposeViewMatrix * vec4(viewSampleDir, 0.);
|
||||||
|
vec4 detail0 = texture(tex, sampleDir.xyz);
|
||||||
|
|
||||||
FragColor = vec4(detail0.xyz, 1.);
|
FragColor = vec4(detail0.xyz, 1.);
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
uniform sampler2D ntex;
|
uniform sampler2D ntex;
|
||||||
uniform sampler2D dtex;
|
uniform sampler2D dtex;
|
||||||
|
|
||||||
uniform vec4 center[16];
|
|
||||||
uniform vec4 col[16];
|
|
||||||
uniform float energy[16];
|
|
||||||
uniform float spec;
|
uniform float spec;
|
||||||
uniform mat4 invproj;
|
uniform mat4 invproj;
|
||||||
uniform mat4 viewm;
|
uniform mat4 ViewMatrix;
|
||||||
|
uniform vec2 screen;
|
||||||
|
|
||||||
|
flat in vec3 center;
|
||||||
|
flat in float energy;
|
||||||
|
flat in vec3 col;
|
||||||
|
|
||||||
#if __VERSION__ >= 130
|
|
||||||
in vec2 uv;
|
|
||||||
out vec4 Diffuse;
|
out vec4 Diffuse;
|
||||||
out vec4 Specular;
|
out vec4 Specular;
|
||||||
#else
|
|
||||||
varying vec2 uv;
|
|
||||||
#define Diffuse gl_FragData[0]
|
|
||||||
#define Specular gl_FragData[1]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
vec3 DecodeNormal(vec2 n)
|
vec3 DecodeNormal(vec2 n)
|
||||||
{
|
{
|
||||||
@ -27,7 +20,7 @@ vec3 DecodeNormal(vec2 n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 texc = uv;
|
vec2 texc = gl_FragCoord.xy / screen;
|
||||||
float z = texture(dtex, texc).x;
|
float z = texture(dtex, texc).x;
|
||||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, texc).xy - 1.));
|
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, texc).xy - 1.));
|
||||||
|
|
||||||
@ -38,25 +31,23 @@ void main() {
|
|||||||
|
|
||||||
vec3 diffuse = vec3(0.), specular = vec3(0.);
|
vec3 diffuse = vec3(0.), specular = vec3(0.);
|
||||||
|
|
||||||
for (int i = 0; i < 16; ++i) {
|
vec4 pseudocenter = ViewMatrix * vec4(center.xyz, 1.0);
|
||||||
vec4 pseudocenter = viewm * vec4(center[i].xyz, 1.0);
|
pseudocenter /= pseudocenter.w;
|
||||||
pseudocenter /= pseudocenter.w;
|
vec3 light_pos = pseudocenter.xyz;
|
||||||
vec3 light_pos = pseudocenter.xyz;
|
vec3 light_col = col.xyz;
|
||||||
vec3 light_col = col[i].xyz;
|
float d = distance(light_pos, xpos.xyz);
|
||||||
float d = distance(light_pos, xpos.xyz);
|
float att = energy * 200. / (4. * 3.14 * d * d);
|
||||||
float att = energy[i] * 200. / (4. * 3.14 * d * d);
|
float spec_att = (energy + 10.) * 200. / (4. * 3.14 * d * d);
|
||||||
float spec_att = (energy[i] + 10.) * 200. / (4. * 3.14 * d * d);
|
|
||||||
|
|
||||||
// Light Direction
|
// Light Direction
|
||||||
vec3 L = normalize(xpos.xyz - light_pos);
|
vec3 L = normalize(xpos.xyz - light_pos);
|
||||||
|
|
||||||
float NdotL = max(0.0, dot(norm, -L));
|
float NdotL = max(0.0, dot(norm, -L));
|
||||||
diffuse += NdotL * light_col * att;
|
diffuse += NdotL * light_col * att;
|
||||||
// Reflected light dir
|
// Reflected light dir
|
||||||
vec3 R = reflect(-L, norm);
|
vec3 R = reflect(-L, norm);
|
||||||
float RdotE = max(0.0, dot(R, eyedir));
|
float RdotE = max(0.0, dot(R, eyedir));
|
||||||
specular += pow(RdotE, spec) * light_col * spec_att;
|
specular += pow(RdotE, spec) * light_col * spec_att;
|
||||||
}
|
|
||||||
|
|
||||||
Diffuse = vec4(diffuse, 1.);
|
Diffuse = vec4(diffuse, 1.);
|
||||||
Specular = vec4(specular , 1.);
|
Specular = vec4(specular , 1.);
|
||||||
|
38
data/shaders/pointlight.vert
Normal file
38
data/shaders/pointlight.vert
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
uniform mat4 ViewMatrix;
|
||||||
|
uniform mat4 ProjectionMatrix;
|
||||||
|
|
||||||
|
in vec3 Position;
|
||||||
|
in float Energy;
|
||||||
|
in vec3 Color;
|
||||||
|
|
||||||
|
in vec2 Corner;
|
||||||
|
|
||||||
|
flat out vec3 center;
|
||||||
|
flat out float energy;
|
||||||
|
flat out vec3 col;
|
||||||
|
|
||||||
|
const float zNear = 1.;
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
// Beyond that value, light is too attenuated
|
||||||
|
float r = 40 * Energy;
|
||||||
|
center = Position;
|
||||||
|
energy = Energy;
|
||||||
|
vec4 Center = ViewMatrix * vec4(Position, 1.);
|
||||||
|
if (Center.z > zNear) // Light is in front of the cam
|
||||||
|
{
|
||||||
|
vec3 UnitCenter = normalize(-Center.xyz);
|
||||||
|
float clampedR = min(r, Center.z - 1.);
|
||||||
|
float cosTheta = dot(UnitCenter, vec3(0., 0., -1));
|
||||||
|
float d = clampedR / cosTheta;
|
||||||
|
Center.xyz += d * UnitCenter;
|
||||||
|
}
|
||||||
|
else if (Center.z + r > zNear) // Light is behind the cam but in range
|
||||||
|
{
|
||||||
|
Center.z = zNear;
|
||||||
|
// TODO: Change r so that we make the screen aligned quad fits light range.
|
||||||
|
}
|
||||||
|
col = Color;
|
||||||
|
gl_Position = ProjectionMatrix * (Center + r * vec4(Corner, 0., 0.));
|
||||||
|
}
|
@ -280,28 +280,6 @@ void renderColorLevel(ITexture *in)
|
|||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessing::renderPointlight(const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy)
|
|
||||||
{
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
|
||||||
glBlendFunc(GL_ONE, GL_ONE);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
glUseProgram(FullScreenShader::PointLightShader::Program);
|
|
||||||
glBindVertexArray(FullScreenShader::PointLightShader::vao);
|
|
||||||
|
|
||||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(1, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
|
||||||
FullScreenShader::PointLightShader::setUniforms(irr_driver->getInvProjMatrix(), irr_driver->getViewMatrix(), positions, colors, energy, 200, 0, 1);
|
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
glBindVertexArray(0);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff)
|
void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff)
|
||||||
{
|
{
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
@ -313,7 +291,8 @@ void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSH
|
|||||||
glBindVertexArray(FullScreenShader::DiffuseEnvMapShader::vao);
|
glBindVertexArray(FullScreenShader::DiffuseEnvMapShader::vao);
|
||||||
|
|
||||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
||||||
FullScreenShader::DiffuseEnvMapShader::setUniforms(bSHCoeff, gSHCoeff, rSHCoeff, 0);
|
core::matrix4 TVM = irr_driver->getViewMatrix().getTransposed();
|
||||||
|
FullScreenShader::DiffuseEnvMapShader::setUniforms(TVM, bSHCoeff, gSHCoeff, rSHCoeff, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
@ -73,7 +73,6 @@ public:
|
|||||||
void update(float dt);
|
void update(float dt);
|
||||||
|
|
||||||
/** Generate diffuse and specular map */
|
/** Generate diffuse and specular map */
|
||||||
void renderPointlight(const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy);
|
|
||||||
void renderSunlight();
|
void renderSunlight();
|
||||||
void renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
|
void renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
|
||||||
|
|
||||||
|
@ -236,6 +236,14 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||||
|
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
||||||
|
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
||||||
|
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
||||||
|
if (!UserConfigParams::m_ssao)
|
||||||
|
{
|
||||||
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
||||||
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
|
}
|
||||||
m_scene_manager->drawAll(m_renderpass);
|
m_scene_manager->drawAll(m_renderpass);
|
||||||
|
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
@ -736,6 +744,73 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
#define MAXLIGHT 16 // to be adjusted in pointlight.frag too
|
#define MAXLIGHT 16 // to be adjusted in pointlight.frag too
|
||||||
|
|
||||||
|
|
||||||
|
static GLuint pointlightvbo = 0;
|
||||||
|
static GLuint pointlightsvao = 0;
|
||||||
|
|
||||||
|
struct PointLightInfo
|
||||||
|
{
|
||||||
|
float posX;
|
||||||
|
float posY;
|
||||||
|
float posZ;
|
||||||
|
float energy;
|
||||||
|
float red;
|
||||||
|
float green;
|
||||||
|
float blue;
|
||||||
|
float padding;
|
||||||
|
};
|
||||||
|
|
||||||
|
void createPointLightVAO()
|
||||||
|
{
|
||||||
|
glGenVertexArrays(1, &pointlightsvao);
|
||||||
|
glBindVertexArray(pointlightsvao);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
|
||||||
|
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Corner);
|
||||||
|
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||||
|
|
||||||
|
glGenBuffers(1, &pointlightvbo);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, pointlightvbo);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, MAXLIGHT * sizeof(PointLightInfo), 0, GL_DYNAMIC_DRAW);
|
||||||
|
|
||||||
|
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Position);
|
||||||
|
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Position, 3, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), 0);
|
||||||
|
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Energy);
|
||||||
|
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Energy, 1, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), (GLvoid*)(3 * sizeof(float)));
|
||||||
|
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Color);
|
||||||
|
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Color, 3, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), (GLvoid*)(4 * sizeof(float)));
|
||||||
|
|
||||||
|
glVertexAttribDivisor(MeshShader::PointLightShader::attrib_Position, 1);
|
||||||
|
glVertexAttribDivisor(MeshShader::PointLightShader::attrib_Energy, 1);
|
||||||
|
glVertexAttribDivisor(MeshShader::PointLightShader::attrib_Color, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void renderPointLights()
|
||||||
|
{
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::PointLightShader::Program);
|
||||||
|
glBindVertexArray(pointlightsvao);
|
||||||
|
|
||||||
|
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
||||||
|
setTexture(1, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
||||||
|
MeshShader::PointLightShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 200, 0, 1);
|
||||||
|
|
||||||
|
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, MAXLIGHT);
|
||||||
|
glBindVertexArray(0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
PointLightInfo PointLightsInfo[MAXLIGHT];
|
||||||
|
|
||||||
void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
||||||
scene::ICameraSceneNode * const camnode,
|
scene::ICameraSceneNode * const camnode,
|
||||||
video::SOverrideMaterial &overridemat,
|
video::SOverrideMaterial &overridemat,
|
||||||
@ -757,9 +832,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
|||||||
const u32 lightcount = m_lights.size();
|
const u32 lightcount = m_lights.size();
|
||||||
const core::vector3df &campos =
|
const core::vector3df &campos =
|
||||||
irr_driver->getSceneManager()->getActiveCamera()->getAbsolutePosition();
|
irr_driver->getSceneManager()->getActiveCamera()->getAbsolutePosition();
|
||||||
std::vector<float> accumulatedLightPos;
|
|
||||||
std::vector<float> accumulatedLightColor;
|
|
||||||
std::vector<float> accumulatedLightEnergy;
|
|
||||||
std::vector<LightNode *> BucketedLN[15];
|
std::vector<LightNode *> BucketedLN[15];
|
||||||
for (unsigned int i = 0; i < lightcount; i++)
|
for (unsigned int i = 0; i < lightcount; i++)
|
||||||
{
|
{
|
||||||
@ -785,7 +858,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
|||||||
{
|
{
|
||||||
for (unsigned j = 0; j < BucketedLN[i].size(); j++)
|
for (unsigned j = 0; j < BucketedLN[i].size(); j++)
|
||||||
{
|
{
|
||||||
if (++lightnum > MAXLIGHT)
|
if (++lightnum >= MAXLIGHT)
|
||||||
{
|
{
|
||||||
LightNode* light_node = BucketedLN[i].at(j);
|
LightNode* light_node = BucketedLN[i].at(j);
|
||||||
light_node->setEnergyMultiplier(0.0f);
|
light_node->setEnergyMultiplier(0.0f);
|
||||||
@ -801,17 +874,16 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const core::vector3df &pos = light_node->getAbsolutePosition();
|
const core::vector3df &pos = light_node->getAbsolutePosition();
|
||||||
accumulatedLightPos.push_back(pos.X);
|
PointLightsInfo[lightnum].posX = pos.X;
|
||||||
accumulatedLightPos.push_back(pos.Y);
|
PointLightsInfo[lightnum].posY = pos.Y;
|
||||||
accumulatedLightPos.push_back(pos.Z);
|
PointLightsInfo[lightnum].posZ = pos.Z;
|
||||||
accumulatedLightPos.push_back(0.);
|
|
||||||
const core::vector3df &col = light_node->getColor();
|
|
||||||
|
|
||||||
accumulatedLightColor.push_back(col.X);
|
PointLightsInfo[lightnum].energy = light_node->getEffectiveEnergy();
|
||||||
accumulatedLightColor.push_back(col.Y);
|
|
||||||
accumulatedLightColor.push_back(col.Z);
|
const core::vector3df &col = light_node->getColor();
|
||||||
accumulatedLightColor.push_back(0.);
|
PointLightsInfo[lightnum].red = col.X;
|
||||||
accumulatedLightEnergy.push_back(light_node->getEffectiveEnergy());
|
PointLightsInfo[lightnum].green = col.Y;
|
||||||
|
PointLightsInfo[lightnum].blue = col.Z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lightnum > MAXLIGHT)
|
if (lightnum > MAXLIGHT)
|
||||||
@ -820,19 +892,20 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lightnum++;
|
||||||
|
|
||||||
// Fill lights
|
// Fill lights
|
||||||
for (; lightnum < MAXLIGHT; lightnum++) {
|
for (; lightnum < MAXLIGHT; lightnum++) {
|
||||||
accumulatedLightPos.push_back(0.);
|
PointLightsInfo[lightnum].energy = 0;
|
||||||
accumulatedLightPos.push_back(0.);
|
|
||||||
accumulatedLightPos.push_back(0.);
|
|
||||||
accumulatedLightPos.push_back(0.);
|
|
||||||
accumulatedLightColor.push_back(0.);
|
|
||||||
accumulatedLightColor.push_back(0.);
|
|
||||||
accumulatedLightColor.push_back(0.);
|
|
||||||
accumulatedLightColor.push_back(0.);
|
|
||||||
accumulatedLightEnergy.push_back(0.);
|
|
||||||
}
|
}
|
||||||
m_post_processing->renderPointlight(accumulatedLightPos, accumulatedLightColor, accumulatedLightEnergy);
|
|
||||||
|
if (!pointlightsvao)
|
||||||
|
createPointLightVAO();
|
||||||
|
glBindVertexArray(pointlightsvao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, pointlightvbo);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, 0, MAXLIGHT * sizeof(PointLightInfo), PointLightsInfo);
|
||||||
|
renderPointLights();
|
||||||
if (SkyboxCubeMap)
|
if (SkyboxCubeMap)
|
||||||
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
|
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||||
// Handle SSAO
|
// Handle SSAO
|
||||||
|
@ -89,6 +89,21 @@ static void initQuadBuffer()
|
|||||||
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint SharedObject::billboardvbo = 0;
|
||||||
|
|
||||||
|
static void initBillboardVBO()
|
||||||
|
{
|
||||||
|
float quad[] = {
|
||||||
|
-.5, -.5, 0., 1.,
|
||||||
|
-.5, .5, 0., 0.,
|
||||||
|
.5, -.5, 1., 1.,
|
||||||
|
.5, .5, 1., 0.,
|
||||||
|
};
|
||||||
|
glGenBuffers(1, &(SharedObject::billboardvbo));
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad, GL_STATIC_DRAW);
|
||||||
|
}
|
||||||
|
|
||||||
void Shaders::loadShaders()
|
void Shaders::loadShaders()
|
||||||
{
|
{
|
||||||
const std::string &dir = file_manager->getAsset(FileManager::SHADER, "");
|
const std::string &dir = file_manager->getAsset(FileManager::SHADER, "");
|
||||||
@ -215,6 +230,7 @@ void Shaders::loadShaders()
|
|||||||
initGL();
|
initGL();
|
||||||
initQuadVBO();
|
initQuadVBO();
|
||||||
initQuadBuffer();
|
initQuadBuffer();
|
||||||
|
initBillboardVBO();
|
||||||
FullScreenShader::BloomBlendShader::init();
|
FullScreenShader::BloomBlendShader::init();
|
||||||
FullScreenShader::BloomShader::init();
|
FullScreenShader::BloomShader::init();
|
||||||
FullScreenShader::ColorLevelShader::init();
|
FullScreenShader::ColorLevelShader::init();
|
||||||
@ -227,7 +243,6 @@ void Shaders::loadShaders()
|
|||||||
FullScreenShader::PenumbraVShader::init();
|
FullScreenShader::PenumbraVShader::init();
|
||||||
FullScreenShader::GlowShader::init();
|
FullScreenShader::GlowShader::init();
|
||||||
FullScreenShader::PassThroughShader::init();
|
FullScreenShader::PassThroughShader::init();
|
||||||
FullScreenShader::PointLightShader::init();
|
|
||||||
FullScreenShader::SSAOShader::init();
|
FullScreenShader::SSAOShader::init();
|
||||||
FullScreenShader::SunLightShader::init();
|
FullScreenShader::SunLightShader::init();
|
||||||
FullScreenShader::DiffuseEnvMapShader::init();
|
FullScreenShader::DiffuseEnvMapShader::init();
|
||||||
@ -254,6 +269,7 @@ void Shaders::loadShaders()
|
|||||||
MeshShader::TransparentShader::init();
|
MeshShader::TransparentShader::init();
|
||||||
MeshShader::TransparentFogShader::init();
|
MeshShader::TransparentFogShader::init();
|
||||||
MeshShader::BillboardShader::init();
|
MeshShader::BillboardShader::init();
|
||||||
|
MeshShader::PointLightShader::init();
|
||||||
MeshShader::DisplaceShader::init();
|
MeshShader::DisplaceShader::init();
|
||||||
MeshShader::DisplaceMaskShader::init();
|
MeshShader::DisplaceMaskShader::init();
|
||||||
MeshShader::ShadowShader::init();
|
MeshShader::ShadowShader::init();
|
||||||
@ -297,6 +313,8 @@ void Shaders::check(const int num) const
|
|||||||
|
|
||||||
namespace MeshShader
|
namespace MeshShader
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Solid Normal and depth pass shaders
|
||||||
GLuint ObjectPass1Shader::Program;
|
GLuint ObjectPass1Shader::Program;
|
||||||
GLuint ObjectPass1Shader::attrib_position;
|
GLuint ObjectPass1Shader::attrib_position;
|
||||||
GLuint ObjectPass1Shader::attrib_normal;
|
GLuint ObjectPass1Shader::attrib_normal;
|
||||||
@ -347,17 +365,75 @@ namespace MeshShader
|
|||||||
glUniform1i(uniform_tex, TU_tex);
|
glUniform1i(uniform_tex, TU_tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint GrassPass1Shader::Program;
|
||||||
|
GLuint GrassPass1Shader::attrib_position;
|
||||||
|
GLuint GrassPass1Shader::attrib_texcoord;
|
||||||
|
GLuint GrassPass1Shader::attrib_normal;
|
||||||
|
GLuint GrassPass1Shader::attrib_color;
|
||||||
|
GLuint GrassPass1Shader::uniform_MVP;
|
||||||
|
GLuint GrassPass1Shader::uniform_TIMV;
|
||||||
|
GLuint GrassPass1Shader::uniform_tex;
|
||||||
|
GLuint GrassPass1Shader::uniform_windDir;
|
||||||
|
|
||||||
|
void GrassPass1Shader::init()
|
||||||
|
{
|
||||||
|
Program = LoadProgram(file_manager->getAsset("shaders/grass_pass1.vert").c_str(), file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||||
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
|
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||||
|
attrib_color = glGetAttribLocation(Program, "Color");
|
||||||
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
|
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
||||||
|
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||||
|
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GrassPass1Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::vector3df &windDirection, unsigned TU_tex)
|
||||||
|
{
|
||||||
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
|
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
||||||
|
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
|
||||||
|
glUniform1i(uniform_tex, TU_tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLuint NormalMapShader::Program;
|
||||||
|
GLuint NormalMapShader::attrib_position;
|
||||||
|
GLuint NormalMapShader::attrib_texcoord;
|
||||||
|
GLuint NormalMapShader::attrib_tangent;
|
||||||
|
GLuint NormalMapShader::attrib_bitangent;
|
||||||
|
GLuint NormalMapShader::uniform_MVP;
|
||||||
|
GLuint NormalMapShader::uniform_TIMV;
|
||||||
|
GLuint NormalMapShader::uniform_normalMap;
|
||||||
|
|
||||||
|
void NormalMapShader::init()
|
||||||
|
{
|
||||||
|
Program = LoadProgram(file_manager->getAsset("shaders/normalmap.vert").c_str(), file_manager->getAsset("shaders/normalmap.frag").c_str());
|
||||||
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
|
attrib_tangent = glGetAttribLocation(Program, "Tangent");
|
||||||
|
attrib_bitangent = glGetAttribLocation(Program, "Bitangent");
|
||||||
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
|
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
||||||
|
uniform_normalMap = glGetUniformLocation(Program, "normalMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
void NormalMapShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_normalMap)
|
||||||
|
{
|
||||||
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
|
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
||||||
|
glUniform1i(uniform_normalMap, TU_normalMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Solid Lit pass shaders
|
||||||
|
|
||||||
GLuint ObjectPass2Shader::Program;
|
GLuint ObjectPass2Shader::Program;
|
||||||
GLuint ObjectPass2Shader::attrib_position;
|
GLuint ObjectPass2Shader::attrib_position;
|
||||||
GLuint ObjectPass2Shader::attrib_texcoord;
|
GLuint ObjectPass2Shader::attrib_texcoord;
|
||||||
GLuint ObjectPass2Shader::uniform_MVP;
|
GLuint ObjectPass2Shader::uniform_MVP;
|
||||||
GLuint ObjectPass2Shader::uniform_TM;
|
GLuint ObjectPass2Shader::uniform_TM;
|
||||||
GLuint ObjectPass2Shader::uniform_Albedo;
|
|
||||||
GLuint ObjectPass2Shader::uniform_DiffuseMap;
|
|
||||||
GLuint ObjectPass2Shader::uniform_SpecularMap;
|
|
||||||
GLuint ObjectPass2Shader::uniform_SSAO;
|
|
||||||
GLuint ObjectPass2Shader::uniform_screen;
|
GLuint ObjectPass2Shader::uniform_screen;
|
||||||
GLuint ObjectPass2Shader::uniform_ambient;
|
GLuint ObjectPass2Shader::uniform_ambient;
|
||||||
|
GLuint ObjectPass2Shader::TU_Albedo;
|
||||||
|
|
||||||
void ObjectPass2Shader::init()
|
void ObjectPass2Shader::init()
|
||||||
{
|
{
|
||||||
@ -366,22 +442,26 @@ namespace MeshShader
|
|||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
|
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
|
||||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
|
TU_Albedo = 3;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
void ObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
@ -392,13 +472,10 @@ namespace MeshShader
|
|||||||
GLuint DetailledObjectPass2Shader::attrib_texcoord;
|
GLuint DetailledObjectPass2Shader::attrib_texcoord;
|
||||||
GLuint DetailledObjectPass2Shader::attrib_second_texcoord;
|
GLuint DetailledObjectPass2Shader::attrib_second_texcoord;
|
||||||
GLuint DetailledObjectPass2Shader::uniform_MVP;
|
GLuint DetailledObjectPass2Shader::uniform_MVP;
|
||||||
GLuint DetailledObjectPass2Shader::uniform_Albedo;
|
|
||||||
GLuint DetailledObjectPass2Shader::uniform_Detail;
|
|
||||||
GLuint DetailledObjectPass2Shader::uniform_DiffuseMap;
|
|
||||||
GLuint DetailledObjectPass2Shader::uniform_SpecularMap;
|
|
||||||
GLuint DetailledObjectPass2Shader::uniform_SSAO;
|
|
||||||
GLuint DetailledObjectPass2Shader::uniform_screen;
|
GLuint DetailledObjectPass2Shader::uniform_screen;
|
||||||
GLuint DetailledObjectPass2Shader::uniform_ambient;
|
GLuint DetailledObjectPass2Shader::uniform_ambient;
|
||||||
|
GLuint DetailledObjectPass2Shader::TU_Albedo;
|
||||||
|
GLuint DetailledObjectPass2Shader::TU_detail;
|
||||||
|
|
||||||
void DetailledObjectPass2Shader::init()
|
void DetailledObjectPass2Shader::init()
|
||||||
{
|
{
|
||||||
@ -407,23 +484,28 @@ namespace MeshShader
|
|||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
|
attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||||
uniform_Detail = glGetUniformLocation(Program, "Detail");
|
GLuint uniform_Detail = glGetUniformLocation(Program, "Detail");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
|
TU_Albedo = 3;
|
||||||
|
TU_detail = 4;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||||
|
glUniform1i(uniform_Detail, TU_detail);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetailledObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_detail, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
void DetailledObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
|
||||||
glUniform1i(uniform_Detail, TU_detail);
|
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
@ -433,7 +515,7 @@ namespace MeshShader
|
|||||||
GLuint ObjectUnlitShader::attrib_position;
|
GLuint ObjectUnlitShader::attrib_position;
|
||||||
GLuint ObjectUnlitShader::attrib_texcoord;
|
GLuint ObjectUnlitShader::attrib_texcoord;
|
||||||
GLuint ObjectUnlitShader::uniform_MVP;
|
GLuint ObjectUnlitShader::uniform_MVP;
|
||||||
GLuint ObjectUnlitShader::uniform_tex;
|
GLuint ObjectUnlitShader::TU_tex;
|
||||||
|
|
||||||
void ObjectUnlitShader::init()
|
void ObjectUnlitShader::init()
|
||||||
{
|
{
|
||||||
@ -441,13 +523,17 @@ namespace MeshShader
|
|||||||
attrib_position = glGetAttribLocation(Program, "Position");
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
|
||||||
|
TU_tex = 3;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_tex, TU_tex);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectUnlitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex)
|
void ObjectUnlitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniform1i(uniform_tex, TU_tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint ObjectRimLimitShader::Program;
|
GLuint ObjectRimLimitShader::Program;
|
||||||
@ -457,12 +543,9 @@ namespace MeshShader
|
|||||||
GLuint ObjectRimLimitShader::uniform_MVP;
|
GLuint ObjectRimLimitShader::uniform_MVP;
|
||||||
GLuint ObjectRimLimitShader::uniform_TIMV;
|
GLuint ObjectRimLimitShader::uniform_TIMV;
|
||||||
GLuint ObjectRimLimitShader::uniform_TM;
|
GLuint ObjectRimLimitShader::uniform_TM;
|
||||||
GLuint ObjectRimLimitShader::uniform_Albedo;
|
|
||||||
GLuint ObjectRimLimitShader::uniform_DiffuseMap;
|
|
||||||
GLuint ObjectRimLimitShader::uniform_SpecularMap;
|
|
||||||
GLuint ObjectRimLimitShader::uniform_SSAO;
|
|
||||||
GLuint ObjectRimLimitShader::uniform_screen;
|
GLuint ObjectRimLimitShader::uniform_screen;
|
||||||
GLuint ObjectRimLimitShader::uniform_ambient;
|
GLuint ObjectRimLimitShader::uniform_ambient;
|
||||||
|
GLuint ObjectRimLimitShader::TU_Albedo;
|
||||||
|
|
||||||
void ObjectRimLimitShader::init()
|
void ObjectRimLimitShader::init()
|
||||||
{
|
{
|
||||||
@ -473,23 +556,27 @@ namespace MeshShader
|
|||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
||||||
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
|
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
|
||||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
|
TU_Albedo = 3;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
||||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
@ -499,9 +586,6 @@ namespace MeshShader
|
|||||||
GLuint UntexturedObjectShader::attrib_position;
|
GLuint UntexturedObjectShader::attrib_position;
|
||||||
GLuint UntexturedObjectShader::attrib_color;
|
GLuint UntexturedObjectShader::attrib_color;
|
||||||
GLuint UntexturedObjectShader::uniform_MVP;
|
GLuint UntexturedObjectShader::uniform_MVP;
|
||||||
GLuint UntexturedObjectShader::uniform_DiffuseMap;
|
|
||||||
GLuint UntexturedObjectShader::uniform_SpecularMap;
|
|
||||||
GLuint UntexturedObjectShader::uniform_SSAO;
|
|
||||||
GLuint UntexturedObjectShader::uniform_screen;
|
GLuint UntexturedObjectShader::uniform_screen;
|
||||||
GLuint UntexturedObjectShader::uniform_ambient;
|
GLuint UntexturedObjectShader::uniform_ambient;
|
||||||
|
|
||||||
@ -511,19 +595,22 @@ namespace MeshShader
|
|||||||
attrib_position = glGetAttribLocation(Program, "Position");
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
attrib_color = glGetAttribLocation(Program, "Color");
|
attrib_color = glGetAttribLocation(Program, "Color");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UntexturedObjectShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
void UntexturedObjectShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
@ -535,12 +622,9 @@ namespace MeshShader
|
|||||||
GLuint ObjectRefPass2Shader::attrib_texcoord;
|
GLuint ObjectRefPass2Shader::attrib_texcoord;
|
||||||
GLuint ObjectRefPass2Shader::uniform_MVP;
|
GLuint ObjectRefPass2Shader::uniform_MVP;
|
||||||
GLuint ObjectRefPass2Shader::uniform_TM;
|
GLuint ObjectRefPass2Shader::uniform_TM;
|
||||||
GLuint ObjectRefPass2Shader::uniform_Albedo;
|
|
||||||
GLuint ObjectRefPass2Shader::uniform_DiffuseMap;
|
|
||||||
GLuint ObjectRefPass2Shader::uniform_SpecularMap;
|
|
||||||
GLuint ObjectRefPass2Shader::uniform_SSAO;
|
|
||||||
GLuint ObjectRefPass2Shader::uniform_screen;
|
GLuint ObjectRefPass2Shader::uniform_screen;
|
||||||
GLuint ObjectRefPass2Shader::uniform_ambient;
|
GLuint ObjectRefPass2Shader::uniform_ambient;
|
||||||
|
GLuint ObjectRefPass2Shader::TU_Albedo;
|
||||||
|
|
||||||
void ObjectRefPass2Shader::init()
|
void ObjectRefPass2Shader::init()
|
||||||
{
|
{
|
||||||
@ -550,70 +634,40 @@ namespace MeshShader
|
|||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
|
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
|
||||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
|
TU_Albedo = 3;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectRefPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
void ObjectRefPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint GrassPass1Shader::Program;
|
|
||||||
GLuint GrassPass1Shader::attrib_position;
|
|
||||||
GLuint GrassPass1Shader::attrib_texcoord;
|
|
||||||
GLuint GrassPass1Shader::attrib_normal;
|
|
||||||
GLuint GrassPass1Shader::attrib_color;
|
|
||||||
GLuint GrassPass1Shader::uniform_MVP;
|
|
||||||
GLuint GrassPass1Shader::uniform_TIMV;
|
|
||||||
GLuint GrassPass1Shader::uniform_tex;
|
|
||||||
GLuint GrassPass1Shader::uniform_windDir;
|
|
||||||
|
|
||||||
void GrassPass1Shader::init()
|
|
||||||
{
|
|
||||||
Program = LoadProgram(file_manager->getAsset("shaders/grass_pass1.vert").c_str(), file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
|
||||||
attrib_position = glGetAttribLocation(Program, "Position");
|
|
||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
|
||||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
|
||||||
attrib_color = glGetAttribLocation(Program, "Color");
|
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
|
||||||
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
|
||||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
|
||||||
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrassPass1Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::vector3df &windDirection, unsigned TU_tex)
|
|
||||||
{
|
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
|
||||||
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
|
||||||
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
|
|
||||||
glUniform1i(uniform_tex, TU_tex);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint GrassPass2Shader::Program;
|
GLuint GrassPass2Shader::Program;
|
||||||
GLuint GrassPass2Shader::attrib_position;
|
GLuint GrassPass2Shader::attrib_position;
|
||||||
GLuint GrassPass2Shader::attrib_texcoord;
|
GLuint GrassPass2Shader::attrib_texcoord;
|
||||||
GLuint GrassPass2Shader::attrib_color;
|
GLuint GrassPass2Shader::attrib_color;
|
||||||
GLuint GrassPass2Shader::uniform_MVP;
|
GLuint GrassPass2Shader::uniform_MVP;
|
||||||
GLuint GrassPass2Shader::uniform_Albedo;
|
|
||||||
GLuint GrassPass2Shader::uniform_DiffuseMap;
|
|
||||||
GLuint GrassPass2Shader::uniform_SpecularMap;
|
|
||||||
GLuint GrassPass2Shader::uniform_SSAO;
|
|
||||||
GLuint GrassPass2Shader::uniform_screen;
|
GLuint GrassPass2Shader::uniform_screen;
|
||||||
GLuint GrassPass2Shader::uniform_ambient;
|
GLuint GrassPass2Shader::uniform_ambient;
|
||||||
GLuint GrassPass2Shader::uniform_windDir;
|
GLuint GrassPass2Shader::uniform_windDir;
|
||||||
|
GLuint GrassPass2Shader::TU_Albedo;
|
||||||
|
|
||||||
void GrassPass2Shader::init()
|
void GrassPass2Shader::init()
|
||||||
{
|
{
|
||||||
@ -622,64 +676,41 @@ namespace MeshShader
|
|||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
attrib_color = glGetAttribLocation(Program, "Color");
|
attrib_color = glGetAttribLocation(Program, "Color");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
||||||
|
TU_Albedo = 3;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrassPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
void GrassPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
|
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint NormalMapShader::Program;
|
|
||||||
GLuint NormalMapShader::attrib_position;
|
|
||||||
GLuint NormalMapShader::attrib_texcoord;
|
|
||||||
GLuint NormalMapShader::attrib_tangent;
|
|
||||||
GLuint NormalMapShader::attrib_bitangent;
|
|
||||||
GLuint NormalMapShader::uniform_MVP;
|
|
||||||
GLuint NormalMapShader::uniform_TIMV;
|
|
||||||
GLuint NormalMapShader::uniform_normalMap;
|
|
||||||
|
|
||||||
void NormalMapShader::init()
|
|
||||||
{
|
|
||||||
Program = LoadProgram(file_manager->getAsset("shaders/normalmap.vert").c_str(), file_manager->getAsset("shaders/normalmap.frag").c_str());
|
|
||||||
attrib_position = glGetAttribLocation(Program, "Position");
|
|
||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
|
||||||
attrib_tangent = glGetAttribLocation(Program, "Tangent");
|
|
||||||
attrib_bitangent = glGetAttribLocation(Program, "Bitangent");
|
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
|
||||||
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
|
||||||
uniform_normalMap = glGetUniformLocation(Program, "normalMap");
|
|
||||||
}
|
|
||||||
|
|
||||||
void NormalMapShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_normalMap)
|
|
||||||
{
|
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
|
||||||
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
|
||||||
glUniform1i(uniform_normalMap, TU_normalMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint SphereMapShader::Program;
|
GLuint SphereMapShader::Program;
|
||||||
GLuint SphereMapShader::attrib_position;
|
GLuint SphereMapShader::attrib_position;
|
||||||
GLuint SphereMapShader::attrib_normal;
|
GLuint SphereMapShader::attrib_normal;
|
||||||
GLuint SphereMapShader::uniform_MVP;
|
GLuint SphereMapShader::uniform_MVP;
|
||||||
GLuint SphereMapShader::uniform_TIMV;
|
GLuint SphereMapShader::uniform_TIMV;
|
||||||
GLuint SphereMapShader::uniform_tex;
|
GLuint SphereMapShader::uniform_TVM;
|
||||||
GLuint SphereMapShader::uniform_invproj;
|
GLuint SphereMapShader::uniform_invproj;
|
||||||
GLuint SphereMapShader::uniform_screen;
|
GLuint SphereMapShader::uniform_screen;
|
||||||
|
GLuint SphereMapShader::TU_tex;
|
||||||
|
|
||||||
void SphereMapShader::init()
|
void SphereMapShader::init()
|
||||||
{
|
{
|
||||||
@ -688,18 +719,24 @@ namespace MeshShader
|
|||||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
||||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
uniform_TVM = glGetUniformLocation(Program, "TransposeViewMatrix");
|
||||||
|
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
|
||||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
|
TU_tex = 3;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_tex, TU_tex);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SphereMapShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen, unsigned TU_tex)
|
void SphereMapShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
||||||
|
glUniformMatrix4fv(uniform_TVM, 1, GL_FALSE, TransposeViewMatrix.pointer());
|
||||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProj.pointer());
|
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProj.pointer());
|
||||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||||
glUniform1i(uniform_tex, TU_tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint SplattingShader::Program;
|
GLuint SplattingShader::Program;
|
||||||
@ -707,16 +744,13 @@ namespace MeshShader
|
|||||||
GLuint SplattingShader::attrib_texcoord;
|
GLuint SplattingShader::attrib_texcoord;
|
||||||
GLuint SplattingShader::attrib_second_texcoord;
|
GLuint SplattingShader::attrib_second_texcoord;
|
||||||
GLuint SplattingShader::uniform_MVP;
|
GLuint SplattingShader::uniform_MVP;
|
||||||
GLuint SplattingShader::uniform_tex_layout;
|
|
||||||
GLuint SplattingShader::uniform_tex_detail0;
|
|
||||||
GLuint SplattingShader::uniform_tex_detail1;
|
|
||||||
GLuint SplattingShader::uniform_tex_detail2;
|
|
||||||
GLuint SplattingShader::uniform_tex_detail3;
|
|
||||||
GLuint SplattingShader::uniform_DiffuseMap;
|
|
||||||
GLuint SplattingShader::uniform_SpecularMap;
|
|
||||||
GLuint SplattingShader::uniform_SSAO;
|
|
||||||
GLuint SplattingShader::uniform_screen;
|
GLuint SplattingShader::uniform_screen;
|
||||||
GLuint SplattingShader::uniform_ambient;
|
GLuint SplattingShader::uniform_ambient;
|
||||||
|
GLuint SplattingShader::TU_tex_layout;
|
||||||
|
GLuint SplattingShader::TU_tex_detail0;
|
||||||
|
GLuint SplattingShader::TU_tex_detail1;
|
||||||
|
GLuint SplattingShader::TU_tex_detail2;
|
||||||
|
GLuint SplattingShader::TU_tex_detail3;
|
||||||
|
|
||||||
void SplattingShader::init()
|
void SplattingShader::init()
|
||||||
{
|
{
|
||||||
@ -725,29 +759,37 @@ namespace MeshShader
|
|||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
|
attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
|
||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_tex_layout = glGetUniformLocation(Program, "tex_layout");
|
GLuint uniform_tex_layout = glGetUniformLocation(Program, "tex_layout");
|
||||||
uniform_tex_detail0 = glGetUniformLocation(Program, "tex_detail0");
|
GLuint uniform_tex_detail0 = glGetUniformLocation(Program, "tex_detail0");
|
||||||
uniform_tex_detail1 = glGetUniformLocation(Program, "tex_detail1");
|
GLuint uniform_tex_detail1 = glGetUniformLocation(Program, "tex_detail1");
|
||||||
uniform_tex_detail2 = glGetUniformLocation(Program, "tex_detail2");
|
GLuint uniform_tex_detail2 = glGetUniformLocation(Program, "tex_detail2");
|
||||||
uniform_tex_detail3 = glGetUniformLocation(Program, "tex_detail3");
|
GLuint uniform_tex_detail3 = glGetUniformLocation(Program, "tex_detail3");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
|
TU_tex_layout = 3;
|
||||||
|
TU_tex_detail0 = 4;
|
||||||
|
TU_tex_detail1 = 5;
|
||||||
|
TU_tex_detail2 = 6;
|
||||||
|
TU_tex_detail3 = 7;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUniform1i(uniform_tex_layout, TU_tex_layout);
|
||||||
|
glUniform1i(uniform_tex_detail0, TU_tex_detail0);
|
||||||
|
glUniform1i(uniform_tex_detail1, TU_tex_detail1);
|
||||||
|
glUniform1i(uniform_tex_detail2, TU_tex_detail2);
|
||||||
|
glUniform1i(uniform_tex_detail3, TU_tex_detail3);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplattingShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex_layout, unsigned TU_tex_detail0, unsigned TU_tex_detail1, unsigned TU_tex_detail2, unsigned TU_tex_detail3, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
void SplattingShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniform1i(uniform_tex_layout, TU_tex_layout);
|
|
||||||
glUniform1i(uniform_tex_detail0, TU_tex_detail0);
|
|
||||||
glUniform1i(uniform_tex_detail1, TU_tex_detail1);
|
|
||||||
glUniform1i(uniform_tex_detail2, TU_tex_detail2);
|
|
||||||
glUniform1i(uniform_tex_detail3, TU_tex_detail3);
|
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
@ -759,13 +801,10 @@ namespace MeshShader
|
|||||||
GLuint CausticsShader::uniform_MVP;
|
GLuint CausticsShader::uniform_MVP;
|
||||||
GLuint CausticsShader::uniform_dir;
|
GLuint CausticsShader::uniform_dir;
|
||||||
GLuint CausticsShader::uniform_dir2;
|
GLuint CausticsShader::uniform_dir2;
|
||||||
GLuint CausticsShader::uniform_Albedo;
|
|
||||||
GLuint CausticsShader::uniform_caustictex;
|
|
||||||
GLuint CausticsShader::uniform_DiffuseMap;
|
|
||||||
GLuint CausticsShader::uniform_SpecularMap;
|
|
||||||
GLuint CausticsShader::uniform_SSAO;
|
|
||||||
GLuint CausticsShader::uniform_screen;
|
GLuint CausticsShader::uniform_screen;
|
||||||
GLuint CausticsShader::uniform_ambient;
|
GLuint CausticsShader::uniform_ambient;
|
||||||
|
GLuint CausticsShader::TU_Albedo;
|
||||||
|
GLuint CausticsShader::TU_caustictex;
|
||||||
|
|
||||||
void CausticsShader::init()
|
void CausticsShader::init()
|
||||||
{
|
{
|
||||||
@ -775,26 +814,31 @@ namespace MeshShader
|
|||||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||||
uniform_dir = glGetUniformLocation(Program, "dir");
|
uniform_dir = glGetUniformLocation(Program, "dir");
|
||||||
uniform_dir2 = glGetUniformLocation(Program, "dir2");
|
uniform_dir2 = glGetUniformLocation(Program, "dir2");
|
||||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||||
uniform_caustictex = glGetUniformLocation(Program, "caustictex");
|
GLuint uniform_caustictex = glGetUniformLocation(Program, "caustictex");
|
||||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||||
|
TU_Albedo = 3;
|
||||||
|
TU_caustictex = 4;
|
||||||
|
|
||||||
|
glUseProgram(Program);
|
||||||
|
glUniform1i(uniform_DiffuseMap, 0);
|
||||||
|
glUniform1i(uniform_SpecularMap, 1);
|
||||||
|
glUniform1i(uniform_SSAO, 2);
|
||||||
|
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||||
|
glUniform1i(uniform_caustictex, TU_caustictex);
|
||||||
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CausticsShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_albedo, unsigned TU_DiffuseMap, unsigned TU_Specmap, unsigned TU_SSAO, unsigned TU_caustictex)
|
void CausticsShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||||
glUniform2f(uniform_dir, dir.X, dir.Y);
|
glUniform2f(uniform_dir, dir.X, dir.Y);
|
||||||
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
|
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
|
||||||
glUniform1i(uniform_Albedo, TU_albedo);
|
|
||||||
glUniform1i(uniform_caustictex, TU_caustictex);
|
|
||||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
|
||||||
glUniform1i(uniform_SpecularMap, TU_Specmap);
|
|
||||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
|
||||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||||
}
|
}
|
||||||
@ -896,6 +940,47 @@ namespace MeshShader
|
|||||||
glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
|
glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
|
||||||
glUniform1i(uniform_tex, TU_tex);
|
glUniform1i(uniform_tex, TU_tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint PointLightShader::Program;
|
||||||
|
GLuint PointLightShader::attrib_Position;
|
||||||
|
GLuint PointLightShader::attrib_Color;
|
||||||
|
GLuint PointLightShader::attrib_Energy;
|
||||||
|
GLuint PointLightShader::attrib_Corner;
|
||||||
|
GLuint PointLightShader::uniform_ntex;
|
||||||
|
GLuint PointLightShader::uniform_dtex;
|
||||||
|
GLuint PointLightShader::uniform_spec;
|
||||||
|
GLuint PointLightShader::uniform_screen;
|
||||||
|
GLuint PointLightShader::uniform_invproj;
|
||||||
|
GLuint PointLightShader::uniform_VM;
|
||||||
|
GLuint PointLightShader::uniform_PM;
|
||||||
|
|
||||||
|
void PointLightShader::init()
|
||||||
|
{
|
||||||
|
Program = LoadProgram(file_manager->getAsset("shaders/pointlight.vert").c_str(), file_manager->getAsset("shaders/pointlight.frag").c_str());
|
||||||
|
attrib_Position = glGetAttribLocation(Program, "Position");
|
||||||
|
attrib_Color = glGetAttribLocation(Program, "Color");
|
||||||
|
attrib_Energy = glGetAttribLocation(Program, "Energy");
|
||||||
|
attrib_Corner = glGetAttribLocation(Program, "Corner");
|
||||||
|
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||||
|
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||||
|
uniform_spec = glGetUniformLocation(Program, "spec");
|
||||||
|
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||||
|
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||||
|
uniform_VM = glGetUniformLocation(Program, "ViewMatrix");
|
||||||
|
uniform_PM = glGetUniformLocation(Program, "ProjectionMatrix");
|
||||||
|
}
|
||||||
|
|
||||||
|
void PointLightShader::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 &InvProjMatrix, const core::vector2df &screen, unsigned spec, unsigned TU_ntex, unsigned TU_dtex)
|
||||||
|
{
|
||||||
|
glUniform1f(uniform_spec, 200);
|
||||||
|
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||||
|
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
|
||||||
|
glUniformMatrix4fv(uniform_VM, 1, GL_FALSE, ViewMatrix.pointer());
|
||||||
|
glUniformMatrix4fv(uniform_PM, 1, GL_FALSE, ProjMatrix.pointer());
|
||||||
|
|
||||||
|
glUniform1i(uniform_ntex, TU_ntex);
|
||||||
|
glUniform1i(uniform_dtex, TU_dtex);
|
||||||
|
}
|
||||||
|
|
||||||
GLuint BillboardShader::Program;
|
GLuint BillboardShader::Program;
|
||||||
GLuint BillboardShader::attrib_corner;
|
GLuint BillboardShader::attrib_corner;
|
||||||
@ -1341,44 +1426,6 @@ namespace FullScreenShader
|
|||||||
vao = createVAO(Program);
|
vao = createVAO(Program);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint PointLightShader::Program;
|
|
||||||
GLuint PointLightShader::uniform_ntex;
|
|
||||||
GLuint PointLightShader::uniform_dtex;
|
|
||||||
GLuint PointLightShader::uniform_center;
|
|
||||||
GLuint PointLightShader::uniform_col;
|
|
||||||
GLuint PointLightShader::uniform_energy;
|
|
||||||
GLuint PointLightShader::uniform_spec;
|
|
||||||
GLuint PointLightShader::uniform_invproj;
|
|
||||||
GLuint PointLightShader::uniform_viewm;
|
|
||||||
GLuint PointLightShader::vao;
|
|
||||||
|
|
||||||
void PointLightShader::init()
|
|
||||||
{
|
|
||||||
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/pointlight.frag").c_str());
|
|
||||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
|
||||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
|
||||||
uniform_center = glGetUniformLocation(Program, "center[0]");
|
|
||||||
uniform_col = glGetUniformLocation(Program, "col[0]");
|
|
||||||
uniform_energy = glGetUniformLocation(Program, "energy[0]");
|
|
||||||
uniform_spec = glGetUniformLocation(Program, "spec");
|
|
||||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
|
||||||
uniform_viewm = glGetUniformLocation(Program, "viewm");
|
|
||||||
vao = createVAO(Program);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PointLightShader::setUniforms(const core::matrix4 &InvProjMatrix, const core::matrix4 &ViewMatrix, const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy, unsigned spec, unsigned TU_ntex, unsigned TU_dtex)
|
|
||||||
{
|
|
||||||
glUniform4fv(FullScreenShader::PointLightShader::uniform_center, 16, positions.data());
|
|
||||||
glUniform4fv(FullScreenShader::PointLightShader::uniform_col, 16, colors.data());
|
|
||||||
glUniform1fv(FullScreenShader::PointLightShader::uniform_energy, 16, energy.data());
|
|
||||||
glUniform1f(FullScreenShader::PointLightShader::uniform_spec, 200);
|
|
||||||
glUniformMatrix4fv(FullScreenShader::PointLightShader::uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
|
|
||||||
glUniformMatrix4fv(FullScreenShader::PointLightShader::uniform_viewm, 1, GL_FALSE, ViewMatrix.pointer());
|
|
||||||
|
|
||||||
glUniform1i(FullScreenShader::PointLightShader::uniform_ntex, TU_ntex);
|
|
||||||
glUniform1i(FullScreenShader::PointLightShader::uniform_dtex, TU_dtex);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint SunLightShader::Program;
|
GLuint SunLightShader::Program;
|
||||||
GLuint SunLightShader::uniform_ntex;
|
GLuint SunLightShader::uniform_ntex;
|
||||||
GLuint SunLightShader::uniform_dtex;
|
GLuint SunLightShader::uniform_dtex;
|
||||||
@ -1412,6 +1459,7 @@ namespace FullScreenShader
|
|||||||
GLuint DiffuseEnvMapShader::uniform_blueLmn;
|
GLuint DiffuseEnvMapShader::uniform_blueLmn;
|
||||||
GLuint DiffuseEnvMapShader::uniform_greenLmn;
|
GLuint DiffuseEnvMapShader::uniform_greenLmn;
|
||||||
GLuint DiffuseEnvMapShader::uniform_redLmn;
|
GLuint DiffuseEnvMapShader::uniform_redLmn;
|
||||||
|
GLuint DiffuseEnvMapShader::uniform_TVM;
|
||||||
GLuint DiffuseEnvMapShader::vao;
|
GLuint DiffuseEnvMapShader::vao;
|
||||||
|
|
||||||
void DiffuseEnvMapShader::init()
|
void DiffuseEnvMapShader::init()
|
||||||
@ -1421,11 +1469,13 @@ namespace FullScreenShader
|
|||||||
uniform_blueLmn = glGetUniformLocation(Program, "blueLmn[0]");
|
uniform_blueLmn = glGetUniformLocation(Program, "blueLmn[0]");
|
||||||
uniform_greenLmn = glGetUniformLocation(Program, "greenLmn[0]");
|
uniform_greenLmn = glGetUniformLocation(Program, "greenLmn[0]");
|
||||||
uniform_redLmn = glGetUniformLocation(Program, "redLmn[0]");
|
uniform_redLmn = glGetUniformLocation(Program, "redLmn[0]");
|
||||||
|
uniform_TVM = glGetUniformLocation(Program, "TransposeViewMatrix");
|
||||||
vao = createVAO(Program);
|
vao = createVAO(Program);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiffuseEnvMapShader::setUniforms(const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex)
|
void DiffuseEnvMapShader::setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex)
|
||||||
{
|
{
|
||||||
|
glUniformMatrix4fv(uniform_TVM, 1, GL_FALSE, TransposeViewMatrix.pointer());
|
||||||
glUniform1i(uniform_ntex, TU_ntex);
|
glUniform1i(uniform_ntex, TU_ntex);
|
||||||
glUniform1fv(uniform_blueLmn, 9, blueSHCoeff);
|
glUniform1fv(uniform_blueLmn, 9, blueSHCoeff);
|
||||||
glUniform1fv(uniform_greenLmn, 9, greenSHCoeff);
|
glUniform1fv(uniform_greenLmn, 9, greenSHCoeff);
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
typedef unsigned int GLuint;
|
typedef unsigned int GLuint;
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
|
class SharedObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static GLuint billboardvbo;
|
||||||
|
};
|
||||||
namespace MeshShader
|
namespace MeshShader
|
||||||
{
|
{
|
||||||
class ObjectPass1Shader
|
class ObjectPass1Shader
|
||||||
@ -48,15 +53,38 @@ public:
|
|||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_texture);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GrassPass1Shader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static GLuint Program;
|
||||||
|
static GLuint attrib_position, attrib_texcoord, attrib_normal, attrib_color;
|
||||||
|
static GLuint uniform_MVP, uniform_TIMV, uniform_tex, uniform_windDir;
|
||||||
|
|
||||||
|
static void init();
|
||||||
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::vector3df &windDirection, unsigned TU_tex);
|
||||||
|
};
|
||||||
|
|
||||||
|
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 void init();
|
||||||
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_normalMap);
|
||||||
|
};
|
||||||
|
|
||||||
class ObjectPass2Shader
|
class ObjectPass2Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_TM, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||||
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DetailledObjectPass2Shader
|
class DetailledObjectPass2Shader
|
||||||
@ -64,10 +92,11 @@ class DetailledObjectPass2Shader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_Albedo, uniform_Detail, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||||
|
static GLuint TU_Albedo, TU_detail;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_detail, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectRimLimitShader
|
class ObjectRimLimitShader
|
||||||
@ -75,10 +104,11 @@ class ObjectRimLimitShader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient;
|
||||||
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class UntexturedObjectShader
|
class UntexturedObjectShader
|
||||||
@ -86,10 +116,10 @@ class UntexturedObjectShader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_color;
|
static GLuint attrib_position, attrib_color;
|
||||||
static GLuint uniform_MVP, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectUnlitShader
|
class ObjectUnlitShader
|
||||||
@ -97,10 +127,11 @@ class ObjectUnlitShader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_tex;
|
static GLuint uniform_MVP;
|
||||||
|
static GLuint TU_tex;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectRefPass2Shader
|
class ObjectRefPass2Shader
|
||||||
@ -108,21 +139,11 @@ class ObjectRefPass2Shader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_TM, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||||
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||||
};
|
|
||||||
|
|
||||||
class GrassPass1Shader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static GLuint Program;
|
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_normal, attrib_color;
|
|
||||||
static GLuint uniform_MVP, uniform_TIMV, uniform_tex, uniform_windDir;
|
|
||||||
|
|
||||||
static void init();
|
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::vector3df &windDirection, unsigned TU_tex);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GrassPass2Shader
|
class GrassPass2Shader
|
||||||
@ -130,21 +151,11 @@ class GrassPass2Shader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||||
static GLuint uniform_MVP, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient, uniform_windDir;
|
static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir;
|
||||||
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection);
|
||||||
};
|
|
||||||
|
|
||||||
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 void init();
|
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_normalMap);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SphereMapShader
|
class SphereMapShader
|
||||||
@ -152,10 +163,11 @@ class SphereMapShader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_normal;
|
static GLuint attrib_position, attrib_normal;
|
||||||
static GLuint uniform_MVP, uniform_TIMV, uniform_tex, uniform_invproj, uniform_screen;
|
static GLuint uniform_MVP, uniform_TIMV, uniform_TVM, uniform_invproj, uniform_screen;
|
||||||
|
static GLuint TU_tex;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen, unsigned TU_tex);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SplattingShader
|
class SplattingShader
|
||||||
@ -163,10 +175,11 @@ class SplattingShader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_tex_layout, uniform_tex_detail0, uniform_tex_detail1, uniform_tex_detail2, uniform_tex_detail3, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, 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 init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex_layout, unsigned TU_tex_detail0, unsigned TU_tex_detail1, unsigned TU_tex_detail2, unsigned TU_tex_detail3, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CausticsShader
|
class CausticsShader
|
||||||
@ -174,10 +187,11 @@ class CausticsShader
|
|||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_dir, uniform_dir2, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient, uniform_caustictex;
|
static GLuint uniform_MVP, uniform_dir, uniform_dir2, uniform_screen, uniform_ambient;
|
||||||
|
static GLuint TU_Albedo, TU_caustictex;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_albedo, unsigned TU_DiffuseMap, unsigned TU_Specmap, unsigned TU_SSAO, unsigned TU_caustictex);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BubbleShader
|
class BubbleShader
|
||||||
@ -213,6 +227,18 @@ public:
|
|||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PointLightShader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static GLuint Program;
|
||||||
|
static GLuint attrib_Position, attrib_Energy, attrib_Color;
|
||||||
|
static GLuint attrib_Corner;
|
||||||
|
static GLuint uniform_ntex, uniform_dtex, uniform_spec, uniform_screen, uniform_invproj, uniform_VM, uniform_PM;
|
||||||
|
|
||||||
|
static void init();
|
||||||
|
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 &InvProjMatrix, const core::vector2df &screen, unsigned spec, unsigned TU_ntex, unsigned TU_dtex);
|
||||||
|
};
|
||||||
|
|
||||||
class BillboardShader
|
class BillboardShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -386,17 +412,6 @@ public:
|
|||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PointLightShader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static GLuint Program;
|
|
||||||
static GLuint uniform_ntex, uniform_dtex, uniform_center, uniform_col, uniform_energy, uniform_spec, uniform_invproj, uniform_viewm;
|
|
||||||
static GLuint vao;
|
|
||||||
|
|
||||||
static void init();
|
|
||||||
static void setUniforms(const core::matrix4 &InvProjMatrix, const core::matrix4 &ViewMatrix, const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy, unsigned spec, unsigned TU_ntex, unsigned TU_dtex);
|
|
||||||
};
|
|
||||||
|
|
||||||
class SunLightShader
|
class SunLightShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -412,11 +427,11 @@ class DiffuseEnvMapShader
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_ntex, uniform_blueLmn, uniform_greenLmn, uniform_redLmn;
|
static GLuint uniform_ntex, uniform_TVM, uniform_blueLmn, uniform_greenLmn, uniform_redLmn;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex);
|
static void setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShadowedSunLightShader
|
class ShadowedSunLightShader
|
||||||
|
@ -23,72 +23,52 @@ void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
|
|||||||
{
|
{
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
GLmeshes.clear();
|
GLmeshes.clear();
|
||||||
|
for (unsigned i = 0; i < FPSM_COUNT; i++)
|
||||||
|
GeometricMesh[i].clear();
|
||||||
|
for (unsigned i = 0; i < SM_COUNT; i++)
|
||||||
|
ShadedMesh[i].clear();
|
||||||
CAnimatedMeshSceneNode::setMesh(mesh);
|
CAnimatedMeshSceneNode::setMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKAnimatedMesh::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
void STKAnimatedMesh::drawSolidPass1(const GLMesh &mesh, GeometricMaterial type)
|
||||||
{
|
{
|
||||||
assert(irr_driver->getPhase() == TRANSPARENT_PASS);
|
switch (type)
|
||||||
|
{
|
||||||
computeMVP(ModelViewProjectionMatrix);
|
case FPSM_ALPHA_REF_TEXTURE:
|
||||||
|
drawObjectRefPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, mesh.TextureMatrix);
|
||||||
if (World::getWorld()->getTrack()->isFogEnabled())
|
break;
|
||||||
drawTransparentFogObject(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
case FPSM_DEFAULT:
|
||||||
else
|
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||||
drawTransparentObject(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
break;
|
||||||
|
default:
|
||||||
return;
|
assert(0 && "Wrong geometric material");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
void STKAnimatedMesh::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
|
||||||
{
|
{
|
||||||
switch (irr_driver->getPhase())
|
switch (type)
|
||||||
{
|
{
|
||||||
case SOLID_NORMAL_AND_DEPTH_PASS:
|
case SM_ALPHA_REF_TEXTURE:
|
||||||
{
|
drawObjectRefPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
|
||||||
computeMVP(ModelViewProjectionMatrix);
|
break;
|
||||||
computeTIMV(TransposeInverseModelView);
|
case SM_RIMLIT:
|
||||||
|
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, mesh.TextureMatrix);
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
break;
|
||||||
drawObjectRefPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
case SM_UNLIT:
|
||||||
else
|
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
|
||||||
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
break;
|
||||||
break;
|
case SM_DETAILS:
|
||||||
}
|
drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
|
||||||
case SOLID_LIT_PASS:
|
break;
|
||||||
{
|
case SM_DEFAULT:
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
drawObjectPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
|
||||||
drawObjectRefPass2(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
break;
|
||||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
default:
|
||||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
assert(0 && "Wrong shaded material");
|
||||||
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
break;
|
||||||
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
|
}
|
||||||
else if (mesh.textures[1])
|
|
||||||
drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
|
|
||||||
else
|
|
||||||
drawObjectPass2(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
assert(0 && "wrong pass");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void STKAnimatedMesh::drawShadow(const GLMesh &mesh)
|
|
||||||
{
|
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
|
||||||
GLenum itype = mesh.IndexType;
|
|
||||||
size_t count = mesh.IndexCount;
|
|
||||||
assert(irr_driver->getPhase() == SHADOW_PASS);
|
|
||||||
std::vector<core::matrix4> ShadowMVP(irr_driver->getShadowViewProj());
|
|
||||||
for (unsigned i = 0; i < ShadowMVP.size(); i++)
|
|
||||||
ShadowMVP[i] *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
|
||||||
glUseProgram(MeshShader::ShadowShader::Program);
|
|
||||||
MeshShader::ShadowShader::setUniforms(ShadowMVP);
|
|
||||||
glBindVertexArray(mesh.vao_shadow_pass);
|
|
||||||
glDrawElements(ptype, count, itype, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKAnimatedMesh::render()
|
void STKAnimatedMesh::render()
|
||||||
@ -114,54 +94,142 @@ void STKAnimatedMesh::render()
|
|||||||
|
|
||||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||||
|
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
for (u32 i = 0; i<m->getMeshBufferCount(); ++i)
|
{
|
||||||
{
|
for (u32 i = 0; i < m->getMeshBufferCount(); ++i)
|
||||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
{
|
||||||
GLmeshes.push_back(allocateMeshBuffer(mb));
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
}
|
GLmeshes.push_back(allocateMeshBuffer(mb));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u32 i = 0; i < m->getMeshBufferCount(); ++i)
|
||||||
|
{
|
||||||
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
|
if (!mb)
|
||||||
|
continue;
|
||||||
|
video::E_MATERIAL_TYPE type = mb->getMaterial().MaterialType;
|
||||||
|
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(type);
|
||||||
|
if (!isObject(type))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
Log::warn("material", "Unhandled (animated) material type : %d", type);
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
GLMesh &mesh = GLmeshes[i];
|
||||||
|
if (rnd->isTransparent())
|
||||||
|
{
|
||||||
|
TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type);
|
||||||
|
initvaostate(mesh, TranspMat);
|
||||||
|
TransparentMesh[TranspMat].push_back(&mesh);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GeometricMaterial GeometricType = MaterialTypeToGeometricMaterial(type);
|
||||||
|
ShadedMaterial ShadedType = MaterialTypeToShadedMaterial(type, mesh.textures);
|
||||||
|
initvaostate(mesh, GeometricType, ShadedType);
|
||||||
|
GeometricMesh[GeometricType].push_back(&mesh);
|
||||||
|
ShadedMesh[ShadedType].push_back(&mesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
|
|
||||||
// render original meshes
|
for (u32 i = 0; i<m->getMeshBufferCount(); ++i)
|
||||||
for (u32 i = 0; i<m->getMeshBufferCount(); ++i)
|
{
|
||||||
{
|
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
||||||
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
|
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
||||||
bool transparent = (rnd && rnd->isTransparent());
|
|
||||||
|
|
||||||
// only render transparent buffer if this is the transparent render pass
|
|
||||||
// and solid only in solid pass
|
|
||||||
if (transparent != isTransparentPass)
|
|
||||||
continue;
|
|
||||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
|
||||||
TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
|
||||||
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
|
||||||
if (RenderFromIdentity)
|
|
||||||
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
|
||||||
else if (Mesh->getMeshType() == scene::EAMT_SKINNED)
|
|
||||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((scene::SSkinMeshBuffer*)mb)->Transformation);
|
|
||||||
if (isObject(material.MaterialType))
|
if (isObject(material.MaterialType))
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
|
||||||
initvaostate(GLmeshes[i], material.MaterialType);
|
{
|
||||||
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
|
glBindVertexArray(0);
|
||||||
{
|
glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer);
|
||||||
glBindVertexArray(0);
|
glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices());
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer);
|
}
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices());
|
}
|
||||||
}
|
if (mb)
|
||||||
if (irr_driver->getPhase() == SHADOW_PASS)
|
GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
||||||
drawShadow(GLmeshes[i]);
|
|
||||||
else if (isTransparentPass)
|
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
|
||||||
drawTransparent(GLmeshes[i], material.MaterialType);
|
bool transparent = (rnd && rnd->isTransparent());
|
||||||
else
|
|
||||||
drawSolid(GLmeshes[i], material.MaterialType);
|
// only render transparent buffer if this is the transparent render pass
|
||||||
}
|
// and solid only in solid pass
|
||||||
else
|
if (transparent != isTransparentPass)
|
||||||
{
|
continue;
|
||||||
#ifdef DEBUG
|
|
||||||
Log::warn("material", "Unhandled (animated) material type : %d", material.MaterialType);
|
if (RenderFromIdentity)
|
||||||
#endif
|
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
||||||
continue;
|
else if (Mesh->getMeshType() == scene::EAMT_SKINNED)
|
||||||
}
|
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((scene::SSkinMeshBuffer*)mb)->Transformation);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
|
||||||
|
{
|
||||||
|
computeMVP(ModelViewProjectionMatrix);
|
||||||
|
computeTIMV(TransposeInverseModelView);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectPass1Shader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||||
|
drawSolidPass1(*GeometricMesh[FPSM_DEFAULT][i], FPSM_DEFAULT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||||
|
drawSolidPass1(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i], FPSM_ALPHA_REF_TEXTURE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == SOLID_LIT_PASS)
|
||||||
|
{
|
||||||
|
glUseProgram(MeshShader::ObjectPass2Shader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_DEFAULT][i], SM_DEFAULT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectRefPass2Shader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_ALPHA_REF_TEXTURE][i], SM_ALPHA_REF_TEXTURE);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_RIMLIT][i], SM_RIMLIT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectUnlitShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_UNLIT].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_UNLIT][i], SM_UNLIT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_DETAILS].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_DETAILS][i], SM_DETAILS);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == SHADOW_PASS)
|
||||||
|
{
|
||||||
|
glUseProgram(MeshShader::ShadowShader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||||
|
drawShadow(*GeometricMesh[FPSM_DEFAULT][i]);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::RefShadowShader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||||
|
drawShadowRef(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == TRANSPARENT_PASS)
|
||||||
|
{
|
||||||
|
computeMVP(ModelViewProjectionMatrix);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::BubbleShader::Program);
|
||||||
|
for (unsigned i = 0; i < TransparentMesh[TM_BUBBLE].size(); i++)
|
||||||
|
drawBubble(*TransparentMesh[TM_BUBBLE][i], ModelViewProjectionMatrix);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::TransparentShader::Program);
|
||||||
|
for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++)
|
||||||
|
drawTransparentObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,13 @@ class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
bool firstTime;
|
bool firstTime;
|
||||||
|
std::vector<GLMesh *> GeometricMesh[FPSM_COUNT];
|
||||||
|
std::vector<GLMesh *> ShadedMesh[SM_COUNT];
|
||||||
|
std::vector<GLMesh *> TransparentMesh[TM_COUNT];
|
||||||
std::vector<GLMesh> GLmeshes;
|
std::vector<GLMesh> GLmeshes;
|
||||||
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix;
|
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
|
||||||
void drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
void drawSolidPass1(const GLMesh &mesh, GeometricMaterial type);
|
||||||
void drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
void drawSolidPass2(const GLMesh &mesh, ShadedMaterial type);
|
||||||
void drawShadow(const GLMesh &mesh);
|
|
||||||
public:
|
public:
|
||||||
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
|
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
|
||||||
irr::scene::ISceneManager* mgr, irr::s32 id,
|
irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||||
|
@ -5,23 +5,13 @@
|
|||||||
|
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
static GLuint billboardvbo;
|
|
||||||
static GLuint billboardvao = 0;
|
static GLuint billboardvao = 0;
|
||||||
|
|
||||||
static void createbillboardvao()
|
static void createbillboardvao()
|
||||||
{
|
{
|
||||||
float quad[] = {
|
|
||||||
-.5, -.5, 0., 1.,
|
|
||||||
-.5, .5, 0., 0.,
|
|
||||||
.5, -.5, 1., 1.,
|
|
||||||
.5, .5, 1., 0.,
|
|
||||||
};
|
|
||||||
|
|
||||||
glGenBuffers(1, &billboardvbo);
|
|
||||||
glGenVertexArrays(1, &billboardvao);
|
glGenVertexArrays(1, &billboardvao);
|
||||||
glBindVertexArray(billboardvao);
|
glBindVertexArray(billboardvao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, billboardvbo);
|
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
|
||||||
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad, GL_STATIC_DRAW);
|
|
||||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
|
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
|
||||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
|
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
|
||||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||||
|
@ -9,6 +9,49 @@
|
|||||||
#include "graphics/camera.hpp"
|
#include "graphics/camera.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
|
||||||
|
GeometricMaterial MaterialTypeToGeometricMaterial(video::E_MATERIAL_TYPE MaterialType)
|
||||||
|
{
|
||||||
|
if (MaterialType == irr_driver->getShader(ES_NORMAL_MAP))
|
||||||
|
return FPSM_NORMAL_MAP;
|
||||||
|
else if (MaterialType == irr_driver->getShader(ES_OBJECTPASS_REF) || MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
||||||
|
return FPSM_ALPHA_REF_TEXTURE;
|
||||||
|
else if (MaterialType == irr_driver->getShader(ES_GRASS) || MaterialType == irr_driver->getShader(ES_GRASS_REF))
|
||||||
|
return FPSM_GRASS;
|
||||||
|
else
|
||||||
|
return FPSM_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShadedMaterial MaterialTypeToShadedMaterial(video::E_MATERIAL_TYPE type, GLuint *textures)
|
||||||
|
{
|
||||||
|
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||||
|
return SM_SPHEREMAP;
|
||||||
|
else if (type == irr_driver->getShader(ES_SPLATTING))
|
||||||
|
return SM_SPLATTING;
|
||||||
|
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF) || type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
||||||
|
return SM_ALPHA_REF_TEXTURE;
|
||||||
|
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||||
|
return SM_RIMLIT;
|
||||||
|
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||||
|
return SM_GRASS;
|
||||||
|
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
||||||
|
return SM_UNLIT;
|
||||||
|
else if (type == irr_driver->getShader(ES_CAUSTICS))
|
||||||
|
return SM_CAUSTICS;
|
||||||
|
else if (textures[1] && type != irr_driver->getShader(ES_NORMAL_MAP))
|
||||||
|
return SM_DETAILS;
|
||||||
|
else if (!textures[0])
|
||||||
|
return SM_UNTEXTURED;
|
||||||
|
else
|
||||||
|
return SM_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type)
|
||||||
|
{
|
||||||
|
if (type == irr_driver->getShader(ES_BUBBLES))
|
||||||
|
return TM_BUBBLE;
|
||||||
|
else
|
||||||
|
return TM_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride)
|
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride)
|
||||||
{
|
{
|
||||||
@ -141,6 +184,7 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
|
|||||||
else
|
else
|
||||||
result.textures[i] = 0;
|
result.textures[i] = 0;
|
||||||
}
|
}
|
||||||
|
result.TextureMatrix = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,11 +206,11 @@ void computeTIMV(core::matrix4 &TransposeInverseModelView)
|
|||||||
|
|
||||||
void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
glUseProgram(MeshShader::ObjectPass1Shader::Program);
|
|
||||||
MeshShader::ObjectPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView);
|
MeshShader::ObjectPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
@ -175,6 +219,7 @@ void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjecti
|
|||||||
|
|
||||||
void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
@ -182,7 +227,6 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje
|
|||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
|
|
||||||
MeshShader::ObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix, 0);
|
MeshShader::ObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix, 0);
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
@ -191,13 +235,13 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje
|
|||||||
|
|
||||||
void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir)
|
void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
glUseProgram(MeshShader::GrassPass1Shader::Program);
|
|
||||||
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
|
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
@ -206,6 +250,7 @@ void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
|||||||
|
|
||||||
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
@ -213,7 +258,6 @@ void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
|||||||
assert(mesh.textures[1]);
|
assert(mesh.textures[1]);
|
||||||
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
glUseProgram(MeshShader::NormalMapShader::Program);
|
|
||||||
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
|
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
@ -222,11 +266,12 @@ void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
|||||||
|
|
||||||
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0 + MeshShader::SphereMapShader::TU_tex);
|
||||||
if (!irr_driver->SkyboxCubeMap)
|
if (!irr_driver->SkyboxCubeMap)
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
||||||
@ -234,13 +279,12 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_TEXTURE_CUBE_MAP, irr_driver->SkyboxCubeMap);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, irr_driver->SkyboxCubeMap);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(MeshShader::SphereMapShader::Program);
|
MeshShader::SphereMapShader::setUniforms(ModelViewProjectionMatrix, irr_driver->getViewMatrix().getTransposed(), TransposeInverseModelView, irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height));
|
||||||
MeshShader::SphereMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 0);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -253,12 +297,13 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
|
|
||||||
void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
// Texlayout
|
// Texlayout
|
||||||
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::SplattingShader::TU_tex_layout, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -270,7 +315,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
//Tex detail0
|
//Tex detail0
|
||||||
setTexture(1, mesh.textures[2], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::SplattingShader::TU_tex_detail0, mesh.textures[2], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -282,7 +327,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
//Tex detail1
|
//Tex detail1
|
||||||
setTexture(2, mesh.textures[3], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::SplattingShader::TU_tex_detail1, mesh.textures[3], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -294,7 +339,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
//Tex detail2
|
//Tex detail2
|
||||||
setTexture(3, mesh.textures[4], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::SplattingShader::TU_tex_detail2, mesh.textures[4], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -306,7 +351,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
//Tex detail3
|
//Tex detail3
|
||||||
setTexture(4, mesh.textures[5], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::SplattingShader::TU_tex_detail3, mesh.textures[5], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -317,22 +362,8 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
// Diffuse
|
|
||||||
setTexture(5, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
|
||||||
|
|
||||||
// Specular
|
MeshShader::SplattingShader::setUniforms(ModelViewProjectionMatrix);
|
||||||
setTexture(6, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
|
|
||||||
// SSAO
|
|
||||||
setTexture(7, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE};
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
glUseProgram(MeshShader::SplattingShader::Program);
|
|
||||||
MeshShader::SplattingShader::setUniforms(ModelViewProjectionMatrix, 0, 1, 2, 3, 4, 5, 6, 7);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -340,11 +371,12 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
|
|||||||
|
|
||||||
void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::ObjectRefPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -355,17 +387,8 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
|
|||||||
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(3, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE};
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
glUseProgram(MeshShader::ObjectRefPass2Shader::Program);
|
MeshShader::ObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
|
||||||
MeshShader::ObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0, 1, 2, 3);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -373,11 +396,12 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
|
|||||||
|
|
||||||
void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector2df dir, core::vector2df dir2)
|
void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector2df dir, core::vector2df dir2)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::CausticsShader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||||
@ -388,19 +412,9 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM
|
|||||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
setTexture(1, getTextureGLuint(irr_driver->getTexture(file_manager->getAsset("textures/caustics.png").c_str())), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::CausticsShader::TU_caustictex, getTextureGLuint(irr_driver->getTexture(file_manager->getAsset("textures/caustics.png").c_str())), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(3, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(4, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
MeshShader::CausticsShader::setUniforms(ModelViewProjectionMatrix, dir, dir2, core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height));
|
||||||
glUseProgram(MeshShader::CausticsShader::Program);
|
|
||||||
MeshShader::CausticsShader::setUniforms(ModelViewProjectionMatrix, dir, dir2, core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 0, 2, 3, 4, 1);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -408,11 +422,12 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM
|
|||||||
|
|
||||||
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir)
|
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::GrassPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -423,17 +438,8 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
|||||||
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(3, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE};
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
glUseProgram(MeshShader::GrassPass2Shader::Program);
|
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir);
|
||||||
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir, 0, 1, 2, 3);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -441,22 +447,12 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
|||||||
|
|
||||||
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
MeshShader::UntexturedObjectShader::setUniforms(ModelViewProjectionMatrix);
|
||||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE};
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
glUseProgram(MeshShader::UntexturedObjectShader::Program);
|
|
||||||
MeshShader::UntexturedObjectShader::setUniforms(ModelViewProjectionMatrix, 0, 1, 2);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -464,11 +460,12 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj
|
|||||||
|
|
||||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::ObjectRimLimitShader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||||
@ -480,17 +477,7 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
||||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(3, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
|
|
||||||
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix, 0, 1, 2, 3);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -498,11 +485,12 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
|
|||||||
|
|
||||||
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::ObjectUnlitShader::TU_tex, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||||
@ -514,9 +502,7 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix);
|
||||||
glUseProgram(MeshShader::ObjectUnlitShader::Program);
|
|
||||||
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix, 0);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -524,11 +510,12 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
|
|||||||
|
|
||||||
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::DetailledObjectPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
@ -540,19 +527,9 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTexture(1, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::DetailledObjectPass2Shader::TU_detail, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix);
|
||||||
setTexture(3, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(4, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE};
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
|
|
||||||
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, 0, 1, 2, 3, 4);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -560,11 +537,12 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
|
|||||||
|
|
||||||
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::ObjectPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||||
@ -576,17 +554,7 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
|
|||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
|
||||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
|
||||||
setTexture(3, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
|
||||||
if (!UserConfigParams::m_ssao)
|
|
||||||
{
|
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
glUseProgram(MeshShader::ObjectPass2Shader::Program);
|
|
||||||
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0, 1, 2, 3);
|
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
@ -594,13 +562,13 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
|
|||||||
|
|
||||||
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
glUseProgram(MeshShader::TransparentShader::Program);
|
|
||||||
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
|
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
@ -609,6 +577,7 @@ void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewPro
|
|||||||
|
|
||||||
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
@ -638,6 +607,7 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
|
|||||||
|
|
||||||
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||||
float transparency = 1.;
|
float transparency = 1.;
|
||||||
|
|
||||||
@ -647,13 +617,54 @@ void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatr
|
|||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
glUseProgram(MeshShader::BubbleShader::Program);
|
|
||||||
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
|
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawShadowRef(const GLMesh &mesh)
|
||||||
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
|
GLenum itype = mesh.IndexType;
|
||||||
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
|
std::vector<core::matrix4> ShadowMVP(irr_driver->getShadowViewProj());
|
||||||
|
for (unsigned i = 0; i < ShadowMVP.size(); i++)
|
||||||
|
ShadowMVP[i] *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||||
|
|
||||||
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
MeshShader::RefShadowShader::setUniforms(ShadowMVP, 0);
|
||||||
|
|
||||||
|
glBindVertexArray(mesh.vao_shadow_pass);
|
||||||
|
glDrawElements(ptype, count, itype, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawShadow(const GLMesh &mesh)
|
||||||
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
|
GLenum itype = mesh.IndexType;
|
||||||
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
|
std::vector<core::matrix4> ShadowMVP(irr_driver->getShadowViewProj());
|
||||||
|
for (unsigned i = 0; i < ShadowMVP.size(); i++)
|
||||||
|
ShadowMVP[i] *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||||
|
|
||||||
|
/* if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||||
|
{
|
||||||
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
glUseProgram(MeshShader::GrassShadowShader::Program);
|
||||||
|
MeshShader::GrassShadowShader::setUniforms(ShadowMVP, windDir, 0);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
MeshShader::ShadowShader::setUniforms(ShadowMVP);
|
||||||
|
|
||||||
|
glBindVertexArray(mesh.vao_shadow_pass);
|
||||||
|
glDrawElements(ptype, count, itype, 0);
|
||||||
|
}
|
||||||
|
|
||||||
bool isObject(video::E_MATERIAL_TYPE type)
|
bool isObject(video::E_MATERIAL_TYPE type)
|
||||||
{
|
{
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS))
|
if (type == irr_driver->getShader(ES_OBJECTPASS))
|
||||||
@ -684,137 +695,119 @@ bool isObject(video::E_MATERIAL_TYPE type)
|
|||||||
return true;
|
return true;
|
||||||
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
|
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
|
||||||
return true;
|
return true;
|
||||||
|
if (type == video::EMT_SOLID)
|
||||||
|
return true;
|
||||||
|
if (type == video::EMT_LIGHTMAP_LIGHTING)
|
||||||
|
return true;
|
||||||
|
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
|
||||||
{
|
{
|
||||||
switch (irr_driver->getPhase())
|
switch (GeoMat)
|
||||||
{
|
{
|
||||||
case SOLID_NORMAL_AND_DEPTH_PASS:
|
case FPSM_DEFAULT:
|
||||||
if (mesh.vao_first_pass)
|
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
return;
|
MeshShader::ObjectPass1Shader::attrib_position, -1, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||||
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
{
|
break;
|
||||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
case FPSM_ALPHA_REF_TEXTURE:
|
||||||
MeshShader::NormalMapShader::attrib_position, MeshShader::NormalMapShader::attrib_texcoord, -1, -1, MeshShader::NormalMapShader::attrib_tangent, MeshShader::NormalMapShader::attrib_bitangent, -1, mesh.Stride);
|
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
}
|
MeshShader::ObjectRefPass1Shader::attrib_position, MeshShader::ObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::ObjectRefPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::RefShadowShader::attrib_position, MeshShader::RefShadowShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
{
|
break;
|
||||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
case FPSM_NORMAL_MAP:
|
||||||
MeshShader::ObjectPass1Shader::attrib_position, MeshShader::ObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
|
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
}
|
MeshShader::NormalMapShader::attrib_position, MeshShader::NormalMapShader::attrib_texcoord, -1, -1, MeshShader::NormalMapShader::attrib_tangent, MeshShader::NormalMapShader::attrib_bitangent, -1, mesh.Stride);
|
||||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
{
|
break;
|
||||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
case FPSM_GRASS:
|
||||||
MeshShader::GrassPass1Shader::attrib_position, MeshShader::GrassPass1Shader::attrib_texcoord, -1, MeshShader::GrassPass1Shader::attrib_normal, -1, -1, MeshShader::GrassPass1Shader::attrib_color, mesh.Stride);
|
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
}
|
MeshShader::GrassPass1Shader::attrib_position, MeshShader::GrassPass1Shader::attrib_texcoord, -1, MeshShader::GrassPass1Shader::attrib_normal, -1, -1, MeshShader::GrassPass1Shader::attrib_color, mesh.Stride);
|
||||||
else
|
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::GrassShadowShader::attrib_position, MeshShader::GrassShadowShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassShadowShader::attrib_color, mesh.Stride);
|
||||||
{
|
break;
|
||||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
default:
|
||||||
MeshShader::ObjectPass1Shader::attrib_position, -1, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
|
assert(0 && "Unknow material");
|
||||||
}
|
break;
|
||||||
return;
|
}
|
||||||
case SOLID_LIT_PASS:
|
|
||||||
if (mesh.vao_second_pass)
|
switch (ShadedMat)
|
||||||
return;
|
{
|
||||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
case SM_SPHEREMAP:
|
||||||
{
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
MeshShader::SphereMapShader::attrib_position, -1, -1, MeshShader::SphereMapShader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||||
MeshShader::SphereMapShader::attrib_position, -1, -1, MeshShader::SphereMapShader::attrib_normal, -1, -1, -1, mesh.Stride);
|
break;
|
||||||
}
|
case SM_SPLATTING:
|
||||||
else if (type == irr_driver->getShader(ES_SPLATTING))
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
{
|
MeshShader::SplattingShader::attrib_position, MeshShader::SplattingShader::attrib_texcoord, MeshShader::SplattingShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
break;
|
||||||
MeshShader::SplattingShader::attrib_position, MeshShader::SplattingShader::attrib_texcoord, MeshShader::SplattingShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
case SM_ALPHA_REF_TEXTURE:
|
||||||
}
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
MeshShader::ObjectRefPass2Shader::attrib_position, MeshShader::ObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
{
|
break;
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
case SM_RIMLIT:
|
||||||
MeshShader::ObjectRefPass2Shader::attrib_position, MeshShader::ObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
}
|
MeshShader::ObjectRimLimitShader::attrib_position, MeshShader::ObjectRimLimitShader::attrib_texcoord, -1, MeshShader::ObjectRimLimitShader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
break;
|
||||||
{
|
case SM_GRASS:
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
MeshShader::ObjectRimLimitShader::attrib_position, MeshShader::ObjectRimLimitShader::attrib_texcoord, -1, MeshShader::ObjectRimLimitShader::attrib_normal, -1, -1, -1, mesh.Stride);
|
MeshShader::GrassPass2Shader::attrib_position, MeshShader::GrassPass2Shader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassPass2Shader::attrib_color, mesh.Stride);
|
||||||
}
|
break;
|
||||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
case SM_UNLIT:
|
||||||
{
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
MeshShader::ObjectUnlitShader::attrib_position, MeshShader::ObjectUnlitShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
MeshShader::GrassPass2Shader::attrib_position, MeshShader::GrassPass2Shader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassPass2Shader::attrib_color, mesh.Stride);
|
break;
|
||||||
}
|
case SM_CAUSTICS:
|
||||||
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
{
|
MeshShader::CausticsShader::attrib_position, MeshShader::CausticsShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
break;
|
||||||
MeshShader::ObjectUnlitShader::attrib_position, MeshShader::ObjectUnlitShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
case SM_DETAILS:
|
||||||
}
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
else if (type == irr_driver->getShader(ES_CAUSTICS))
|
MeshShader::DetailledObjectPass2Shader::attrib_position, MeshShader::DetailledObjectPass2Shader::attrib_texcoord, MeshShader::DetailledObjectPass2Shader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
||||||
{
|
break;
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
case SM_UNTEXTURED:
|
||||||
MeshShader::CausticsShader::attrib_position, MeshShader::CausticsShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
}
|
MeshShader::UntexturedObjectShader::attrib_position, -1, -1, -1, -1, -1, MeshShader::UntexturedObjectShader::attrib_color, mesh.Stride);
|
||||||
else if (mesh.textures[1])
|
break;
|
||||||
{
|
case SM_DEFAULT:
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
MeshShader::DetailledObjectPass2Shader::attrib_position, MeshShader::DetailledObjectPass2Shader::attrib_texcoord, MeshShader::DetailledObjectPass2Shader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
MeshShader::ObjectPass2Shader::attrib_position, MeshShader::ObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
}
|
break;
|
||||||
else if (!mesh.textures[0])
|
default:
|
||||||
{
|
assert(0 && "unknow shaded material");
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
break;
|
||||||
MeshShader::UntexturedObjectShader::attrib_position, -1, -1, -1, -1, -1, MeshShader::UntexturedObjectShader::attrib_color, mesh.Stride);
|
}
|
||||||
}
|
|
||||||
else
|
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
{
|
mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
if (mesh.Stride >= 44)
|
||||||
MeshShader::ObjectPass2Shader::attrib_position, MeshShader::ObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
case GLOW_PASS:
|
void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat)
|
||||||
if (mesh.vao_glow_pass)
|
{
|
||||||
return;
|
switch (TranspMat)
|
||||||
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
{
|
||||||
return;
|
case TM_BUBBLE:
|
||||||
case TRANSPARENT_PASS:
|
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
if (mesh.vao_first_pass)
|
MeshShader::BubbleShader::attrib_position, MeshShader::BubbleShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
return;
|
break;
|
||||||
if (type == irr_driver->getShader(ES_BUBBLES))
|
case TM_DEFAULT:
|
||||||
{
|
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
MeshShader::BubbleShader::attrib_position, MeshShader::BubbleShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
break;
|
||||||
}
|
}
|
||||||
else if (World::getWorld()->getTrack()->isFogEnabled())
|
mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
{
|
if (mesh.Stride >= 44)
|
||||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
||||||
MeshShader::TransparentFogShader::attrib_position, MeshShader::TransparentFogShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
|
||||||
}
|
/*
|
||||||
else
|
else if (World::getWorld()->getTrack()->isFogEnabled())
|
||||||
{
|
{
|
||||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||||
MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
MeshShader::TransparentFogShader::attrib_position, MeshShader::TransparentFogShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||||
}
|
}*/
|
||||||
return;
|
|
||||||
case DISPLACEMENT_PASS:
|
|
||||||
if (mesh.vao_displace_pass)
|
|
||||||
return;
|
|
||||||
mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position,-1, -1, -1, -1, -1, -1, mesh.Stride);
|
|
||||||
mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
|
||||||
return;
|
|
||||||
case SHADOW_PASS:
|
|
||||||
if (mesh.vao_shadow_pass)
|
|
||||||
return;
|
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
|
||||||
{
|
|
||||||
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::RefShadowShader::attrib_position, MeshShader::RefShadowShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
|
||||||
}
|
|
||||||
/*else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
|
||||||
{
|
|
||||||
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::GrassShadowShader::attrib_position, MeshShader::GrassShadowShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassShadowShader::attrib_color, mesh.Stride);
|
|
||||||
}*/
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,37 @@
|
|||||||
#include "glwrap.hpp"
|
#include "glwrap.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
enum GeometricMaterial
|
||||||
|
{
|
||||||
|
FPSM_DEFAULT,
|
||||||
|
FPSM_ALPHA_REF_TEXTURE,
|
||||||
|
FPSM_NORMAL_MAP,
|
||||||
|
FPSM_GRASS,
|
||||||
|
FPSM_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ShadedMaterial
|
||||||
|
{
|
||||||
|
SM_DEFAULT,
|
||||||
|
SM_ALPHA_REF_TEXTURE,
|
||||||
|
SM_RIMLIT,
|
||||||
|
SM_SPHEREMAP,
|
||||||
|
SM_SPLATTING,
|
||||||
|
SM_GRASS,
|
||||||
|
SM_UNLIT,
|
||||||
|
SM_CAUSTICS,
|
||||||
|
SM_DETAILS,
|
||||||
|
SM_UNTEXTURED,
|
||||||
|
SM_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum TransparentMaterial
|
||||||
|
{
|
||||||
|
TM_DEFAULT,
|
||||||
|
TM_BUBBLE,
|
||||||
|
TM_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
struct GLMesh {
|
struct GLMesh {
|
||||||
GLuint vao_first_pass;
|
GLuint vao_first_pass;
|
||||||
GLuint vao_second_pass;
|
GLuint vao_second_pass;
|
||||||
@ -22,11 +53,13 @@ struct GLMesh {
|
|||||||
GLenum IndexType;
|
GLenum IndexType;
|
||||||
size_t IndexCount;
|
size_t IndexCount;
|
||||||
size_t Stride;
|
size_t Stride;
|
||||||
|
core::matrix4 TextureMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride);
|
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride);
|
||||||
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb);
|
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb);
|
||||||
void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat);
|
||||||
|
void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat);
|
||||||
void computeMVP(core::matrix4 &ModelViewProjectionMatrix);
|
void computeMVP(core::matrix4 &ModelViewProjectionMatrix);
|
||||||
void computeTIMV(core::matrix4 &TransposeInverseModelView);
|
void computeTIMV(core::matrix4 &TransposeInverseModelView);
|
||||||
bool isObject(video::E_MATERIAL_TYPE type);
|
bool isObject(video::E_MATERIAL_TYPE type);
|
||||||
@ -49,9 +82,17 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
|
|||||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
||||||
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
|
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
|
|
||||||
|
// Shadow pass
|
||||||
|
void drawShadowRef(const GLMesh &mesh);
|
||||||
|
void drawShadow(const GLMesh &mesh);
|
||||||
|
|
||||||
// Forward pass (for transparents meshes)
|
// Forward pass (for transparents meshes)
|
||||||
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||||
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||||
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
|
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
|
|
||||||
#endif // STKMESH_H
|
GeometricMaterial MaterialTypeToGeometricMaterial(video::E_MATERIAL_TYPE);
|
||||||
|
ShadedMaterial MaterialTypeToShadedMaterial(video::E_MATERIAL_TYPE, GLuint *textures);
|
||||||
|
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE);
|
||||||
|
|
||||||
|
#endif // STKMESH_H
|
||||||
|
@ -42,6 +42,46 @@ void STKMeshSceneNode::createGLMeshes()
|
|||||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
GLmeshes.push_back(allocateMeshBuffer(mb));
|
GLmeshes.push_back(allocateMeshBuffer(mb));
|
||||||
}
|
}
|
||||||
|
isMaterialInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void STKMeshSceneNode::setFirstTimeMaterial()
|
||||||
|
{
|
||||||
|
if (isMaterialInitialized)
|
||||||
|
return;
|
||||||
|
irr::video::IVideoDriver* driver = irr_driver->getVideoDriver();
|
||||||
|
for (u32 i = 0; i<Mesh->getMeshBufferCount(); ++i)
|
||||||
|
{
|
||||||
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
|
if (!mb)
|
||||||
|
continue;
|
||||||
|
video::E_MATERIAL_TYPE type = mb->getMaterial().MaterialType;
|
||||||
|
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(type);
|
||||||
|
if (!isObject(type))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
Log::warn("material", "Unhandled (static) material type : %d", type);
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLMesh &mesh = GLmeshes[i];
|
||||||
|
if (rnd->isTransparent())
|
||||||
|
{
|
||||||
|
TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type);
|
||||||
|
initvaostate(mesh, TranspMat);
|
||||||
|
TransparentMesh[TranspMat].push_back(&mesh);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GeometricMaterial GeometricType = MaterialTypeToGeometricMaterial(type);
|
||||||
|
ShadedMaterial ShadedType = MaterialTypeToShadedMaterial(type, mesh.textures);
|
||||||
|
initvaostate(mesh, GeometricType, ShadedType);
|
||||||
|
GeometricMesh[GeometricType].push_back(&mesh);
|
||||||
|
ShadedMesh[ShadedType].push_back(&mesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isMaterialInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKMeshSceneNode::cleanGLMeshes()
|
void STKMeshSceneNode::cleanGLMeshes()
|
||||||
@ -63,6 +103,10 @@ void STKMeshSceneNode::cleanGLMeshes()
|
|||||||
glDeleteBuffers(1, &(mesh.index_buffer));
|
glDeleteBuffers(1, &(mesh.index_buffer));
|
||||||
}
|
}
|
||||||
GLmeshes.clear();
|
GLmeshes.clear();
|
||||||
|
for (unsigned i = 0; i < FPSM_COUNT; i++)
|
||||||
|
GeometricMesh[i].clear();
|
||||||
|
for (unsigned i = 0; i < SM_COUNT; i++)
|
||||||
|
ShadedMesh[i].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKMeshSceneNode::setMesh(irr::scene::IMesh* mesh)
|
void STKMeshSceneNode::setMesh(irr::scene::IMesh* mesh)
|
||||||
@ -86,7 +130,6 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
|
|||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
computeMVP(ModelViewProjectionMatrix);
|
computeMVP(ModelViewProjectionMatrix);
|
||||||
glUseProgram(MeshShader::ColorizeShader::Program);
|
|
||||||
MeshShader::ColorizeShader::setUniforms(ModelViewProjectionMatrix, cb->getRed(), cb->getGreen(), cb->getBlue());
|
MeshShader::ColorizeShader::setUniforms(ModelViewProjectionMatrix, cb->getRed(), cb->getGreen(), cb->getBlue());
|
||||||
|
|
||||||
glBindVertexArray(mesh.vao_glow_pass);
|
glBindVertexArray(mesh.vao_glow_pass);
|
||||||
@ -135,114 +178,92 @@ void STKMeshSceneNode::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYP
|
|||||||
|
|
||||||
if (type == irr_driver->getShader(ES_BUBBLES))
|
if (type == irr_driver->getShader(ES_BUBBLES))
|
||||||
drawBubble(mesh, ModelViewProjectionMatrix);
|
drawBubble(mesh, ModelViewProjectionMatrix);
|
||||||
else if (World::getWorld()->getTrack()->isFogEnabled())
|
// else if (World::getWorld()->getTrack()->isFogEnabled())
|
||||||
drawTransparentFogObject(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
// drawTransparentFogObject(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
||||||
else
|
else
|
||||||
drawTransparentObject(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
drawTransparentObject(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKMeshSceneNode::drawShadow(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
void STKMeshSceneNode::drawSolidPass1(const GLMesh &mesh, GeometricMaterial type)
|
||||||
{
|
{
|
||||||
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
windDir = getWind();
|
||||||
GLenum itype = mesh.IndexType;
|
switch (type)
|
||||||
size_t count = mesh.IndexCount;
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<core::matrix4> ShadowMVP(irr_driver->getShadowViewProj());
|
|
||||||
for (unsigned i = 0; i < ShadowMVP.size(); i++)
|
|
||||||
ShadowMVP[i] *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
|
||||||
|
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
|
||||||
{
|
{
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
case FPSM_NORMAL_MAP:
|
||||||
glUseProgram(MeshShader::RefShadowShader::Program);
|
drawNormalPass(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||||
MeshShader::RefShadowShader::setUniforms(ShadowMVP, 0);
|
break;
|
||||||
|
case FPSM_ALPHA_REF_TEXTURE:
|
||||||
|
drawObjectRefPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, mesh.TextureMatrix);
|
||||||
|
break;
|
||||||
|
case FPSM_GRASS:
|
||||||
|
drawGrassPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, windDir);
|
||||||
|
break;
|
||||||
|
case FPSM_DEFAULT:
|
||||||
|
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0 && "wrong geometric material");
|
||||||
}
|
}
|
||||||
/* else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
|
||||||
{
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
|
||||||
glUseProgram(MeshShader::GrassShadowShader::Program);
|
|
||||||
MeshShader::GrassShadowShader::setUniforms(ShadowMVP, windDir, 0);
|
|
||||||
}*/
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glUseProgram(MeshShader::ShadowShader::Program);
|
|
||||||
MeshShader::ShadowShader::setUniforms(ShadowMVP);
|
|
||||||
}
|
|
||||||
glBindVertexArray(mesh.vao_shadow_pass);
|
|
||||||
glDrawElements(ptype, count, itype, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKMeshSceneNode::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
void STKMeshSceneNode::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
|
||||||
{
|
{
|
||||||
switch (irr_driver->getPhase())
|
switch (type)
|
||||||
{
|
{
|
||||||
case SOLID_NORMAL_AND_DEPTH_PASS:
|
case SM_SPHEREMAP:
|
||||||
|
drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||||
|
break;
|
||||||
|
case SM_SPLATTING:
|
||||||
|
drawSplatting(mesh, ModelViewProjectionMatrix);
|
||||||
|
break;
|
||||||
|
case SM_ALPHA_REF_TEXTURE:
|
||||||
|
drawObjectRefPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
|
||||||
|
break;
|
||||||
|
case SM_GRASS:
|
||||||
|
drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
|
||||||
|
break;
|
||||||
|
case SM_RIMLIT:
|
||||||
|
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, core::matrix4::EM4CONST_IDENTITY);
|
||||||
|
break;
|
||||||
|
case SM_UNLIT:
|
||||||
|
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
|
||||||
|
break;
|
||||||
|
case SM_CAUSTICS:
|
||||||
{
|
{
|
||||||
windDir = getWind();
|
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||||
|
const float speed = World::getWorld()->getTrack()->getCausticsSpeed();
|
||||||
|
|
||||||
computeMVP(ModelViewProjectionMatrix);
|
float strength = time;
|
||||||
computeTIMV(TransposeInverseModelView);
|
strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.001f;
|
||||||
|
|
||||||
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
vector3df wind = irr_driver->getWind() * strength * speed;
|
||||||
drawNormalPass(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
caustic_dir.X += wind.X;
|
||||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
caustic_dir.Y += wind.Z;
|
||||||
drawObjectRefPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
|
||||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
strength = time * 0.56f + sinf(time);
|
||||||
drawGrassPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, windDir);
|
strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.001f;
|
||||||
else
|
|
||||||
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
wind = irr_driver->getWind() * strength * speed;
|
||||||
|
wind.rotateXZBy(cosf(time));
|
||||||
|
caustic_dir2.X += wind.X;
|
||||||
|
caustic_dir2.Y += wind.Z;
|
||||||
|
drawCaustics(mesh, ModelViewProjectionMatrix, caustic_dir, caustic_dir2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SOLID_LIT_PASS:
|
case SM_DETAILS:
|
||||||
{
|
drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
|
||||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
break;
|
||||||
drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
case SM_UNTEXTURED:
|
||||||
else if (type == irr_driver->getShader(ES_SPLATTING))
|
drawUntexturedObject(mesh, ModelViewProjectionMatrix);
|
||||||
drawSplatting(mesh, ModelViewProjectionMatrix);
|
break;
|
||||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
case SM_DEFAULT:
|
||||||
drawObjectRefPass2(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
drawObjectPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
|
||||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
|
||||||
drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
|
|
||||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
|
||||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
|
||||||
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
|
||||||
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
|
|
||||||
else if (type == irr_driver->getShader(ES_CAUSTICS))
|
|
||||||
{
|
|
||||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
|
||||||
const float speed = World::getWorld()->getTrack()->getCausticsSpeed();
|
|
||||||
|
|
||||||
float strength = time;
|
|
||||||
strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.001f;
|
|
||||||
|
|
||||||
vector3df wind = irr_driver->getWind() * strength * speed;
|
|
||||||
caustic_dir.X += wind.X;
|
|
||||||
caustic_dir.Y += wind.Z;
|
|
||||||
|
|
||||||
strength = time * 0.56f + sinf(time);
|
|
||||||
strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.001f;
|
|
||||||
|
|
||||||
wind = irr_driver->getWind() * strength * speed;
|
|
||||||
wind.rotateXZBy(cosf(time));
|
|
||||||
caustic_dir2.X += wind.X;
|
|
||||||
caustic_dir2.Y += wind.Z;
|
|
||||||
drawCaustics(mesh, ModelViewProjectionMatrix, caustic_dir, caustic_dir2);
|
|
||||||
}
|
|
||||||
else if (mesh.textures[1] && type != irr_driver->getShader(ES_NORMAL_MAP))
|
|
||||||
drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
|
|
||||||
else if (!mesh.textures[0])
|
|
||||||
drawUntexturedObject(mesh, ModelViewProjectionMatrix);
|
|
||||||
else
|
|
||||||
drawObjectPass2(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
assert(0 && "Wrong shaded material");
|
||||||
assert(0 && "wrong pass");
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,54 +282,131 @@ void STKMeshSceneNode::render()
|
|||||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||||
Box = Mesh->getBoundingBox();
|
Box = Mesh->getBoundingBox();
|
||||||
|
|
||||||
for (u32 i = 0; i<Mesh->getMeshBufferCount(); ++i)
|
setFirstTimeMaterial();
|
||||||
|
|
||||||
|
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
||||||
{
|
{
|
||||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
if (mb)
|
if (!mb)
|
||||||
|
continue;
|
||||||
|
GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
|
||||||
|
{
|
||||||
|
computeMVP(ModelViewProjectionMatrix);
|
||||||
|
computeTIMV(TransposeInverseModelView);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectPass1Shader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||||
|
drawSolidPass1(*GeometricMesh[FPSM_DEFAULT][i], FPSM_DEFAULT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||||
|
drawSolidPass1(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i], FPSM_ALPHA_REF_TEXTURE);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::NormalMapShader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_NORMAL_MAP].size(); i++)
|
||||||
|
drawSolidPass1(*GeometricMesh[FPSM_NORMAL_MAP][i], FPSM_NORMAL_MAP);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::GrassPass1Shader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_GRASS].size(); i++)
|
||||||
|
drawSolidPass1(*GeometricMesh[FPSM_GRASS][i], FPSM_GRASS);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == SOLID_LIT_PASS)
|
||||||
|
{
|
||||||
|
glUseProgram(MeshShader::ObjectPass2Shader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_DEFAULT][i], SM_DEFAULT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectRefPass2Shader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_ALPHA_REF_TEXTURE][i], SM_ALPHA_REF_TEXTURE);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_RIMLIT][i], SM_RIMLIT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::SphereMapShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_SPHEREMAP].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_SPHEREMAP][i], SM_SPHEREMAP);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::SplattingShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_SPLATTING].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_SPLATTING][i], SM_SPLATTING);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::GrassPass2Shader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_GRASS].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_GRASS][i], SM_GRASS);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::ObjectUnlitShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_UNLIT].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_UNLIT][i], SM_UNLIT);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::CausticsShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_CAUSTICS].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_CAUSTICS][i], SM_CAUSTICS);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_DETAILS].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_DETAILS][i], SM_DETAILS);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::UntexturedObjectShader::Program);
|
||||||
|
for (unsigned i = 0; i < ShadedMesh[SM_UNTEXTURED].size(); i++)
|
||||||
|
drawSolidPass2(*ShadedMesh[SM_UNTEXTURED][i], SM_UNTEXTURED);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == SHADOW_PASS)
|
||||||
|
{
|
||||||
|
glUseProgram(MeshShader::ShadowShader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||||
|
drawShadow(*GeometricMesh[FPSM_DEFAULT][i]);
|
||||||
|
|
||||||
|
glUseProgram(MeshShader::RefShadowShader::Program);
|
||||||
|
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||||
|
drawShadowRef(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irr_driver->getPhase() == GLOW_PASS)
|
||||||
|
{
|
||||||
|
glUseProgram(MeshShader::ColorizeShader::Program);
|
||||||
|
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
||||||
{
|
{
|
||||||
TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
if (!mb)
|
||||||
|
|
||||||
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(material.MaterialType);
|
|
||||||
bool transparent = (rnd && rnd->isTransparent());
|
|
||||||
|
|
||||||
if (isTransparentPass != transparent)
|
|
||||||
continue;
|
continue;
|
||||||
if (irr_driver->getPhase() == DISPLACEMENT_PASS)
|
drawGlow(GLmeshes[i]);
|
||||||
{
|
}
|
||||||
initvaostate(GLmeshes[i], material.MaterialType);
|
}
|
||||||
drawDisplace(GLmeshes[i]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!isObject(material.MaterialType))
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
Log::warn("material", "Unhandled (static) material type : %d", material.MaterialType);
|
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// only render transparent buffer if this is the transparent render pass
|
if (irr_driver->getPhase() == TRANSPARENT_PASS)
|
||||||
// and solid only in solid pass
|
{
|
||||||
if (irr_driver->getPhase() == GLOW_PASS)
|
computeMVP(ModelViewProjectionMatrix);
|
||||||
{
|
|
||||||
initvaostate(GLmeshes[i], material.MaterialType);
|
glUseProgram(MeshShader::BubbleShader::Program);
|
||||||
drawGlow(GLmeshes[i]);
|
for (unsigned i = 0; i < TransparentMesh[TM_BUBBLE].size(); i++)
|
||||||
}
|
drawBubble(*TransparentMesh[TM_BUBBLE][i], ModelViewProjectionMatrix);
|
||||||
else if (irr_driver->getPhase() == SHADOW_PASS)
|
|
||||||
{
|
glUseProgram(MeshShader::TransparentShader::Program);
|
||||||
initvaostate(GLmeshes[i], material.MaterialType);
|
for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++)
|
||||||
drawShadow(GLmeshes[i], material.MaterialType);
|
drawTransparentObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix);
|
||||||
}
|
return;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
irr_driver->IncreaseObjectCount();
|
if (irr_driver->getPhase() == DISPLACEMENT_PASS)
|
||||||
initvaostate(GLmeshes[i], material.MaterialType);
|
{
|
||||||
if (transparent)
|
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
||||||
drawTransparent(GLmeshes[i], material.MaterialType);
|
{
|
||||||
else
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
drawSolid(GLmeshes[i], material.MaterialType);
|
if (!mb)
|
||||||
}
|
continue;
|
||||||
|
drawDisplace(GLmeshes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,24 @@
|
|||||||
class STKMeshSceneNode : public irr::scene::CMeshSceneNode
|
class STKMeshSceneNode : public irr::scene::CMeshSceneNode
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
std::vector<GLMesh *> GeometricMesh[FPSM_COUNT];
|
||||||
|
std::vector<GLMesh *> ShadedMesh[SM_COUNT];
|
||||||
|
std::vector<GLMesh *> TransparentMesh[TM_COUNT];
|
||||||
std::vector<GLMesh> GLmeshes;
|
std::vector<GLMesh> GLmeshes;
|
||||||
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix;
|
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
|
||||||
core::vector3df windDir;
|
core::vector3df windDir;
|
||||||
core::vector2df caustic_dir, caustic_dir2;
|
core::vector2df caustic_dir, caustic_dir2;
|
||||||
void drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
void drawSolidPass1(const GLMesh &mesh, GeometricMaterial type);
|
||||||
|
void drawSolidPass2(const GLMesh &mesh, ShadedMaterial type);
|
||||||
void drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
void drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
||||||
|
|
||||||
// Misc passes shaders (glow, displace...)
|
// Misc passes shaders (glow, displace...)
|
||||||
void drawGlow(const GLMesh &mesh);
|
void drawGlow(const GLMesh &mesh);
|
||||||
void drawDisplace(const GLMesh &mesh);
|
void drawDisplace(const GLMesh &mesh);
|
||||||
void drawShadow(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
|
||||||
void createGLMeshes();
|
void createGLMeshes();
|
||||||
void cleanGLMeshes();
|
void cleanGLMeshes();
|
||||||
|
void setFirstTimeMaterial();
|
||||||
|
bool isMaterialInitialized;
|
||||||
public:
|
public:
|
||||||
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||||
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
|
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
|
||||||
@ -30,4 +35,4 @@ public:
|
|||||||
~STKMeshSceneNode();
|
~STKMeshSceneNode();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user