Trying to render the proxies without success

This commit is contained in:
samcake 2018-02-21 17:31:53 -08:00
parent ff067601e7
commit 9c136e7dac
5 changed files with 53 additions and 42 deletions

View file

@ -52,7 +52,7 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
namespace render {
template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload) {
auto builder = ItemKey::Builder().opaqueShape().withTagBits(ItemKey::TAG_BITS_0 | ItemKey::TAG_BITS_1);
auto builder = ItemKey::Builder().transparentShape().withTagBits(ItemKey::TAG_BITS_0 | ItemKey::TAG_BITS_1);
return builder.build();
}
template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload) {
@ -66,6 +66,12 @@ namespace render {
payload->render(args);
}
}
template <> const ShapeKey shapeGetShapeKey(const GameWorkloadRenderItem::Pointer& payload) {
if (payload) {
return ShapeKey::Builder::ownPipeline();
}
return ShapeKey::Builder::ownPipeline();
}
}
@ -87,40 +93,41 @@ const gpu::PipelinePointer GameWorkloadRenderItem::getPipeline() {
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding("ssbo0Buffer", 0));
gpu::Shader::makeProgram(*program, slotBindings);
auto state = std::make_shared<gpu::State>();
state->setDepthTest(true, false, gpu::LESS_EQUAL);
/* state->setDepthTest(true, false, gpu::LESS_EQUAL);
state->setBlendFunction(true,
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
*/
_drawAllProxiesPipeline = gpu::Pipeline::create(program, state);
}
return _drawAllProxiesPipeline;
}
void GameWorkloadRenderItem::render(RenderArgs* args) {
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
args->_batch = &batch;
gpu::Batch& batch = *(args->_batch);
// Setup projection
glm::mat4 projMat;
Transform viewMat;
args->getViewFrustum().evalProjectionMatrix(projMat);
args->getViewFrustum().evalViewTransform(viewMat);
batch.setProjectionTransform(projMat);
batch.setViewTransform(viewMat);
batch.setModelTransform(Transform());
// Setup projection
// glm::mat4 projMat;
// Transform viewMat;
// args->getViewFrustum().evalProjectionMatrix(projMat);
// args->getViewFrustum().evalViewTransform(viewMat);
// batch.setProjectionTransform(projMat);
// batch.setViewTransform(viewMat);
batch.setModelTransform(Transform());
// Bind program
batch.setPipeline(getPipeline());
// Bind program
batch.setPipeline(getPipeline());
batch.setResourceBuffer(0, _allProxiesBuffer);
batch.setResourceBuffer(0, _allProxiesBuffer);
static const int NUM_VERTICES_PER_QUAD = 4;
batch.draw(gpu::LINES, NUM_VERTICES_PER_QUAD * _numAllProxies, 0);
});
static const int NUM_VERTICES_PER_QUAD = 24;
batch.draw(gpu::LINES, NUM_VERTICES_PER_QUAD * _numAllProxies, 0);
batch.setResourceBuffer(0, nullptr);
}

View file

@ -59,6 +59,8 @@ namespace render {
template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload);
template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload);
template <> void payloadRender(const GameWorkloadRenderItem::Pointer& payload, RenderArgs* args);
template <> const ShapeKey shapeGetShapeKey(const GameWorkloadRenderItem::Pointer& payload);
}
#endif

View file

@ -16,6 +16,8 @@ in vec2 varTexcoord;
out vec4 outFragColor;
void main(void) {
outFragColor = vec4(1.0);
/*
float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5);
if (varColor.a == 0.0) {
@ -23,6 +25,6 @@ void main(void) {
} else {
outFragColor = vec4(mix(vec3(1.0), varColor.xyz, var), varColor.a);
}
}*/
}

View file

@ -21,27 +21,27 @@
uniform vec4 inColor;
struct ItemBound {
vec4 id_boundPos;
vec4 boundDim_s;
struct WorkloadProxy {
vec4 sphere;
vec4 region;
};
#if defined(GPU_GL410)
uniform samplerBuffer ssbo0Buffer;
ItemBound getItemBound(int i) {
WorkloadProxy getWorkloadProxy(int i) {
int offset = 2 * i;
ItemBound bound;
bound.id_boundPos = texelFetch(ssbo0Buffer, offset);
bound.boundDim_s = texelFetch(ssbo0Buffer, offset + 1);
return bound;
WorkloadProxy proxy;
proxy.sphere = texelFetch(ssbo0Buffer, offset);
proxy.region = texelFetch(ssbo0Buffer, offset + 1);
return proxy;
}
#else
layout(std140) buffer ssbo0Buffer {
ItemBound bounds[];
WorkloadProxy proxies[];
};
ItemBound getItemBound(int i) {
ItemBound bound = bounds[i];
return bound;
WorkloadProxy getWorkloadProxy(int i) {
WorkloadProxy proxy = proxies[i];
return proxy;
}
#endif
@ -76,14 +76,15 @@ void main(void) {
1, 5
);
int boundID = gl_VertexID / 24;
int vertexID = gl_VertexID - boundID * 24;
int proxyID = gl_VertexID / 24;
int vertexID = gl_VertexID - proxyID * 24;
vec4 cubeVec = UNIT_BOX[UNIT_BOX_LINE_INDICES[vertexID]];
ItemBound bound = getItemBound(boundID);
vec3 boundPos = bound.id_boundPos.yzw;
vec3 boundDim = bound.boundDim_s.xyz;
WorkloadProxy proxy = getWorkloadProxy(proxyID);
vec3 boundPos = proxy.sphere.xyz;
// vec3 boundDim = vec3(proxy.sphere.w);
vec3 boundDim = vec3(0.5);
vec4 pos = vec4(boundPos + boundDim * cubeVec.xyz, 1.0);
@ -92,11 +93,8 @@ void main(void) {
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
if (inColor.w < 0.0) {
varColor = vec4(colorWheel(float(boundID)/(-inColor.w)), 1.0);
} else {
varColor = vec4(colorWheel(float(inColor.w)), 1.0);
}
varColor = vec4(colorWheel(float(proxyID)/(-inColor.w)), 1.0);
varTexcoord = vec2(cubeVec.w, length(boundDim));
}

View file

@ -40,6 +40,8 @@ public:
Sphere sphere;
uint8_t region { REGION_UNKNOWN };
uint8_t prevRegion { REGION_UNKNOWN };
uint16_t _padding;
uint32_t _paddings[3];
};
class View {