mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Fixing a few issues and syntax, trying to understand why the shadows are not rendering correctly
This commit is contained in:
parent
f96079f4f9
commit
6f5c411a46
4 changed files with 38 additions and 12 deletions
|
@ -169,7 +169,8 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
PerformanceTimer perfTimer("model->render");
|
||||
// filter out if not needed to render
|
||||
if (args && (args->_renderMode == RenderArgs::SHADOW_RENDER_MODE)) {
|
||||
if (movingOrAnimating) {
|
||||
// if (movingOrAnimating) {
|
||||
{
|
||||
_model->renderInScene(alpha, args);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -104,7 +104,7 @@ void makeBindings(GLBackend::GLShader* shader) {
|
|||
loc = glGetUniformBlockIndex(glprogram, "transformCameraBuffer");
|
||||
if (loc >= 0) {
|
||||
glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_CAMERA_SLOT);
|
||||
shader->_transformCameraSlot = gpu::TRANSFORM_OBJECT_SLOT;
|
||||
shader->_transformCameraSlot = gpu::TRANSFORM_CAMERA_SLOT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -121,18 +121,20 @@ Model::Locations Model::_normalMapLocations;
|
|||
Model::Locations Model::_specularMapLocations;
|
||||
Model::Locations Model::_normalSpecularMapLocations;
|
||||
Model::Locations Model::_translucentLocations;
|
||||
Model::Locations Model::_shadowLocations;
|
||||
|
||||
Model::Locations Model::_lightmapLocations;
|
||||
Model::Locations Model::_lightmapNormalMapLocations;
|
||||
Model::Locations Model::_lightmapSpecularMapLocations;
|
||||
Model::Locations Model::_lightmapNormalSpecularMapLocations;
|
||||
|
||||
|
||||
Model::SkinLocations Model::_skinLocations;
|
||||
Model::SkinLocations Model::_skinNormalMapLocations;
|
||||
Model::SkinLocations Model::_skinSpecularMapLocations;
|
||||
Model::SkinLocations Model::_skinNormalSpecularMapLocations;
|
||||
Model::SkinLocations Model::_skinShadowLocations;
|
||||
Model::SkinLocations Model::_skinTranslucentLocations;
|
||||
Model::SkinLocations Model::_skinShadowLocations;
|
||||
|
||||
AbstractViewStateInterface* Model::_viewState = NULL;
|
||||
|
||||
|
@ -284,8 +286,7 @@ void Model::init() {
|
|||
|
||||
_shadowProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelShadowVertex, modelShadowPixel));
|
||||
makeResult = gpu::Shader::makeProgram(*_shadowProgram, slotBindings);
|
||||
Model::Locations tempShadowLoc;
|
||||
initProgram(_shadowProgram, tempShadowLoc);
|
||||
initProgram(_shadowProgram, _shadowLocations);
|
||||
|
||||
_lightmapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelLightmapVertex, modelLightmapPixel));
|
||||
makeResult = gpu::Shader::makeProgram(*_lightmapProgram, slotBindings);
|
||||
|
@ -656,7 +657,9 @@ bool Model::render(float alpha, RenderMode mode, RenderArgs* args) {
|
|||
renderSetup(args);
|
||||
return renderCore(alpha, mode, args);
|
||||
}
|
||||
|
||||
|
||||
#define WANT_DEBUG_MESHBOXES
|
||||
|
||||
bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
|
||||
PROFILE_RANGE(__FUNCTION__);
|
||||
if (!_viewState) {
|
||||
|
@ -678,7 +681,14 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
|
|||
if (_transforms.empty()) {
|
||||
_transforms.push_back(Transform());
|
||||
}
|
||||
_transforms[0] = _viewState->getViewTransform();
|
||||
|
||||
if (args && args->_viewFrustum) {
|
||||
_transforms[0].setTranslation(args->_viewFrustum->getPosition());
|
||||
_transforms[0].setRotation(args->_viewFrustum->getOrientation());
|
||||
} else {
|
||||
_transforms[0] = _viewState->getViewTransform();
|
||||
}
|
||||
|
||||
// apply entity translation offset to the viewTransform in one go (it's a preTranslate because viewTransform goes from world to eye space)
|
||||
_transforms[0].preTranslate(-_translation);
|
||||
|
||||
|
@ -694,6 +704,9 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
|
|||
GLBATCH(glCullFace)(GL_FRONT);
|
||||
}
|
||||
}
|
||||
GLBATCH(glEnable)(GL_DEPTH_TEST);
|
||||
GLBATCH(glDepthFunc)(GL_LEQUAL);
|
||||
GLBATCH(glDepthMask)(true);
|
||||
|
||||
// render opaque meshes with alpha testing
|
||||
|
||||
|
@ -1710,14 +1723,22 @@ void Model::startScene(RenderArgs::RenderSide renderSide) {
|
|||
}
|
||||
}
|
||||
|
||||
void Model::setupBatchTransform(gpu::Batch& batch) {
|
||||
void Model::setupBatchTransform(gpu::Batch& batch, RenderArgs* args) {
|
||||
|
||||
// Capture the view matrix once for the rendering of this model
|
||||
if (_transforms.empty()) {
|
||||
_transforms.push_back(Transform());
|
||||
}
|
||||
_transforms[0] = _viewState->getViewTransform();
|
||||
|
||||
if (args && args->_viewFrustum) {
|
||||
_transforms[0].setTranslation(args->_viewFrustum->getPosition());
|
||||
_transforms[0].setRotation(args->_viewFrustum->getOrientation());
|
||||
} else {
|
||||
_transforms[0] = _viewState->getViewTransform();
|
||||
}
|
||||
|
||||
_transforms[0].preTranslate(-_translation);
|
||||
|
||||
batch.setViewTransform(_transforms[0]);
|
||||
}
|
||||
|
||||
|
@ -1762,6 +1783,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
|
|||
}
|
||||
|
||||
// render opaque meshes with alpha testing
|
||||
GLBATCH(glDepthMask)(true);
|
||||
|
||||
GLBATCH(glDisable)(GL_BLEND);
|
||||
GLBATCH(glEnable)(GL_ALPHA_TEST);
|
||||
|
@ -2286,6 +2308,7 @@ void Model::pickPrograms(gpu::Batch& batch, RenderMode mode, bool translucent, f
|
|||
skinLocations = &_skinLocations;
|
||||
if (mode == SHADOW_RENDER_MODE) {
|
||||
program = _shadowProgram;
|
||||
locations = &_shadowLocations;
|
||||
skinProgram = _skinShadowProgram;
|
||||
skinLocations = &_skinShadowLocations;
|
||||
} else if (translucent && alphaThreshold == 0.0f) {
|
||||
|
@ -2376,7 +2399,7 @@ int Model::renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool
|
|||
pickPrograms(batch, mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned, args, locations, skinLocations);
|
||||
pickProgramsNeeded = false;
|
||||
}
|
||||
model->setupBatchTransform(batch);
|
||||
model->setupBatchTransform(batch, args);
|
||||
meshPartsRendered += model->renderMeshesFromList(list, batch, mode, translucent, alphaThreshold, args, locations, skinLocations);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -357,6 +357,7 @@ private:
|
|||
static Locations _specularMapLocations;
|
||||
static Locations _normalSpecularMapLocations;
|
||||
static Locations _translucentLocations;
|
||||
static Locations _shadowLocations;
|
||||
|
||||
static Locations _lightmapLocations;
|
||||
static Locations _lightmapNormalMapLocations;
|
||||
|
@ -377,8 +378,9 @@ private:
|
|||
static SkinLocations _skinNormalMapLocations;
|
||||
static SkinLocations _skinSpecularMapLocations;
|
||||
static SkinLocations _skinNormalSpecularMapLocations;
|
||||
static SkinLocations _skinShadowLocations;
|
||||
static SkinLocations _skinTranslucentLocations;
|
||||
static SkinLocations _skinShadowLocations;
|
||||
|
||||
|
||||
static void initSkinProgram(ProgramObject& program, SkinLocations& locations);
|
||||
static void initSkinProgram(gpu::ShaderPointer& program, SkinLocations& locations);
|
||||
|
@ -463,7 +465,7 @@ private:
|
|||
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args = NULL,
|
||||
bool forceRenderMeshes = false);
|
||||
|
||||
void setupBatchTransform(gpu::Batch& batch);
|
||||
void setupBatchTransform(gpu::Batch& batch, RenderArgs* args);
|
||||
QVector<int>* pickMeshList(bool translucent, float alphaThreshold, bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned);
|
||||
|
||||
int renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold,
|
||||
|
|
Loading…
Reference in a new issue