Merge branch 'graphics' of https://github.com/highfidelity/hifi into hdr

This commit is contained in:
samcake 2015-12-04 17:53:37 -08:00
commit dfd26bebae
10 changed files with 107 additions and 21 deletions

View file

@ -384,10 +384,10 @@ var CHECK_MARK_COLOR = {
y: newY
});
Overlays.editOverlay(this.checkMark, {
y: newY
y: newY + (0.25 * this.thumbSize)
});
Overlays.editOverlay(this.unCheckMark, {
y: newY
y: newY + (0.25 * this.thumbSize)
});
};
@ -399,10 +399,10 @@ var CHECK_MARK_COLOR = {
y: this.y
});
Overlays.editOverlay(this.checkMark, {
y: this.y
y: this.y + (0.25 * this.thumbSize)
});
Overlays.editOverlay(this.unCheckMark, {
y: this.y
y: this.y+ (0.25 * this.thumbSize)
});
};

View file

@ -10,6 +10,9 @@
Script.include("cookies.js");
var MENU = "Developer>Render>Debug Deferred Buffer";
var ACTIONS = ["Off", "Diffuse", "Normal", "Specular", "Depth", "Lighting"];
var panel = new Panel(10, 100);
function CounterWidget(parentPanel, name, feedGetter, drawGetter, capSetter, capGetter) {
@ -61,17 +64,18 @@ var overlaysCounter = new CounterWidget(panel, "Overlays",
function () { return Scene.getEngineMaxDrawnOverlay3DItems(); }
);
function menuItemEvent(menuItem) {
var index = ACTIONS.indexOf(menuItem);
if (index >= 0) {
Scene.setEngineDisplayDebugDeferredBuffer(index);
print(menuItem);
}
}
// see libraries/render/src/render/Engine.h
var showDisplayStatusFlag = 1;
var showNetworkStatusFlag = 2;
panel.newCheckbox("Debug deferred buffer",
function(value) { Scene.setEngineDisplayDebugDeferredBuffer(value > 0); },
function() { return Scene.doEngineDisplayDebugDeferredBuffer() > 0; },
function(value) { return value > 0; }
);
panel.newCheckbox("Display status",
function(value) { Scene.setEngineDisplayItemStatus(value ?
Scene.doEngineDisplayItemStatus() | showDisplayStatusFlag :
@ -101,7 +105,11 @@ Controller.mouseMoveEvent.connect(function panelMouseMoveEvent(event) { return p
Controller.mousePressEvent.connect( function panelMousePressEvent(event) { return panel.mousePressEvent(event); });
Controller.mouseReleaseEvent.connect(function(event) { return panel.mouseReleaseEvent(event); });
Menu.menuItemEvent.connect(menuItemEvent);
Menu.addActionGroup(MENU, ACTIONS, ACTIONS[0]);
function scriptEnding() {
panel.destroy();
Menu.removeActionGroup(MENU);
}
Script.scriptEnding.connect(scriptEnding);

View file

@ -985,6 +985,26 @@ bool Menu::menuItemExists(const QString& menu, const QString& menuitem) {
return false;
};
void Menu::addActionGroup(const QString& groupName, const QStringList& actionList, const QString& selected) {
auto menu = addMenu(groupName);
QActionGroup* actionGroup = new QActionGroup(menu);
actionGroup->setExclusive(true);
auto menuScriptingInterface = MenuScriptingInterface::getInstance();
for (auto action : actionList) {
auto item = addCheckableActionToQMenuAndActionHash(menu, action, 0, action == selected,
menuScriptingInterface,
SLOT(menuItemTriggered()));
actionGroup->addAction(item);
}
QMenuBar::repaint();
}
void Menu::removeActionGroup(const QString& groupName) {
removeMenu(groupName);
}
MenuWrapper::MenuWrapper(QMenu* menu) : _realMenu(menu) {
VrMenu::executeOrQueue([=](VrMenu* vrMenu) {

View file

@ -100,6 +100,8 @@ public slots:
void addMenuItem(const MenuItemProperties& properties);
void removeMenuItem(const QString& menuName, const QString& menuitem);
bool menuItemExists(const QString& menuName, const QString& menuitem);
void addActionGroup(const QString& groupName, const QStringList& actionList, const QString& selected = QString());
void removeActionGroup(const QString& groupName);
bool isOptionChecked(const QString& menuOption) const;
void setIsOptionChecked(const QString& menuOption, bool isChecked);

View file

@ -84,6 +84,19 @@ bool MenuScriptingInterface::menuItemExists(const QString& menu, const QString&
return result;
}
void MenuScriptingInterface::addActionGroup(const QString& groupName, const QStringList& actionList,
const QString& selected) {
QMetaObject::invokeMethod(Menu::getInstance(), "addActionGroup",
Q_ARG(const QString&, groupName),
Q_ARG(const QStringList&, actionList),
Q_ARG(const QString&, selected));
}
void MenuScriptingInterface::removeActionGroup(const QString& groupName) {
QMetaObject::invokeMethod(Menu::getInstance(), "removeActionGroup",
Q_ARG(const QString&, groupName));
}
bool MenuScriptingInterface::isOptionChecked(const QString& menuOption) {
bool result;
QMetaObject::invokeMethod(Menu::getInstance(), "isOptionChecked", Qt::BlockingQueuedConnection,

View file

@ -42,6 +42,10 @@ public slots:
void removeMenuItem(const QString& menuName, const QString& menuitem);
bool menuItemExists(const QString& menuName, const QString& menuitem);
void addActionGroup(const QString& groupName, const QStringList& actionList,
const QString& selected = QString());
void removeActionGroup(const QString& groupName);
bool isOptionChecked(const QString& menuOption);
void setIsOptionChecked(const QString& menuOption, bool isChecked);

View file

@ -24,20 +24,38 @@
using namespace render;
const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline() {
if (!_pipeline) {
static const std::string PLACEHOLDER { "DEBUG_PLACEHOLDER" };
static const std::array<std::string, DebugDeferredBuffer::NUM_SLOTS> SLOT_NAMES {{
"diffuseMap",
"normalMap",
"specularMap",
"depthMap",
"lightingMap"
}};
std::string getCode(int slot) {
return std::string("return texture(").append(SLOT_NAMES[slot]).append(", uv);");
}
const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(int slot) {
if (!_pipelines[slot]) {
std::string fragmentShader = debug_deferred_buffer_frag;
fragmentShader.replace(fragmentShader.find(PLACEHOLDER), PLACEHOLDER.size(), getCode(slot));
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex({ debug_deferred_buffer_vert }));
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel({ debug_deferred_buffer_frag }));
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(fragmentShader));
auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
gpu::Shader::BindingSet slotBindings;
for (int slot = 0; slot < NUM_SLOTS; ++slot) {
slotBindings.insert(gpu::Shader::Binding(SLOT_NAMES[slot], slot));
}
gpu::Shader::makeProgram(*program, slotBindings);
// Good to go add the brand new pipeline
_pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>());
_pipelines[slot] = gpu::Pipeline::create(program, std::make_shared<gpu::State>());
}
return _pipeline;
return _pipelines[slot];
}
@ -58,9 +76,13 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren
batch.setViewTransform(viewMat);
batch.setModelTransform(Transform());
batch.setPipeline(getPipeline());
batch.setPipeline(getPipeline((DebugDeferredBufferSlot)(renderContext->_drawDebugDeferredBuffer - 1)));
batch.setResourceTexture(0, framebufferCache->getDeferredColorTexture());
batch.setResourceTexture(Diffuse, framebufferCache->getDeferredColorTexture());
batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture());
batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture());
glm::vec4 color(0.0f, 0.0f, 1.0f, 1.0f);
glm::vec2 bottomLeft(0.0f, -1.0f);

View file

@ -18,12 +18,22 @@ class DebugDeferredBuffer {
public:
using JobModel = render::Job::Model<DebugDeferredBuffer>;
enum DebugDeferredBufferSlot : int {
Diffuse = 0,
Normal,
Specular,
Depth,
Lighting,
NUM_SLOTS
};
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
private:
const gpu::PipelinePointer& getPipeline();
const gpu::PipelinePointer& getPipeline(int slot);
gpu::PipelinePointer _pipeline;
std::array<gpu::PipelinePointer, NUM_SLOTS> _pipelines;
};
#endif // hifi_DebugDeferredBuffer_h

View file

@ -24,6 +24,9 @@ uniform sampler2D specularMap;
// the depth texture
uniform sampler2D depthMap;
// the lighting texture
uniform sampler2D lightingMap;
struct DeferredTransform {
mat4 projection;

View file

@ -17,6 +17,10 @@
in vec2 uv;
out vec4 outFragColor;
vec4 getFragmentColor() {
DEBUG_PLACEHOLDER
}
void main(void) {
outFragColor = texture(diffuseMap, uv);
outFragColor = getFragmentColor();
}