mirror of
https://github.com/lubosz/overte.git
synced 2025-04-06 21:22:44 +02:00
Working on cubemap mip bug
This commit is contained in:
parent
ffbddd2d0f
commit
fa23fa7b2d
5 changed files with 21 additions and 19 deletions
|
@ -31,6 +31,7 @@ public:
|
|||
using Parent = GLTexture;
|
||||
static GLuint allocate(const Texture& texture);
|
||||
static const uint32_t DEFAULT_PAGE_DIMENSION = 128;
|
||||
static const uint32_t DEFAULT_MAX_SPARSE_LEVEL = 0xFFFF;
|
||||
public:
|
||||
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable);
|
||||
~GL45Texture();
|
||||
|
@ -40,7 +41,7 @@ public:
|
|||
struct SparseInfo {
|
||||
GL45Texture& _texture;
|
||||
uvec3 _pageDimensions { DEFAULT_PAGE_DIMENSION };
|
||||
GLuint _maxSparseLevel { 0 };
|
||||
GLuint _maxSparseLevel { DEFAULT_MAX_SPARSE_LEVEL };
|
||||
uint32_t _maxPages { 0 };
|
||||
uint32_t _pageBytes { 0 };
|
||||
bool _sparse { false };
|
||||
|
|
|
@ -98,11 +98,6 @@ void SparseInfo::maybeMakeSparse() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (GL_TEXTURE_CUBE_MAP == _texture._target) {
|
||||
qCDebug(gpugl45logging) << "Don't enable sparse texture for cubemaps " << _texture._gpuObject.source().c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
const uvec3 dimensions = _texture._gpuObject.getDimensions();
|
||||
auto allowedPageDimensions = getPageDimensionsForFormat(_texture._target, _texture._internalFormat);
|
||||
// In order to enable sparse the texture size must be an integer multiple of the page size
|
||||
|
@ -132,11 +127,6 @@ void SparseInfo::update() {
|
|||
return;
|
||||
}
|
||||
glGetTextureParameterIuiv(_texture._id, GL_NUM_SPARSE_LEVELS_ARB, &_maxSparseLevel);
|
||||
// For some reason the long mip tail isn't working properly with cubemaps unless
|
||||
// I extend one more level
|
||||
if (GL_TEXTURE_CUBE_MAP == _texture._target) {
|
||||
++_maxSparseLevel;
|
||||
}
|
||||
_pageBytes = _texture._gpuObject.getTexelFormat().getSize();
|
||||
_pageBytes *= _pageDimensions.x * _pageDimensions.y * _pageDimensions.z;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void main(void) {
|
|||
|
||||
// blend is only set if there is a cubemap
|
||||
if (skybox.color.a > 0.0) {
|
||||
color = texture(cubeMap, coord).rgb;
|
||||
color = textureLod(cubeMap, coord, 0).rgb;
|
||||
if (skybox.color.a < 1.0) {
|
||||
color *= skybox.color.rgb;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,10 @@ protected:
|
|||
|
||||
public:
|
||||
glm::quat getOrientation() const {
|
||||
return glm::angleAxis(yaw, Vectors::UP);
|
||||
return glm::angleAxis(yawPitch.x, Vectors::UP) * glm::angleAxis(yawPitch.y, Vectors::RIGHT);
|
||||
}
|
||||
float yaw { 0 };
|
||||
|
||||
vec2 yawPitch { 0 };
|
||||
glm::vec3 position;
|
||||
float rotationSpeed { 1.0f };
|
||||
float movementSpeed { 1.0f };
|
||||
|
@ -76,7 +77,12 @@ public:
|
|||
};
|
||||
|
||||
void rotate(const float delta) {
|
||||
yaw += delta;
|
||||
yawPitch.x += delta;
|
||||
updateViewMatrix();
|
||||
}
|
||||
|
||||
void rotate(const glm::vec2& delta) {
|
||||
yawPitch += delta;
|
||||
updateViewMatrix();
|
||||
}
|
||||
|
||||
|
@ -84,7 +90,11 @@ public:
|
|||
glm::vec3 f = rotation * Vectors::UNIT_NEG_Z;
|
||||
f.y = 0;
|
||||
f = glm::normalize(f);
|
||||
yaw = angleBetween(Vectors::UNIT_NEG_Z, f);
|
||||
yawPitch.x = angleBetween(Vectors::UNIT_NEG_Z, f);
|
||||
f = rotation * Vectors::UNIT_NEG_Z;
|
||||
f.x = 0;
|
||||
f = glm::normalize(f);
|
||||
yawPitch.y = angleBetween(Vectors::UNIT_NEG_Z, f);
|
||||
updateViewMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,8 @@ public:
|
|||
if (buttons & Qt::RightButton) {
|
||||
dolly(delta.y * 0.01f);
|
||||
} else if (buttons & Qt::LeftButton) {
|
||||
rotate(delta.x * -0.01f);
|
||||
//rotate(delta.x * -0.01f);
|
||||
rotate(delta * -0.01f);
|
||||
} else if (buttons & Qt::MiddleButton) {
|
||||
delta.y *= -1.0f;
|
||||
translate(delta * -0.01f);
|
||||
|
@ -367,7 +368,7 @@ public:
|
|||
|
||||
sortedHighFrames.sort();
|
||||
for (const auto& t : sortedHighFrames) {
|
||||
qDebug() << "Long frame " << t;
|
||||
//qDebug() << "Long frame " << t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -990,7 +991,7 @@ private:
|
|||
}
|
||||
|
||||
void resetPosition() {
|
||||
_camera.yaw = 0;
|
||||
_camera.yawPitch = vec3(0);
|
||||
_camera.setPosition(vec3());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue