Using pipelines properly where appropriate

This commit is contained in:
Brad Davis 2016-06-30 20:52:41 -07:00
parent b7926b8582
commit 5288d98376
5 changed files with 15 additions and 14 deletions

View file

@ -149,7 +149,6 @@ void Circle3DOverlay::render(RenderArgs* args) {
geometryCache->updateVertices(_quadVerticesID, points, color); geometryCache->updateVertices(_quadVerticesID, points, color);
} }
geometryCache->bindSimpleProgram(batch);
geometryCache->renderVertices(batch, gpu::TRIANGLES, _quadVerticesID); geometryCache->renderVertices(batch, gpu::TRIANGLES, _quadVerticesID);
} else { } else {
@ -188,8 +187,6 @@ void Circle3DOverlay::render(RenderArgs* args) {
geometryCache->updateVertices(_lineVerticesID, points, color); geometryCache->updateVertices(_lineVerticesID, points, color);
} }
// Render unlit
geometryCache->bindSimpleProgram(batch, false, false, true);
if (getIsDashedLine()) { if (getIsDashedLine()) {
geometryCache->renderVertices(batch, gpu::LINES, _lineVerticesID); geometryCache->renderVertices(batch, gpu::LINES, _lineVerticesID);
} else { } else {
@ -282,10 +279,13 @@ void Circle3DOverlay::render(RenderArgs* args) {
} }
const render::ShapeKey Circle3DOverlay::getShapeKey() { const render::ShapeKey Circle3DOverlay::getShapeKey() {
auto builder = render::ShapeKey::Builder().withOwnPipeline(); auto builder = render::ShapeKey::Builder().withoutCullFace();
if (getAlpha() != 1.0f) { if (getAlpha() != 1.0f) {
builder.withTranslucent(); builder.withTranslucent();
} }
if (!getIsSolid()) {
builder.withUnlit().withDepthBias();
}
return builder.build(); return builder.build();
} }

View file

@ -44,7 +44,6 @@ void Cube3DOverlay::render(RenderArgs* args) {
Transform transform; Transform transform;
transform.setTranslation(position); transform.setTranslation(position);
transform.setRotation(rotation); transform.setRotation(rotation);
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
auto pipeline = args->_pipeline; auto pipeline = args->_pipeline;
if (!pipeline) { if (!pipeline) {
@ -97,10 +96,13 @@ void Cube3DOverlay::render(RenderArgs* args) {
} }
const render::ShapeKey Cube3DOverlay::getShapeKey() { const render::ShapeKey Cube3DOverlay::getShapeKey() {
auto builder = render::ShapeKey::Builder().withOwnPipeline(); auto builder = render::ShapeKey::Builder();
if (getAlpha() != 1.0f) { if (getAlpha() != 1.0f) {
builder.withTranslucent(); builder.withTranslucent();
} }
if (!getIsSolid()) {
builder.withUnlit().withDepthBias();
}
return builder.build(); return builder.build();
} }

View file

@ -75,11 +75,9 @@ void Grid3DOverlay::render(RenderArgs* args) {
transform.setScale(glm::vec3(getDimensions(), 1.0f)); transform.setScale(glm::vec3(getDimensions(), 1.0f));
transform.setTranslation(position); transform.setTranslation(position);
batch->setModelTransform(transform); batch->setModelTransform(transform);
auto geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
const float MINOR_GRID_EDGE = 0.0025f; const float MINOR_GRID_EDGE = 0.0025f;
const float MAJOR_GRID_EDGE = 0.005f; const float MAJOR_GRID_EDGE = 0.005f;
geometryCache->renderGrid(*batch, minCorner, maxCorner, DependencyManager::get<GeometryCache>()->renderGrid(*batch, minCorner, maxCorner,
_minorGridRowDivisions, _minorGridColDivisions, MINOR_GRID_EDGE, _minorGridRowDivisions, _minorGridColDivisions, MINOR_GRID_EDGE,
_majorGridRowDivisions, _majorGridColDivisions, MAJOR_GRID_EDGE, _majorGridRowDivisions, _majorGridColDivisions, MAJOR_GRID_EDGE,
gridColor, _drawInFront); gridColor, _drawInFront);
@ -87,7 +85,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
} }
const render::ShapeKey Grid3DOverlay::getShapeKey() { const render::ShapeKey Grid3DOverlay::getShapeKey() {
return render::ShapeKey::Builder().withOwnPipeline(); return render::ShapeKey::Builder().withOwnPipeline().withUnlit().withDepthBias();
} }
void Grid3DOverlay::setProperties(const QVariantMap& properties) { void Grid3DOverlay::setProperties(const QVariantMap& properties) {

View file

@ -93,9 +93,7 @@ void Image3DOverlay::render(RenderArgs* args) {
batch->setModelTransform(transform); batch->setModelTransform(transform);
batch->setResourceTexture(0, _texture->getGPUTexture()); batch->setResourceTexture(0, _texture->getGPUTexture());
auto geometryCache = DependencyManager::get<GeometryCache>(); DependencyManager::get<GeometryCache>()->renderQuad(
geometryCache->bindSimpleProgram(*batch, true, false);
geometryCache->renderQuad(
*batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, *batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha) glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha)
); );
@ -104,7 +102,7 @@ void Image3DOverlay::render(RenderArgs* args) {
} }
const render::ShapeKey Image3DOverlay::getShapeKey() { const render::ShapeKey Image3DOverlay::getShapeKey() {
auto builder = render::ShapeKey::Builder().withOwnPipeline(); auto builder = render::ShapeKey::Builder().withoutCullFace().withDepthBias();
if (_emissive) { if (_emissive) {
builder.withUnlit(); builder.withUnlit();
} }

View file

@ -62,6 +62,9 @@ const render::ShapeKey Sphere3DOverlay::getShapeKey() {
if (getAlpha() != 1.0f) { if (getAlpha() != 1.0f) {
builder.withTranslucent(); builder.withTranslucent();
} }
if (!getIsSolid()) {
builder.withUnlit().withDepthBias();
}
return builder.build(); return builder.build();
} }