mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 14:53:01 +02:00
Working on texture compatibility with Shadertoy
This commit is contained in:
parent
83c9ebf06c
commit
c8aea67505
2 changed files with 29 additions and 4 deletions
|
@ -343,9 +343,22 @@ bool Texture::assignStoredMipFace(uint16 level, const Element& format, Size size
|
|||
}
|
||||
|
||||
uint16 Texture::autoGenerateMips(uint16 maxMip) {
|
||||
bool changed = false;
|
||||
if (!_autoGenerateMips) {
|
||||
changed = true;
|
||||
_autoGenerateMips = true;
|
||||
_maxMip = std::min((uint16) (evalNumMips() - 1), maxMip);
|
||||
}
|
||||
|
||||
auto newMaxMip = std::min((uint16)(evalNumMips() - 1), maxMip);
|
||||
if (newMaxMip != _maxMip) {
|
||||
changed = true;
|
||||
_maxMip = newMaxMip;;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
_stamp++;
|
||||
}
|
||||
|
||||
return _maxMip;
|
||||
}
|
||||
|
||||
|
|
|
@ -223,9 +223,21 @@ void Procedural::prepare(gpu::Batch& batch, const glm::vec3& position, const glm
|
|||
lambda(batch);
|
||||
}
|
||||
|
||||
static gpu::Sampler sampler;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
gpu::Sampler::Desc desc;
|
||||
desc._filter = gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR;
|
||||
});
|
||||
|
||||
for (size_t i = 0; i < MAX_PROCEDURAL_TEXTURE_CHANNELS; ++i) {
|
||||
if (_channels[i] && _channels[i]->isLoaded()) {
|
||||
batch.setResourceTexture(i, _channels[i]->getGPUTexture());
|
||||
auto gpuTexture = _channels[i]->getGPUTexture();
|
||||
if (gpuTexture) {
|
||||
gpuTexture->setSampler(sampler);
|
||||
gpuTexture->autoGenerateMips(-1);
|
||||
}
|
||||
batch.setResourceTexture(i, gpuTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue