Some fixes
This commit is contained in:
parent
d5e30ee41e
commit
964baad705
@ -20,8 +20,8 @@ void main()
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 6; i++) {
|
||||
sum += texture(tex, vec2(X - i * pixel.x, Y)) * g0;
|
||||
sum += texture(tex, vec2(X + i * pixel.x, Y)) * g0;
|
||||
sum += texture(tex, vec2(X - float(i) * pixel.x, Y)) * g0;
|
||||
sum += texture(tex, vec2(X + float(i) * pixel.x, Y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ void main()
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 6; i++) {
|
||||
sum += texture(tex, vec2(X, Y - i * pixel.y)) * g0;
|
||||
sum += texture(tex, vec2(X, Y + i * pixel.y)) * g0;
|
||||
sum += texture(tex, vec2(X, Y - float(i) * pixel.y)) * g0;
|
||||
sum += texture(tex, vec2(X, Y + float(i) * pixel.y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
|
@ -28,14 +28,14 @@ void main()
|
||||
vec3 closestpoint = - eyedir * (dot(-eyedir, light_pos) - radius);
|
||||
if (closestpoint.z < 1.) closestpoint = vec3(0.);
|
||||
|
||||
float stepsize = length(farthestpoint - closestpoint) / 16;
|
||||
float stepsize = length(farthestpoint - closestpoint) / 16.;
|
||||
vec3 fog = vec3(0.);
|
||||
vec3 xpos = farthestpoint;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
float d = distance(light_pos, xpos);
|
||||
float l = (16 - i) * stepsize;
|
||||
float l = (16. - float(i)) * stepsize;
|
||||
float att = energy * 20. / (1. + d * d);
|
||||
att *= max((radius - d) / radius, 0.);
|
||||
fog += density * light_col * att * exp(- density * d) * exp(- density * l) * stepsize;
|
||||
|
@ -1,6 +1,6 @@
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix)
|
||||
{
|
||||
vec4 pos = 2.0 * vec4(uvDepth, 1.0) - 1.0f;
|
||||
vec4 pos = 2.0 * vec4(uvDepth, 1.0) - 1.0;
|
||||
pos.xy *= vec2(InverseProjectionMatrix[0][0], InverseProjectionMatrix[1][1]);
|
||||
pos.zw = vec2(pos.z * InverseProjectionMatrix[2][2] + pos.w, pos.z * InverseProjectionMatrix[2][3] + pos.w);
|
||||
pos /= pos.w;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "graphics/shaders.hpp"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
using namespace irr;
|
||||
@ -56,7 +56,7 @@ public:
|
||||
}; // SkyboxShader
|
||||
|
||||
|
||||
class SpecularIBLGenerator : public TextureShader<SpecularIBLGenerator, 1,
|
||||
class SpecularIBLGenerator : public TextureShader<SpecularIBLGenerator, 1,
|
||||
core::matrix4, float >
|
||||
{
|
||||
public:
|
||||
@ -84,7 +84,7 @@ namespace {
|
||||
new_img[4 * (stride * new_i + new_j) + 2] = old_img[4 * (stride * old_i + old_j) + 2];
|
||||
new_img[4 * (stride * new_i + new_j) + 3] = old_img[4 * (stride * old_i + old_j) + 3];
|
||||
} // swapPixels
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html
|
||||
/** Returns the index-th pair from Hammersley set of pseudo random set.
|
||||
@ -97,7 +97,7 @@ namespace {
|
||||
float InvertedBinaryRepresentation = 0.;
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
InvertedBinaryRepresentation += ((index >> i) & 0x1)
|
||||
InvertedBinaryRepresentation += ((index >> i) & 0x1)
|
||||
* powf(.5, (float) (i + 1.));
|
||||
}
|
||||
return std::make_pair(float(index) / float(samples),
|
||||
@ -108,7 +108,7 @@ namespace {
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Returns a pseudo random (theta, phi) generated from a probability density
|
||||
* function modeled after Phong function.
|
||||
* \param a pseudo random float pair from a uniform density function between
|
||||
* \param a pseudo random float pair from a uniform density function between
|
||||
* 0 and 1.
|
||||
* \param exponent from the Phong formula.
|
||||
*/
|
||||
@ -120,8 +120,8 @@ namespace {
|
||||
} // getImportanceSamplingPhong
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
static core::matrix4 getPermutationMatrix(size_t indexX, float valX,
|
||||
size_t indexY, float valY,
|
||||
static core::matrix4 getPermutationMatrix(size_t indexX, float valX,
|
||||
size_t indexY, float valY,
|
||||
size_t indexZ, float valZ)
|
||||
{
|
||||
core::matrix4 result_mat;
|
||||
@ -135,7 +135,7 @@ namespace {
|
||||
M[8 + indexZ] = valZ;
|
||||
return result_mat;
|
||||
} // getPermutationMatrix
|
||||
|
||||
|
||||
} //namespace
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -224,6 +224,9 @@ void Skybox::generateSpecularCubemap()
|
||||
|
||||
if (!CVS->isDefferedEnabled())
|
||||
return;
|
||||
#if defined(USE_GLES2)
|
||||
return;
|
||||
#endif
|
||||
|
||||
GLuint fbo;
|
||||
glGenFramebuffers(1, &fbo);
|
||||
@ -258,7 +261,7 @@ void Skybox::generateSpecularCubemap()
|
||||
float *tmp = new float[2048];
|
||||
for (unsigned i = 0; i < 1024; i++)
|
||||
{
|
||||
std::pair<float, float> sample =
|
||||
std::pair<float, float> sample =
|
||||
getImportanceSamplingPhong(getHammersleySequence(i, 1024),
|
||||
roughness);
|
||||
tmp[2 * i] = sample.first;
|
||||
@ -266,12 +269,12 @@ void Skybox::generateSpecularCubemap()
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
glActiveTexture(GL_TEXTURE0 +
|
||||
glActiveTexture(GL_TEXTURE0 +
|
||||
SpecularIBLGenerator::getInstance()->m_tu_samples);
|
||||
GLuint sampleTex, sampleBuffer;
|
||||
glGenBuffers(1, &sampleBuffer);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, sampleBuffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, 2048 * sizeof(float), tmp,
|
||||
glBufferData(GL_TEXTURE_BUFFER, 2048 * sizeof(float), tmp,
|
||||
GL_STATIC_DRAW);
|
||||
glGenTextures(1, &sampleTex);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, sampleTex);
|
||||
@ -281,7 +284,7 @@ void Skybox::generateSpecularCubemap()
|
||||
for (unsigned face = 0; face < 6; face++)
|
||||
{
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
|
||||
m_specular_probe, level);
|
||||
//~ GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
@ -322,7 +325,7 @@ Out of legacy the sequence of textures maps to:
|
||||
Skybox::Skybox(const std::vector<video::ITexture *> &skybox_textures)
|
||||
{
|
||||
m_skybox_textures = skybox_textures;
|
||||
|
||||
|
||||
#if !defined(ANDROID) && !defined(USE_GLES2)
|
||||
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||
#endif
|
||||
@ -337,7 +340,7 @@ Skybox::Skybox(const std::vector<video::ITexture *> &skybox_textures)
|
||||
Skybox::~Skybox()
|
||||
{
|
||||
glDeleteTextures(1, &m_cube_map);
|
||||
glDeleteTextures(1, &m_specular_probe);
|
||||
glDeleteTextures(1, &m_specular_probe);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user