mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 20:47:35 +02:00
Working on render modes.
This commit is contained in:
parent
550a8fdb99
commit
a2b94aa433
6 changed files with 37 additions and 16 deletions
|
@ -436,6 +436,19 @@ void StaticModelRenderer::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticModelRenderer::renderUnclipped(float alpha, Mode mode) {
|
void StaticModelRenderer::renderUnclipped(float alpha, Mode mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case DIFFUSE_MODE:
|
||||||
|
_model->render(alpha, Model::DIFFUSE_RENDER_MODE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORMAL_MODE:
|
||||||
|
_model->render(alpha, Model::NORMAL_RENDER_MODE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
_model->render(alpha);
|
||||||
|
break;
|
||||||
|
}
|
||||||
_model->render(alpha);
|
_model->render(alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,8 +326,10 @@ void Avatar::renderBody(RenderMode renderMode) {
|
||||||
renderBillboard();
|
renderBillboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_skeletonModel.render(1.0f, renderMode == SHADOW_RENDER_MODE);
|
Model::RenderMode modelRenderMode = (renderMode == SHADOW_RENDER_MODE) ?
|
||||||
getHead()->render(1.0f, renderMode == SHADOW_RENDER_MODE);
|
Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
|
||||||
|
_skeletonModel.render(1.0f, modelRenderMode);
|
||||||
|
getHead()->render(1.0f, modelRenderMode);
|
||||||
getHand()->render(false);
|
getHand()->render(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -642,14 +642,16 @@ void MyAvatar::renderBody(RenderMode renderMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the body's voxels and head
|
// Render the body's voxels and head
|
||||||
_skeletonModel.render(1.0f, renderMode == SHADOW_RENDER_MODE);
|
Model::RenderMode modelRenderMode = (renderMode == SHADOW_RENDER_MODE) ?
|
||||||
|
Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
|
||||||
|
_skeletonModel.render(1.0f, modelRenderMode);
|
||||||
|
|
||||||
// Render head so long as the camera isn't inside it
|
// Render head so long as the camera isn't inside it
|
||||||
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.40f;
|
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.40f;
|
||||||
Camera* myCamera = Application::getInstance()->getCamera();
|
Camera* myCamera = Application::getInstance()->getCamera();
|
||||||
if (renderMode != NORMAL_RENDER_MODE || (glm::length(myCamera->getPosition() - getHead()->calculateAverageEyePosition()) >
|
if (renderMode != NORMAL_RENDER_MODE || (glm::length(myCamera->getPosition() - getHead()->calculateAverageEyePosition()) >
|
||||||
RENDER_HEAD_CUTOFF_DISTANCE * _scale)) {
|
RENDER_HEAD_CUTOFF_DISTANCE * _scale)) {
|
||||||
getHead()->render(1.0f, renderMode == SHADOW_RENDER_MODE);
|
getHead()->render(1.0f, modelRenderMode);
|
||||||
}
|
}
|
||||||
getHand()->render(true);
|
getHand()->render(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ bool Model::updateGeometry() {
|
||||||
bool Model::render(float alpha, RenderMode mode) {
|
bool Model::render(float alpha, RenderMode mode) {
|
||||||
// render the attachments
|
// render the attachments
|
||||||
foreach (Model* attachment, _attachments) {
|
foreach (Model* attachment, _attachments) {
|
||||||
attachment->render(alpha);
|
attachment->render(alpha, mode);
|
||||||
}
|
}
|
||||||
if (_meshStates.isEmpty()) {
|
if (_meshStates.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -305,7 +305,11 @@ bool Model::render(float alpha, RenderMode mode) {
|
||||||
|
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
|
|
||||||
// glEnable(GL_CULL_FACE);
|
if (mode == DIFFUSE_RENDER_MODE || mode == NORMAL_RENDER_MODE) {
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
} else {
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
}
|
||||||
|
|
||||||
// render opaque meshes with alpha testing
|
// render opaque meshes with alpha testing
|
||||||
|
|
||||||
|
@ -316,7 +320,7 @@ bool Model::render(float alpha, RenderMode mode) {
|
||||||
|
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
// render translucent meshes afterwards, with back face culling
|
// render translucent meshes afterwards
|
||||||
|
|
||||||
renderMeshes(alpha, mode, true);
|
renderMeshes(alpha, mode, true);
|
||||||
|
|
||||||
|
@ -1137,7 +1141,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
||||||
ProgramObject* program = &_program;
|
ProgramObject* program = &_program;
|
||||||
ProgramObject* skinProgram = &_skinProgram;
|
ProgramObject* skinProgram = &_skinProgram;
|
||||||
SkinLocations* skinLocations = &_skinLocations;
|
SkinLocations* skinLocations = &_skinLocations;
|
||||||
if (mode == SHADOW_MAP_MODE) {
|
if (mode == SHADOW_RENDER_MODE) {
|
||||||
program = &_shadowProgram;
|
program = &_shadowProgram;
|
||||||
skinProgram = &_skinShadowProgram;
|
skinProgram = &_skinShadowProgram;
|
||||||
skinLocations = &_skinShadowLocations;
|
skinLocations = &_skinShadowLocations;
|
||||||
|
@ -1175,7 +1179,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesh.blendshapes.isEmpty()) {
|
if (mesh.blendshapes.isEmpty()) {
|
||||||
if (!(mesh.tangents.isEmpty() || mode == SHADOW_MAP_MODE)) {
|
if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) {
|
||||||
activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, vertexCount * 2 * sizeof(glm::vec3), 3);
|
activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, vertexCount * 2 * sizeof(glm::vec3), 3);
|
||||||
activeProgram->enableAttributeArray(tangentLocation);
|
activeProgram->enableAttributeArray(tangentLocation);
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1189,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
||||||
(mesh.tangents.size() + mesh.colors.size()) * sizeof(glm::vec3)));
|
(mesh.tangents.size() + mesh.colors.size()) * sizeof(glm::vec3)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(mesh.tangents.isEmpty() || mode == SHADOW_MAP_MODE)) {
|
if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) {
|
||||||
activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, 0, 3);
|
activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, 0, 3);
|
||||||
activeProgram->enableAttributeArray(tangentLocation);
|
activeProgram->enableAttributeArray(tangentLocation);
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1218,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// apply material properties
|
// apply material properties
|
||||||
if (mode == SHADOW_MAP_MODE) {
|
if (mode == SHADOW_RENDER_MODE) {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1255,7 +1259,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(mesh.tangents.isEmpty() || mode == SHADOW_MAP_MODE)) {
|
if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) {
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
|
@ -58,9 +58,9 @@ public:
|
||||||
void reset();
|
void reset();
|
||||||
virtual void simulate(float deltaTime, bool fullUpdate = true);
|
virtual void simulate(float deltaTime, bool fullUpdate = true);
|
||||||
|
|
||||||
enum RenderMode { DEFAULT_MODE, SHADOW_MAP_MODE, DIFFUSE_MODE, NORMAL_MODE };
|
enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE };
|
||||||
|
|
||||||
bool render(float alpha = 1.0f, RenderMode mode = DEFAULT_MODE);
|
bool render(float alpha = 1.0f, RenderMode mode = DEFAULT_RENDER_MODE);
|
||||||
|
|
||||||
/// Sets the URL of the model to render.
|
/// Sets the URL of the model to render.
|
||||||
/// \param fallback the URL of a fallback model to render if the requested model fails to load
|
/// \param fallback the URL of a fallback model to render if the requested model fails to load
|
||||||
|
|
|
@ -774,12 +774,12 @@ int VoxelizationVisitor::visit(MetavoxelInfo& info) {
|
||||||
float depth = 1.0f - images.depth.at(y * images.color.width() + x);
|
float depth = 1.0f - images.depth.at(y * images.color.width() + x);
|
||||||
float distance = depth - relative.z;
|
float distance = depth - relative.z;
|
||||||
float extent = images.scale.z * halfSize;
|
float extent = images.scale.z * halfSize;
|
||||||
if (distance < 0.0f) {
|
if (distance < -extent - EPSILON) {
|
||||||
info.outputValues[0] = AttributeValue(_outputs.at(0));
|
info.outputValues[0] = AttributeValue(_outputs.at(0));
|
||||||
return STOP_RECURSION;
|
return STOP_RECURSION;
|
||||||
}
|
}
|
||||||
QRgb color = images.color.pixel(x, y);
|
QRgb color = images.color.pixel(x, y);
|
||||||
if (distance < EPSILON) {
|
if (distance < extent + EPSILON) {
|
||||||
info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline<QRgb>(color));
|
info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline<QRgb>(color));
|
||||||
return STOP_RECURSION;
|
return STOP_RECURSION;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue