demo map and weapon

This commit is contained in:
h4570
2022-07-31 16:24:46 +02:00
parent 834d57ea32
commit 12dd72f15e
28 changed files with 781 additions and 18 deletions
@@ -29,6 +29,7 @@ class DynPipCore {
/** Force starting VU1 program instead of continueing */
void clear() { qbufferRenderer.clearLastProgramName(); }
void updatePrimLod(PipelineInfoBag* bag);
/**
* Send model matrix, lighting data and other
@@ -14,6 +14,7 @@
#include "math/m4x4.hpp"
#include "math/vec4.hpp"
#include "../pipeline_shading_type.hpp"
#include "../pipeline_texture_mapping_type.hpp"
namespace Tyra {
@@ -26,6 +27,7 @@ class PipelineInfoBag {
M4x4* model;
PipelineShadingType shadingType;
PipelineTextureMappingType textureMappingType;
bool blendingEnabled;
bool antiAliasingEnabled;
@@ -10,8 +10,9 @@
#pragma once
#include "renderer/3d/pipeline/shared/pipeline_shading_type.hpp"
#include "../shared/pipeline_shading_type.hpp"
#include "../shared/pipeline_lighting_options.hpp"
#include "../shared/pipeline_texture_mapping_type.hpp"
#include "./pipeline_frustum_culling.hpp"
namespace Tyra {
@@ -23,11 +24,13 @@ class PipelineOptions {
antiAliasingEnabled = false;
blendingEnabled = true;
shadingType = TyraShadingFlat;
textureMappingType = TyraLinear;
}
~PipelineOptions() {}
PipelineFrustumCulling frustumCulling;
PipelineShadingType shadingType;
PipelineTextureMappingType textureMappingType;
bool blendingEnabled;
bool antiAliasingEnabled;
@@ -0,0 +1,20 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
namespace Tyra {
enum PipelineTextureMappingType {
TyraNearest,
TyraLinear,
};
} // namespace Tyra
@@ -41,8 +41,8 @@ void DynPipCore::setPrim() {
void DynPipCore::setLod() {
lod.calculation = LOD_USE_K;
lod.max_level = 0;
lod.mag_filter = LOD_MAG_NEAREST;
lod.min_filter = LOD_MIN_NEAREST;
lod.mag_filter = LOD_MAG_LINEAR;
lod.min_filter = LOD_MIN_LINEAR;
lod.mipmap_select = LOD_MIPMAP_REGISTER;
lod.l = 0;
lod.k = 0.0F;
@@ -70,6 +70,20 @@ void DynPipCore::initParts(DynPipBag* bag) {
delete texBuffers;
}
void DynPipCore::updatePrimLod(PipelineInfoBag* bag) {
prim.antialiasing = bag->antiAliasingEnabled;
prim.blending = bag->blendingEnabled;
prim.shading = bag->shadingType;
if (bag->textureMappingType == TyraLinear) {
lod.mag_filter = LOD_MAG_LINEAR;
lod.min_filter = LOD_MIN_LINEAR;
} else {
lod.mag_filter = LOD_MAG_NEAREST;
lod.min_filter = LOD_MIN_NEAREST;
}
}
void DynPipCore::renderPart(DynPipBag** bags, const u32& count,
const bool& frustumCull) {
if (count <= 0) return;
@@ -75,6 +75,7 @@ void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
setBuffersDefaultVars(buffers, mesh, infoBag);
core.clear();
core.updatePrimLod(infoBag);
for (u32 i = 0; i < mesh->getMaterialsCount(); i++) {
auto* material = mesh->getMaterial(i);
@@ -210,10 +211,12 @@ PipelineInfoBag* DynamicPipeline::getInfoBag(DynamicMesh* mesh,
result->antiAliasingEnabled = options->antiAliasingEnabled;
result->blendingEnabled = options->blendingEnabled;
result->shadingType = options->shadingType;
result->textureMappingType = options->textureMappingType;
} else {
result->antiAliasingEnabled = false;
result->blendingEnabled = true;
result->shadingType = TyraShadingFlat;
result->textureMappingType = TyraLinear;
}
result->model = model;
@@ -243,8 +246,9 @@ DynPipTextureBag* DynamicPipeline::getTextureBag(
result->texture =
rendererCore->texture.repository.getBySpriteOrMesh(material->getId());
TYRA_ASSERT(result->texture, "Texture for material id: ", material->getId(),
"was not found in texture repository!");
TYRA_ASSERT(
result->texture, "Texture for material id: ", material->getId(),
"was not found in texture repository! Did you forget to add texture?");
result->coordinatesFrom = &materialFrameFrom->getTextureCoords()[startIndex];
result->coordinatesTo = &materialFrameTo->getTextureCoords()[startIndex];
@@ -14,6 +14,7 @@ namespace Tyra {
PipelineInfoBag::PipelineInfoBag() {
shadingType = TyraShadingFlat;
textureMappingType = TyraLinear;
blendingEnabled = true;
antiAliasingEnabled = false;
model = nullptr;
@@ -50,8 +50,8 @@ void StaPipCore::setPrim() {
void StaPipCore::setLod() {
lod.calculation = LOD_USE_K;
lod.max_level = 0;
lod.mag_filter = LOD_MAG_NEAREST;
lod.min_filter = LOD_MIN_NEAREST;
lod.mag_filter = LOD_MAG_LINEAR;
lod.min_filter = LOD_MIN_LINEAR;
lod.mipmap_select = LOD_MIPMAP_REGISTER;
lod.l = 0;
lod.k = 0.0F;
@@ -159,6 +159,14 @@ void StaPipQBufferRenderer::setInfo(PipelineInfoBag* bag) {
prim->antialiasing = bag->antiAliasingEnabled;
prim->blending = bag->blendingEnabled;
prim->shading = bag->shadingType;
if (bag->textureMappingType == TyraLinear) {
lod->mag_filter = LOD_MAG_LINEAR;
lod->min_filter = LOD_MIN_LINEAR;
} else {
lod->mag_filter = LOD_MAG_NEAREST;
lod->min_filter = LOD_MIN_NEAREST;
}
}
void StaPipQBufferRenderer::sendStaticData() const {
@@ -94,10 +94,12 @@ PipelineInfoBag* StaticPipeline::getInfoBag(StaticMesh* mesh,
result->blendingEnabled = options->blendingEnabled;
result->shadingType = options->shadingType;
result->fullClipChecks = options->fullClipChecks;
result->textureMappingType = options->textureMappingType;
} else {
result->antiAliasingEnabled = false;
result->blendingEnabled = true;
result->shadingType = TyraShadingFlat;
result->textureMappingType = TyraLinear;
result->fullClipChecks = false;
}
@@ -127,8 +129,9 @@ StaPipTextureBag* StaticPipeline::getTextureBag(
result->texture =
rendererCore->texture.repository.getBySpriteOrMesh(material->getId());
TYRA_ASSERT(result->texture, "Texture for material id: ", material->getId(),
"was not found in texture repository!");
TYRA_ASSERT(
result->texture, "Texture for material id: ", material->getId(),
"was not found in texture repository! Did you forget to add texture?");
result->coordinates = materialFrame->getTextureCoords();