opengl related fixes that almost are done (some props aren't rendering because of alpha shitcannery)
This commit is contained in:
parent
c3e337bb87
commit
a2636e834c
@ -1,9 +1,9 @@
|
||||
{
|
||||
"engine": {
|
||||
"scenes": {
|
||||
"start": "StartMenu",
|
||||
"start": "SourceEngine",
|
||||
"lights": { "enabled": true,
|
||||
"lightmaps": true,
|
||||
"lightmaps": false,
|
||||
"max": 32,
|
||||
"shadows": {
|
||||
"enabled": false,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "Object",
|
||||
"name": "Player: Model",
|
||||
"ignore": false,
|
||||
"ignore": true,
|
||||
"import": "/model.json",
|
||||
"assets": [
|
||||
// "/player/pbear.glb"
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
{
|
||||
"import": "./base_sourceengine.json",
|
||||
"assets": [
|
||||
{ "filename": "./maps/mcdonalds-mds.bsp" }
|
||||
// { "filename": "./maps/mcdonalds-mds/graph.json" }
|
||||
// { "filename": "./maps/mcdonalds-mds.bsp" }
|
||||
{ "filename": "./maps/mcdonalds-mds/graph.json" }
|
||||
// ,{ "filename": "ent://burger.json", "delay": 1 }
|
||||
// ,{ "filename": "ent://craeture.json", "delay": 2 }
|
||||
]
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
{
|
||||
// "import": "./rp_downtown_v2.json"
|
||||
// "import": "./ss2_medsci1.json"
|
||||
// "import": "./mds_mcdonalds.json"
|
||||
"import": "./cs_office.json"
|
||||
"import": "./mds_mcdonalds.json"
|
||||
// "import": "./cs_office.json"
|
||||
// "import": "./de_dust2.json"
|
||||
// "import": "./gm_construct.json"
|
||||
}
|
||||
@ -22,7 +22,7 @@ namespace pod {
|
||||
float factorMetallic = 0.0f;
|
||||
float factorRoughness = 1.0f;
|
||||
float factorOcclusion = 1.0f;
|
||||
float factorAlphaCutoff = 1.0f;
|
||||
float factorAlphaCutoff = 0.0f;
|
||||
|
||||
int32_t indexAlbedo = -1;
|
||||
int32_t indexNormal = -1;
|
||||
|
||||
@ -69,7 +69,7 @@ namespace ext {
|
||||
} textures;
|
||||
|
||||
struct {
|
||||
uint8_t modeAlpha{};
|
||||
int8_t modeAlpha{};
|
||||
float alphaCutoff = 0.001f;
|
||||
} blend;
|
||||
|
||||
|
||||
@ -97,30 +97,30 @@ namespace ext {
|
||||
}
|
||||
namespace PrimitiveTopology {
|
||||
typedef GLenum type_t;
|
||||
static const type_t POINT_LIST = GLenumerator(VK_PRIMITIVE_TOPOLOGY_POINT_LIST);
|
||||
static const type_t LINE_LIST = GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_LIST);
|
||||
static const type_t LINE_STRIP = GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_STRIP);
|
||||
static const type_t TRIANGLE_LIST = GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
||||
static const type_t TRIANGLE_STRIP = GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP);
|
||||
static const type_t TRIANGLE_FAN = GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN);
|
||||
static const type_t LINE_LIST_WITH_ADJACENCY = GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY);
|
||||
static const type_t LINE_STRIP_WITH_ADJACENCY = GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY);
|
||||
static const type_t TRIANGLE_LIST_WITH_ADJACENCY = GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY);
|
||||
static const type_t TRIANGLE_STRIP_WITH_ADJACENCY = GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY);
|
||||
static const type_t PATCH_LIST = GLenumerator(VK_PRIMITIVE_TOPOLOGY_PATCH_LIST);
|
||||
static const type_t POINT_LIST = 0; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_POINT_LIST);
|
||||
static const type_t LINE_LIST = 1; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_LIST);
|
||||
static const type_t LINE_STRIP = 2; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_STRIP);
|
||||
static const type_t TRIANGLE_LIST = 3; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
||||
static const type_t TRIANGLE_STRIP = 4; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP);
|
||||
static const type_t TRIANGLE_FAN = 5; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN);
|
||||
static const type_t LINE_LIST_WITH_ADJACENCY = 6; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY);
|
||||
static const type_t LINE_STRIP_WITH_ADJACENCY = 7; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY);
|
||||
static const type_t TRIANGLE_LIST_WITH_ADJACENCY = 8; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY);
|
||||
static const type_t TRIANGLE_STRIP_WITH_ADJACENCY = 9; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY);
|
||||
static const type_t PATCH_LIST = 10; // GLenumerator(VK_PRIMITIVE_TOPOLOGY_PATCH_LIST);
|
||||
}
|
||||
namespace PolygonMode {
|
||||
typedef GLenum type_t;
|
||||
static const type_t FILL = GLenumerator(VK_POLYGON_MODE_FILL);
|
||||
static const type_t LINE = GLenumerator(VK_POLYGON_MODE_LINE);
|
||||
static const type_t POINT = GLenumerator(VK_POLYGON_MODE_POINT);
|
||||
static const type_t FILL = 0; // GLenumerator(VK_POLYGON_MODE_FILL);
|
||||
static const type_t LINE = 1; // GLenumerator(VK_POLYGON_MODE_LINE);
|
||||
static const type_t POINT = 2; // GLenumerator(VK_POLYGON_MODE_POINT);
|
||||
}
|
||||
namespace AddressMode {
|
||||
typedef GLenum type_t;
|
||||
static const type_t CLAMP_TO_EDGE = GLenumerator(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
|
||||
static const type_t CLAMP_TO_BORDER = GLenumerator(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER);
|
||||
static const type_t MIRRORED_REPEAT = GLenumerator(VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT);
|
||||
static const type_t REPEAT = GLenumerator(VK_SAMPLER_ADDRESS_MODE_REPEAT);
|
||||
static const type_t CLAMP_TO_EDGE = 0; // GLenumerator(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
|
||||
static const type_t CLAMP_TO_BORDER = 1; // GLenumerator(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER);
|
||||
static const type_t MIRRORED_REPEAT = 2; // GLenumerator(VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT);
|
||||
static const type_t REPEAT = 3; // GLenumerator(VK_SAMPLER_ADDRESS_MODE_REPEAT);
|
||||
}
|
||||
namespace Filter {
|
||||
typedef GLenum type_t;
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
#include <uf/ext/vall_e/vall_e.h>
|
||||
#include <uf/ext/valve/vpk.h>
|
||||
|
||||
#if UF_USE_OPENVR
|
||||
#if UF_USE_OPENVR && UF_USE_VULKAN
|
||||
#include <uf/ext/vulkan/rendermodes/vr.h>
|
||||
#endif
|
||||
|
||||
@ -664,7 +664,7 @@ void UF_API uf::initialize() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UF_USE_OPENVR
|
||||
#if UF_USE_OPENVR && UF_USE_VULKAN
|
||||
{
|
||||
auto& configVrJson = uf::config["engine"]["ext"]["vr"];
|
||||
ext::openvr::enabled = configVrJson["enable"].as( ext::openvr::enabled );
|
||||
@ -674,7 +674,7 @@ void UF_API uf::initialize() {
|
||||
}
|
||||
|
||||
// could probably live alongside gui/deferred in the scene
|
||||
static auto* vrRenderMode = new ext::vulkan::VrRenderMode;
|
||||
static auto* vrRenderMode = new uf::renderer::VrRenderMode;
|
||||
uf::renderer::addRenderMode(vrRenderMode, "VR");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -834,9 +834,17 @@ void uf::graph::process( pod::Graph& graph ) {
|
||||
UF_DEBUG_TIMER_MULTITRACE("Parsing lightmaps");
|
||||
// cringe hack for VBSP loader
|
||||
if ( storage.textures.map.count("lightmap_atlas") > 0 ) {
|
||||
graphMetadataJson["lights"]["lightmap"] = true;
|
||||
graphMetadataJson["baking"]["enabled"] = false;
|
||||
textureDescriptors["lightmap_atlas"].srgb = false;
|
||||
|
||||
if ( !graphMetadataJson["lights"]["lightmap"].as<bool>() ) {
|
||||
for ( auto& name : graph.primitives ) {
|
||||
auto& primitives = storage.primitives[name];
|
||||
for ( auto& primitive : primitives ) {
|
||||
primitive.instance.lightmapID = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
constexpr const char* UF_GRAPH_DEFAULT_LIGHTMAP = "./lightmap.%i.png";
|
||||
uf::stl::unordered_map<size_t, uf::stl::string> filenames;
|
||||
@ -1518,6 +1526,7 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent )
|
||||
storage.objects[objectKeyName] = pod::Instance::Object{
|
||||
.model = model,
|
||||
.previous = model,
|
||||
.color = {1, 1, 1, 1},
|
||||
};
|
||||
|
||||
if ( node.skin >= 0 && node.skin < graph.skins.size() ) {
|
||||
|
||||
@ -281,10 +281,11 @@ void ext::opengl::CommandBuffer::drawIndexed( const ext::opengl::CommandBuffer::
|
||||
pod::Matrix4f mat = (*drawInfo.matrices.projection) * (*drawInfo.matrices.view) * (*drawInfo.matrices.model);
|
||||
|
||||
bool visible = inside( instance, mat );
|
||||
drawCommand.instances = visible ? 1 : 0;
|
||||
if ( !visible ) ++::culled;
|
||||
if ( !visible ) {
|
||||
++::culled;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ( drawCommand.instances == 0 ) return;
|
||||
}
|
||||
|
||||
GL_ERROR_CHECK(glMatrixMode(GL_MODELVIEW));
|
||||
@ -327,12 +328,9 @@ void ext::opengl::CommandBuffer::drawIndexed( const ext::opengl::CommandBuffer::
|
||||
GL_ERROR_CHECK(glDisable(GL_DEPTH_TEST));
|
||||
}
|
||||
GL_ERROR_CHECK(glDepthMask(drawInfo.descriptor.depth.write ? GL_TRUE : GL_FALSE));
|
||||
|
||||
uf::stl::vector<pod::Vector4f> colors;
|
||||
|
||||
// CPU-buffer based command dispatching
|
||||
if ( drawInfo.attributes.normal.pointer ) GL_ERROR_CHECK(glEnableClientState(GL_NORMAL_ARRAY));
|
||||
if ( drawInfo.attributes.color.pointer || drawInfo.color.enabled ) GL_ERROR_CHECK(glEnableClientState(GL_COLOR_ARRAY));
|
||||
GL_ERROR_CHECK(glEnableClientState(GL_VERTEX_ARRAY));
|
||||
|
||||
GLenum vertexType = GL_FLOAT;
|
||||
@ -452,16 +450,17 @@ void ext::opengl::CommandBuffer::drawIndexed( const ext::opengl::CommandBuffer::
|
||||
// prioritize uniform color for now
|
||||
if ( drawInfo.color.enabled ) {
|
||||
const auto& color = drawInfo.color.pointer ? *drawInfo.color.pointer : drawInfo.color.value;
|
||||
colors = uf::stl::vector<pod::Vector4f>( drawInfo.descriptor.inputs.vertex.count, color );
|
||||
GL_ERROR_CHECK(glColorPointer(4, GL_FLOAT, sizeof(pod::Vector4f), colors.data()));
|
||||
// GL_ERROR_CHECK(glColor4f( color[0], color[1], color[2], color[3] ));
|
||||
GL_ERROR_CHECK(glColor4f( color[0], color[1], color[2], color[3] ));
|
||||
} else if ( drawInfo.attributes.color.pointer ) {
|
||||
GLenum colorType = GL_UNSIGNED_BYTE;
|
||||
switch ( drawInfo.attributes.color.descriptor.size / drawInfo.attributes.color.descriptor.components ) {
|
||||
case sizeof(uint8_t): colorType = GL_UNSIGNED_BYTE; break;
|
||||
case sizeof(float): colorType = GL_FLOAT; break;
|
||||
}
|
||||
GL_ERROR_CHECK(glEnableClientState(GL_COLOR_ARRAY));
|
||||
GL_ERROR_CHECK(glColorPointer(drawInfo.attributes.color.descriptor.components, colorType, drawInfo.attributes.color.stride, colorPtr));
|
||||
} else {
|
||||
GL_ERROR_CHECK(glColor4f( 1, 1, 1, 1 ));
|
||||
}
|
||||
|
||||
if ( drawInfo.textures.primary.image && drawInfo.attributes.uv.pointer ) {
|
||||
@ -493,17 +492,25 @@ void ext::opengl::CommandBuffer::drawIndexed( const ext::opengl::CommandBuffer::
|
||||
GL_ERROR_CHECK(glVertexPointer(3, vertexType, vertexStride, vertexPtr));
|
||||
}
|
||||
|
||||
GLenum mode = GL_TRIANGLES;
|
||||
if ( drawInfo.descriptor.fill == uf::renderer::enums::PolygonMode::LINE ) {
|
||||
mode = GL_LINES;
|
||||
glLineWidth(drawInfo.descriptor.lineWidth);
|
||||
} else {
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
|
||||
if ( drawInfo.descriptor.inputs.index.count ) {
|
||||
GL_ERROR_CHECK(glDrawElements(GL_TRIANGLES, drawInfo.descriptor.inputs.index.count, indicesType, (static_cast<uint8_t*>(drawInfo.attributes.index.pointer) + drawInfo.attributes.index.stride * drawInfo.descriptor.inputs.index.first)));
|
||||
GL_ERROR_CHECK(glDrawElements(mode, drawInfo.descriptor.inputs.index.count, indicesType, (static_cast<uint8_t*>(drawInfo.attributes.index.pointer) + drawInfo.attributes.index.stride * drawInfo.descriptor.inputs.index.first)));
|
||||
} else {
|
||||
#if 0 && UF_ENV_DREAMCAST
|
||||
// GLdc has a "regression" where glDrawArrays does not work
|
||||
// everything should be using indices anyways so this path shouldn't really ever be taken
|
||||
uf::stl::vector<uint16_t> indices(drawInfo.descriptor.inputs.vertex.count);
|
||||
for ( auto i = 0; i < drawInfo.descriptor.inputs.vertex.count; ++i ) indices[i] = i;
|
||||
GL_ERROR_CHECK(glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_SHORT, indices.data()));
|
||||
GL_ERROR_CHECK(glDrawElements(mode, indices.size(), GL_UNSIGNED_SHORT, indices.data()));
|
||||
#else
|
||||
GL_ERROR_CHECK(glDrawArrays(GL_TRIANGLES, drawInfo.descriptor.inputs.vertex.first, drawInfo.descriptor.inputs.vertex.count));
|
||||
GL_ERROR_CHECK(glDrawArrays(mode, drawInfo.descriptor.inputs.vertex.first, drawInfo.descriptor.inputs.vertex.count));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -417,7 +417,7 @@ void ext::opengl::Graphic::record( CommandBuffer& commandBuffer, const GraphicDe
|
||||
|
||||
drawCommandInfoBase.color.pointer = &uniforms->color;
|
||||
drawCommandInfoBase.color.value = uniforms->color;
|
||||
drawCommandInfoBase.color.enabled = true; // drawCommandInfoBase.color.value != pod::Vector4f{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
drawCommandInfoBase.color.enabled = drawCommandInfoBase.color.value != pod::Vector4f{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
}
|
||||
|
||||
struct {
|
||||
@ -497,9 +497,13 @@ void ext::opengl::Graphic::record( CommandBuffer& commandBuffer, const GraphicDe
|
||||
drawCommandInfo.blend.modeAlpha = material.modeAlpha;
|
||||
drawCommandInfo.blend.alphaCutoff = material.factorAlphaCutoff;
|
||||
|
||||
drawCommandInfo.color.value = object.color * material.colorBase;
|
||||
drawCommandInfo.color.value = object.color * material.colorBase; // to-do: blend properly
|
||||
drawCommandInfo.color.enabled = drawCommandInfo.color.value != pod::Vector4f{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
if ( drawCommandInfo.color.value.w == 0.0f ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 0 <= textureID ) {
|
||||
auto texture2DID = textures[textureID].index;
|
||||
drawCommandInfo.textures.primary = this->material.textures.at(texture2DID).descriptor;
|
||||
@ -510,8 +514,8 @@ void ext::opengl::Graphic::record( CommandBuffer& commandBuffer, const GraphicDe
|
||||
drawCommandInfo.textures.secondary = this->material.textures.at(texture2DID).descriptor;
|
||||
}
|
||||
switch ( drawCommandInfo.blend.modeAlpha ) {
|
||||
case 0: drawCommandInfos.opaques.emplace_back(drawCommandInfo); break;
|
||||
default: drawCommandInfos.translucents.emplace_back(drawCommandInfo); break;
|
||||
case pod::Material::AlphaMode::BLEND: drawCommandInfos.translucents.emplace_back(drawCommandInfo); break;
|
||||
default: drawCommandInfos.opaques.emplace_back(drawCommandInfo); break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -34,6 +34,7 @@ size_t impl::addMaterial( pod::Graph& graph, const uf::stl::string& name, int32_
|
||||
material.factorMetallic = 0.0f;
|
||||
material.factorRoughness = 1.0f;
|
||||
material.factorOcclusion = 1.0f;
|
||||
material.factorAlphaCutoff = 0.0f;
|
||||
material.indexNormal = -1;
|
||||
material.indexEmissive = -1;
|
||||
material.indexMetallicRoughness = -1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user