History

adding unlit property to text, fixing transparency, normals, other cleanup

SamGondelman committed 7 years ago

Commit fa416ad1 parent 0ef911050 files · +284 −199Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 50 files). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+14−47
@@ -722,42 +722,12 @@ gpu::ShaderPointer GeometryCache::_forwardUnlitShader; · 721 unmodified lines
722722 gpu::ShaderPointer GeometryCache::_forwardSimpleFadeShader;
723723 gpu::ShaderPointer GeometryCache::_forwardUnlitFadeShader;
724724
725−render::ShapePipelinePointer GeometryCache::_simpleOpaquePipeline;
726−render::ShapePipelinePointer GeometryCache::_simpleTransparentPipeline;
727−render::ShapePipelinePointer GeometryCache::_forwardSimpleOpaquePipeline;
728−render::ShapePipelinePointer GeometryCache::_forwardSimpleTransparentPipeline;
729−render::ShapePipelinePointer GeometryCache::_simpleOpaqueFadePipeline;
730−render::ShapePipelinePointer GeometryCache::_simpleTransparentFadePipeline;
731−render::ShapePipelinePointer GeometryCache::_simpleWirePipeline;
732−
733−uint8_t GeometryCache::CUSTOM_PIPELINE_NUMBER = 0;
734−
735−render::ShapePipelinePointer GeometryCache::shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) {
736− initializeShapePipelines();
737−
738− if (key.isWireframe()) {
739− return _simpleWirePipeline;
740− }
741−
742− if (key.isFaded()) {
743− if (key.isTranslucent()) {
744− return _simpleTransparentFadePipeline;
745− } else {
746− return _simpleOpaqueFadePipeline;
747− }
748− } else {
749− if (key.isTranslucent()) {
750− return _simpleTransparentPipeline;
751− } else {
752− return _simpleOpaquePipeline;
753− }
754− }
755−}
725+std::map<std::tuple<bool, bool, bool>, render::ShapePipelinePointer> GeometryCache::_shapePipelines;
756726
757727 GeometryCache::GeometryCache() :
758728 _nextID(0) {
759729 // Let's register its special shapePipeline factory:
760− registerShapePipeline();
730+ initializeShapePipelines();
761731 buildShapes();
762732 }
763733
@@ -799,16 +769,14 @@ void GeometryCache::releaseID(int id) { · 35 unmodified lines
799769 }
800770
801771 void GeometryCache::initializeShapePipelines() {
802− if (!_simpleOpaquePipeline) {
803− _simpleOpaquePipeline = getShapePipeline(false, false, true, false);
804− _simpleTransparentPipeline = getShapePipeline(false, true, true, false);
805− _forwardSimpleOpaquePipeline = getShapePipeline(false, false, true, false, false, true);
806− _forwardSimpleTransparentPipeline = getShapePipeline(false, true, true, false, false, true);
807−
808− // FIXME: these need forward pipelines
809− _simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, false, false, false);
810− _simpleTransparentFadePipeline = getFadingShapePipeline(false, true, false, false, false);
811− _simpleWirePipeline = getShapePipeline(false, false, true, true);
772+ if (_shapePipelines.empty()) {
773+ const int NUM_PIPELINES = 8;
774+ for (int i = 0; i < NUM_PIPELINES; ++i) {
775+ bool transparent = i & 1;
776+ bool unlit = i & 2;
777+ bool forward = i & 4;
778+ _shapePipelines[std::make_tuple(transparent, unlit, forward)] = getShapePipeline(false, transparent, true, unlit, false, forward);
779+ }
812780 }
813781 }
814782
@@ -1027,7 +995,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con · 212 unmodified lines
1027995 int* colorData = new int[details.vertices];
1028996 int* colorDataAt = colorData;
1029997
1030− const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f);
998+ const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f);
1031999 auto pointCount = points.size();
10321000 auto colorCount = colors.size();
10331001 int compactColor = 0;
@@ -1105,7 +1073,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 71 unmodified lines
11051073 int* colorData = new int[details.vertices];
11061074 int* colorDataAt = colorData;
11071075
1108− const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f);
1076+ const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f);
11091077 auto pointCount = points.size();
11101078 auto colorCount = colors.size();
11111079 for (auto i = 0; i < pointCount; i++) {
@@ -1193,7 +1161,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 81 unmodified lines
11931161 int* colorData = new int[details.vertices];
11941162 int* colorDataAt = colorData;
11951163
1196− const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f);
1164+ const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f);
11971165 for (int i = 0; i < points.size(); i++) {
11981166 glm::vec3 point = points[i];
11991167 glm::vec2 texCoord = texCoords[i];
@@ -2281,8 +2249,7 @@ void renderInstances(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color · 1081 unmodified lines
22812249
22822250 if (isWire) {
22832251 DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]);
2284− }
2285− else {
2252+ } else {
22862253 DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]);
22872254 }
22882255 });