mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 08:03:50 +02:00
try to fix amd deferred bug
This commit is contained in:
parent
3daa40087e
commit
903984f427
3 changed files with 43 additions and 26 deletions
|
@ -21,35 +21,46 @@ using namespace render::entities;
|
||||||
|
|
||||||
static uint8_t CUSTOM_PIPELINE_NUMBER = 0;
|
static uint8_t CUSTOM_PIPELINE_NUMBER = 0;
|
||||||
static gpu::Stream::FormatPointer _vertexFormat;
|
static gpu::Stream::FormatPointer _vertexFormat;
|
||||||
static std::map<std::tuple<bool, bool>, gpu::PipelinePointer> _pipelines;
|
static std::map<std::tuple<bool, bool, bool>, gpu::PipelinePointer> _pipelines;
|
||||||
|
|
||||||
static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) {
|
static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) {
|
||||||
// FIXME: custom pipelines like this don't handle shadows or renderLayers correctly
|
// FIXME: custom pipelines like this don't handle shadows or renderLayers correctly
|
||||||
|
|
||||||
if (_pipelines.empty()) {
|
if (_pipelines.empty()) {
|
||||||
for (size_t i = 0; i < 4; i++) {
|
using namespace shader::entities_renderer::program;
|
||||||
bool transparent = (i % 2 == 0);
|
|
||||||
bool wireframe = (i / 2) == 0;
|
|
||||||
|
|
||||||
auto state = std::make_shared<gpu::State>();
|
// forward, translucent
|
||||||
state->setCullMode(gpu::State::CULL_BACK);
|
static const std::vector<std::tuple<bool, bool, uint32_t>> keys = {
|
||||||
|
std::make_tuple(false, false, textured_particle),
|
||||||
|
std::make_tuple(true, false, textured_particle_forward),
|
||||||
|
std::make_tuple(false, true, textured_particle_translucent),
|
||||||
|
std::make_tuple(true, true, textured_particle_forward)
|
||||||
|
};
|
||||||
|
|
||||||
if (wireframe) {
|
for (auto& key : keys) {
|
||||||
state->setFillMode(gpu::State::FILL_LINE);
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
bool transparent = std::get<1>(key);
|
||||||
|
bool wireframe = i == 0;
|
||||||
|
|
||||||
|
auto state = std::make_shared<gpu::State>();
|
||||||
|
state->setCullMode(gpu::State::CULL_BACK);
|
||||||
|
|
||||||
|
if (wireframe) {
|
||||||
|
state->setFillMode(gpu::State::FILL_LINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
state->setDepthTest(true, !transparent, gpu::LESS_EQUAL);
|
||||||
|
state->setBlendFunction(transparent, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE,
|
||||||
|
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||||
|
transparent ? PrepareStencil::testMask(*state) : PrepareStencil::testMaskDrawShape(*state);
|
||||||
|
|
||||||
|
auto program = gpu::Shader::createProgram(std::get<2>(key));
|
||||||
|
_pipelines[std::make_tuple(std::get<0>(key), transparent, wireframe)] = gpu::Pipeline::create(program, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
state->setDepthTest(true, !transparent, gpu::LESS_EQUAL);
|
|
||||||
state->setBlendFunction(transparent, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE,
|
|
||||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
|
||||||
transparent ? PrepareStencil::testMask(*state) : PrepareStencil::testMaskDrawShape(*state);
|
|
||||||
|
|
||||||
auto program = gpu::Shader::createProgram(transparent ? shader::entities_renderer::program::textured_particle_translucent :
|
|
||||||
shader::entities_renderer::program::textured_particle);
|
|
||||||
_pipelines[std::make_tuple(transparent, wireframe)] = gpu::Pipeline::create(program, state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_shared<render::ShapePipeline>(_pipelines[std::make_tuple(key.isTranslucent(), key.isWireframe())], nullptr, nullptr, nullptr);
|
return std::make_shared<render::ShapePipeline>(_pipelines[std::make_tuple(args->_renderMethod == Args::RenderMethod::FORWARD, key.isTranslucent(), key.isWireframe())], nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GpuParticle {
|
struct GpuParticle {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
DEFINES translucent:f
|
DEFINES translucent:f/forward:f
|
|
@ -15,17 +15,23 @@ LAYOUT(binding=0) uniform sampler2D colorMap;
|
||||||
layout(location=0) in vec4 varColor;
|
layout(location=0) in vec4 varColor;
|
||||||
layout(location=1) in vec2 varTexcoord;
|
layout(location=1) in vec2 varTexcoord;
|
||||||
|
|
||||||
layout(location=0) out vec4 outFragColor;
|
<@if not HIFI_USE_FORWARD@>
|
||||||
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
<@else@>
|
||||||
|
layout(location=0) out vec4 _fragColor0;
|
||||||
|
<@endif@>
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 albedo = texture(colorMap, varTexcoord.xy) * varColor;
|
vec4 albedo = texture(colorMap, varTexcoord.xy) * varColor;
|
||||||
|
|
||||||
|
<@if not HIFI_USE_FORWARD@>
|
||||||
|
vec3 NORMAL = vec3(1.0, 0.0, 0.0);
|
||||||
<@if not HIFI_USE_TRANSLUCENT@>
|
<@if not HIFI_USE_TRANSLUCENT@>
|
||||||
// to reduce texel flickering for floating point error we discard when alpha is "almost one"
|
packDeferredFragmentUnlit(NORMAL, albedo.a, albedo.rgb);
|
||||||
if (albedo.a < 0.999999) {
|
<@else@>
|
||||||
discard;
|
packDeferredFragmentTranslucent(NORMAL, albedo.a, albedo.rgb, DEFAULT_ROUGHNESS);
|
||||||
}
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
<@else@>
|
||||||
outFragColor = albedo;
|
_fragColor0 = albedo;
|
||||||
|
<@endif@>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue