mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Better rendering of the view circles
This commit is contained in:
parent
e3c8b9c62d
commit
9e7260839c
3 changed files with 68 additions and 19 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "render-utils/drawWorkloadProxy_vert.h"
|
||||
#include "render-utils/drawWorkloadView_vert.h"
|
||||
#include "render-utils/drawWorkloadProxy_frag.h"
|
||||
#include "render-utils/drawWorkloadView_frag.h"
|
||||
|
||||
|
||||
void GameSpaceToRender::configure(const Config& config) {
|
||||
|
@ -179,8 +180,8 @@ const gpu::PipelinePointer GameWorkloadRenderItem::getProxiesPipeline() {
|
|||
const gpu::PipelinePointer GameWorkloadRenderItem::getViewsPipeline() {
|
||||
if (!_drawAllViewsPipeline) {
|
||||
auto vs = drawWorkloadView_vert::getShader();
|
||||
// auto ps = drawWorkloadProxy_frag::getShader();
|
||||
auto ps = DrawWhite_frag::getShader();
|
||||
auto ps = drawWorkloadView_frag::getShader();
|
||||
// auto ps = DrawWhite_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
|
@ -247,8 +248,6 @@ void GameWorkloadRenderItem::render(RenderArgs* args) {
|
|||
batch.setPipeline(getViewsPipeline());
|
||||
|
||||
batch.setUniformBuffer(0, getDrawViewBuffer());
|
||||
// static const int NUM_VERTICES_PER_VIEW = 27;
|
||||
// batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_VIEW * _numAllViews, 0);
|
||||
batch.draw(gpu::TRIANGLE_STRIP, _numDrawViewVerts * 3 * 2, 0);
|
||||
|
||||
}
|
||||
|
|
32
libraries/render-utils/src/drawWorkloadView.slf
Normal file
32
libraries/render-utils/src/drawWorkloadView.slf
Normal file
|
@ -0,0 +1,32 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
// drawItemBounds.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Sam Gateau on 6/29/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
<@include gpu/Paint.slh@>
|
||||
|
||||
in vec4 varColor;
|
||||
in vec3 varTexcoord;
|
||||
|
||||
void main(void) {
|
||||
if (varColor.w > 0.0) {
|
||||
float r = sqrt(dot(varTexcoord.xyz,varTexcoord.xyz));
|
||||
float a = paintStripe(r * varColor.w, 0.0, 1.0 / varColor.w, 0.05 / varColor.w);
|
||||
if (a <= 0.1 || r > 1.1) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
packDeferredFragmentUnlit(
|
||||
vec3(0.0, 1.0, 0.0),
|
||||
1.0,
|
||||
varColor.rgb);
|
||||
}
|
|
@ -106,39 +106,57 @@ void main(void) {
|
|||
int regionVertexID = viewVertexID - regionID * NUM_VERTICES_PER_VIEW_REGION;
|
||||
|
||||
int segmentID = regionVertexID / NUM_VERTICES_PER_SEGMENT;
|
||||
int segmentVertexID = regionVertexID / NUM_VERTICES_PER_SEGMENT;
|
||||
int segmentVertexID = regionVertexID - segmentID * 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);
|
||||
vec4 spriteVert = vec4(segment.y, 0.0, segment.x, 1.0);
|
||||
vec3 spriteTan = vec3(segment.x, 0.0, -segment.y);
|
||||
|
||||
vec3 lateralDir = vec3(0.0, -1.0 + 2.0 * float(segmentVertexID), 0.0);
|
||||
|
||||
WorkloadView view = getWorkloadView(viewID);
|
||||
|
||||
vec4 region = view.regions[regionID];
|
||||
|
||||
vec4 proxyPosWorld = vec4(region.xyz, 1.0);
|
||||
float regionRadius = region.w;
|
||||
|
||||
// Define the sprite space
|
||||
vec3 dirZ = vec3(0.0, 0.0, 1.0);
|
||||
vec3 dirX = vec3(1.0, 0.0, 0.0);
|
||||
// vec3 dirZ = vec3(0.0, 0.0, 1.0);
|
||||
// vec3 dirX = vec3(1.0, 0.0, 0.0);
|
||||
// vec3 dirY = vec3(0.0, 1.0, 0.0);
|
||||
|
||||
vec3 dirZ = -normalize(view.direction_far.xyz);
|
||||
vec3 dirY = vec3(0.0, 1.0, 0.0);
|
||||
vec3 dirX = normalize(cross(dirY, dirZ));
|
||||
dirY = normalize(cross(dirZ, dirX));
|
||||
|
||||
spriteVert.xyz *= regionRadius;
|
||||
|
||||
// spriteVert.xyz += (0.05 * (regionID + 1)) * lateralDir;
|
||||
|
||||
vec3 originSpaceVert = (dirX * spriteVert.x + dirY * spriteVert.y + dirZ * spriteVert.z);
|
||||
vec3 originSpaceTan = normalize(dirX * spriteTan.x + dirY * spriteTan.y + dirZ * spriteTan.z);
|
||||
|
||||
spriteVert.xyz += 0.2 * lateralDir;
|
||||
vec3 originSpaceVert = regionRadius * (dirX * spriteVert.x + dirY * spriteVert.y + dirZ * spriteVert.z);
|
||||
|
||||
vec4 pos = vec4(proxyPosWorld.xyz + originSpaceVert, 1.0);
|
||||
varTexcoord = spriteVert.xyz;
|
||||
|
||||
// standard transform, bring proxy in view space
|
||||
// standard transform, bring pos in view space
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
vec4 proxyPosEye;
|
||||
<$transformModelToEyePos(cam, obj, pos, proxyPosEye)$>
|
||||
<$transformEyeToClipPos(cam, proxyPosEye, gl_Position)$>
|
||||
vec4 posEye;
|
||||
<$transformModelToEyePos(cam, obj, pos, posEye)$>
|
||||
vec3 tanEye;
|
||||
<$transformModelToEyeDir(cam, obj, originSpaceTan, tanEye)$>
|
||||
|
||||
lateralDir = normalize(cross(vec3(0.0, 0.0, 1.0), normalize(tanEye)));
|
||||
posEye.xyz += (0.05 * (regionID + 1)) * lateralDir;
|
||||
|
||||
|
||||
<$transformEyeToClipPos(cam, posEye, gl_Position)$>
|
||||
|
||||
varTexcoord = spriteVert.xyz;
|
||||
|
||||
|
||||
|
||||
// Convert region to color
|
||||
varColor = vec4(colorWheel(float(regionID) / 4.0), -1.0);
|
||||
|
|
Loading…
Reference in a new issue