mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
REndering the view rings better
This commit is contained in:
parent
f087bb7623
commit
e8b5a875d6
3 changed files with 35 additions and 6 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <StencilMaskPass.h>
|
#include <StencilMaskPass.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
|
|
||||||
|
#include <gpu/DrawWhite_frag.h>
|
||||||
#include "render-utils/drawWorkloadProxy_vert.h"
|
#include "render-utils/drawWorkloadProxy_vert.h"
|
||||||
#include "render-utils/drawWorkloadView_vert.h"
|
#include "render-utils/drawWorkloadView_vert.h"
|
||||||
#include "render-utils/drawWorkloadProxy_frag.h"
|
#include "render-utils/drawWorkloadProxy_frag.h"
|
||||||
|
@ -178,7 +179,8 @@ const gpu::PipelinePointer GameWorkloadRenderItem::getProxiesPipeline() {
|
||||||
const gpu::PipelinePointer GameWorkloadRenderItem::getViewsPipeline() {
|
const gpu::PipelinePointer GameWorkloadRenderItem::getViewsPipeline() {
|
||||||
if (!_drawAllViewsPipeline) {
|
if (!_drawAllViewsPipeline) {
|
||||||
auto vs = drawWorkloadView_vert::getShader();
|
auto vs = drawWorkloadView_vert::getShader();
|
||||||
auto ps = drawWorkloadProxy_frag::getShader();
|
// auto ps = drawWorkloadProxy_frag::getShader();
|
||||||
|
auto ps = DrawWhite_frag::getShader();
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
|
@ -247,7 +249,7 @@ void GameWorkloadRenderItem::render(RenderArgs* args) {
|
||||||
batch.setUniformBuffer(0, getDrawViewBuffer());
|
batch.setUniformBuffer(0, getDrawViewBuffer());
|
||||||
// static const int NUM_VERTICES_PER_VIEW = 27;
|
// static const int NUM_VERTICES_PER_VIEW = 27;
|
||||||
// batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_VIEW * _numAllViews, 0);
|
// batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_VIEW * _numAllViews, 0);
|
||||||
batch.draw(gpu::TRIANGLES, _numDrawViewVerts * 4, 0);
|
batch.draw(gpu::TRIANGLE_STRIP, _numDrawViewVerts * 3 * 2, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
|
|
||||||
bool freezeViews{ false };
|
bool freezeViews{ false };
|
||||||
bool showProxies{ false };
|
bool showProxies{ false };
|
||||||
bool showViews{ false };
|
bool showViews{ true };
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
|
||||||
|
|
|
@ -54,15 +54,24 @@ WorkloadView getWorkloadView(int i) {
|
||||||
out vec4 varColor;
|
out vec4 varColor;
|
||||||
out vec3 varTexcoord;
|
out vec3 varTexcoord;
|
||||||
|
|
||||||
const int NUM_VERTICES_PER_VIEW = 27;
|
/*const int NUM_VERTICES_PER_VIEW = 27;
|
||||||
const int NUM_REGIONS_PER_VIEW = 3;
|
const int NUM_REGIONS_PER_VIEW = 3;
|
||||||
const int NUM_VERTICES_PER_VIEW_REGION = NUM_VERTICES_PER_VIEW / NUM_REGIONS_PER_VIEW;
|
const int NUM_VERTICES_PER_VIEW_REGION = NUM_VERTICES_PER_VIEW / NUM_REGIONS_PER_VIEW;
|
||||||
|
*/
|
||||||
|
|
||||||
|
const int NUM_VERTICES_PER_SEGMENT = 2;
|
||||||
|
const int NUM_SEGMENT_PER_VIEW_REGION = 65;
|
||||||
|
const int NUM_VERTICES_PER_VIEW_REGION = NUM_SEGMENT_PER_VIEW_REGION * NUM_VERTICES_PER_SEGMENT;
|
||||||
|
const int NUM_REGIONS_PER_VIEW = 3;
|
||||||
|
const int NUM_VERTICES_PER_VIEW = NUM_VERTICES_PER_VIEW_REGION * NUM_REGIONS_PER_VIEW;
|
||||||
|
|
||||||
|
|
||||||
layout(std140) uniform drawMeshBuffer {
|
layout(std140) uniform drawMeshBuffer {
|
||||||
vec4 verts[65];
|
vec4 verts[NUM_SEGMENT_PER_VIEW_REGION];
|
||||||
};
|
};
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec4 UNIT_SPRITE[NUM_VERTICES_PER_VIEW_REGION] = vec4[NUM_VERTICES_PER_VIEW_REGION](
|
/* const vec4 UNIT_SPRITE[NUM_VERTICES_PER_VIEW_REGION] = vec4[NUM_VERTICES_PER_VIEW_REGION](
|
||||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||||
vec4(3.0, -1.0, 0.0, 1.0),
|
vec4(3.0, -1.0, 0.0, 1.0),
|
||||||
vec4(-1.0, 3.0, 0.0, 1.0),
|
vec4(-1.0, 3.0, 0.0, 1.0),
|
||||||
|
@ -88,6 +97,23 @@ void main(void) {
|
||||||
int vertexID = regionVertexID;
|
int vertexID = regionVertexID;
|
||||||
|
|
||||||
vec4 spriteVert = UNIT_SPRITE[UNIT_SPRITE_INDICES[vertexID]];
|
vec4 spriteVert = UNIT_SPRITE[UNIT_SPRITE_INDICES[vertexID]];
|
||||||
|
*/
|
||||||
|
|
||||||
|
int viewID = gl_VertexID / NUM_VERTICES_PER_VIEW;
|
||||||
|
int viewVertexID = gl_VertexID - viewID * NUM_VERTICES_PER_VIEW;
|
||||||
|
|
||||||
|
int regionID = viewVertexID / NUM_VERTICES_PER_VIEW_REGION;
|
||||||
|
int regionVertexID = viewVertexID - regionID * NUM_VERTICES_PER_VIEW_REGION;
|
||||||
|
|
||||||
|
int segmentID = regionVertexID / NUM_VERTICES_PER_SEGMENT;
|
||||||
|
int segmentVertexID = regionVertexID / NUM_VERTICES_PER_SEGMENT;
|
||||||
|
|
||||||
|
vec4 segment = verts[segmentID];
|
||||||
|
|
||||||
|
vec4 spriteVert = vec4(segment.xy, 0.0, 1.0);
|
||||||
|
|
||||||
|
vec3 lateralDir = (-1.0 + 2.0 * float(segmentVertexID)) * vec3(segment.y, -segment.x, 0.0);
|
||||||
|
|
||||||
|
|
||||||
WorkloadView view = getWorkloadView(viewID);
|
WorkloadView view = getWorkloadView(viewID);
|
||||||
|
|
||||||
|
@ -101,6 +127,7 @@ void main(void) {
|
||||||
vec3 dirX = vec3(1.0, 0.0, 0.0);
|
vec3 dirX = vec3(1.0, 0.0, 0.0);
|
||||||
vec3 dirY = vec3(0.0, 1.0, 0.0);
|
vec3 dirY = vec3(0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
spriteVert.xyz += 0.2 * lateralDir;
|
||||||
vec3 originSpaceVert = regionRadius * (dirX * spriteVert.x + dirY * spriteVert.y + dirZ * spriteVert.z);
|
vec3 originSpaceVert = regionRadius * (dirX * spriteVert.x + dirY * spriteVert.y + dirZ * spriteVert.z);
|
||||||
|
|
||||||
vec4 pos = vec4(proxyPosWorld.xyz + originSpaceVert, 1.0);
|
vec4 pos = vec4(proxyPosWorld.xyz + originSpaceVert, 1.0);
|
||||||
|
|
Loading…
Reference in a new issue