mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:10:49 +02:00
Representing the view spheres
This commit is contained in:
parent
7179a31d17
commit
660c4c30e9
6 changed files with 63 additions and 33 deletions
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
|
|
||||||
void GameSpaceToRender::configure(const Config& config) {
|
void GameSpaceToRender::configure(const Config& config) {
|
||||||
|
_freezeViews = config.freezeViews;
|
||||||
_showAllProxies = config.showProxies;
|
_showAllProxies = config.showProxies;
|
||||||
_showAllViews = config.showViews;
|
_showAllViews = config.showViews;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +39,7 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
|
||||||
auto visible = _showAllProxies || _showAllViews;
|
auto visible = _showAllProxies || _showAllViews;
|
||||||
auto showProxies = _showAllProxies;
|
auto showProxies = _showAllProxies;
|
||||||
auto showViews = _showAllViews;
|
auto showViews = _showAllViews;
|
||||||
|
auto freezeViews = _freezeViews;
|
||||||
|
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
auto scene = gameWorkloadContext->_scene;
|
auto scene = gameWorkloadContext->_scene;
|
||||||
|
@ -57,7 +59,9 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
|
||||||
space->copyProxyValues(proxies.data(), (uint32_t)proxies.size());
|
space->copyProxyValues(proxies.data(), (uint32_t)proxies.size());
|
||||||
|
|
||||||
std::vector<workload::Space::View> views(space->getNumViews());
|
std::vector<workload::Space::View> views(space->getNumViews());
|
||||||
space->copyViews(views);
|
if (!freezeViews) {
|
||||||
|
space->copyViews(views);
|
||||||
|
}
|
||||||
|
|
||||||
// Valid space, let's display its content
|
// Valid space, let's display its content
|
||||||
if (!render::Item::isValidID(_spaceRenderItemID)) {
|
if (!render::Item::isValidID(_spaceRenderItemID)) {
|
||||||
|
@ -68,12 +72,14 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
|
||||||
transaction.resetItem(_spaceRenderItemID, std::make_shared<GameWorkloadRenderItem::Payload>(renderItem));
|
transaction.resetItem(_spaceRenderItemID, std::make_shared<GameWorkloadRenderItem::Payload>(renderItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.updateItem<GameWorkloadRenderItem>(_spaceRenderItemID, [visible, showProxies, proxies, showViews, views](GameWorkloadRenderItem& item) {
|
transaction.updateItem<GameWorkloadRenderItem>(_spaceRenderItemID, [visible, showProxies, proxies, freezeViews, showViews, views](GameWorkloadRenderItem& item) {
|
||||||
item.setVisible(visible);
|
item.setVisible(visible);
|
||||||
item.showProxies(showProxies);
|
item.showProxies(showProxies);
|
||||||
item.setAllProxies(proxies);
|
item.setAllProxies(proxies);
|
||||||
item.showViews(showViews);
|
item.showViews(showViews);
|
||||||
item.setAllViews(views);
|
if (!freezeViews) {
|
||||||
|
item.setAllViews(views);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
|
@ -198,13 +204,6 @@ const gpu::PipelinePointer GameWorkloadRenderItem::getViewsPipeline() {
|
||||||
void GameWorkloadRenderItem::render(RenderArgs* args) {
|
void GameWorkloadRenderItem::render(RenderArgs* args) {
|
||||||
gpu::Batch& batch = *(args->_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());
|
batch.setModelTransform(Transform());
|
||||||
|
|
||||||
batch.setResourceBuffer(0, _allProxiesBuffer);
|
batch.setResourceBuffer(0, _allProxiesBuffer);
|
||||||
|
@ -214,16 +213,16 @@ void GameWorkloadRenderItem::render(RenderArgs* args) {
|
||||||
if (_showProxies) {
|
if (_showProxies) {
|
||||||
batch.setPipeline(getProxiesPipeline());
|
batch.setPipeline(getProxiesPipeline());
|
||||||
|
|
||||||
static const int NUM_VERTICES_PER_QUAD = 3;
|
static const int NUM_VERTICES_PER_PROXY = 3;
|
||||||
batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_QUAD * _numAllProxies, 0);
|
batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_PROXY * _numAllProxies, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show Views
|
// Show Views
|
||||||
if (_showViews) {
|
if (_showViews) {
|
||||||
batch.setPipeline(getViewsPipeline());
|
batch.setPipeline(getViewsPipeline());
|
||||||
|
|
||||||
static const int NUM_VERTICES_PER_QUAD = 3;
|
static const int NUM_VERTICES_PER_VIEW = 27;
|
||||||
batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_QUAD * 3 * _numAllViews, 0);
|
batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_VIEW * _numAllViews, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setResourceBuffer(0, nullptr);
|
batch.setResourceBuffer(0, nullptr);
|
||||||
|
|
|
@ -14,10 +14,12 @@
|
||||||
|
|
||||||
class GameSpaceToRenderConfig : public workload::Job::Config {
|
class GameSpaceToRenderConfig : public workload::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool freezeViews MEMBER freezeViews NOTIFY dirty)
|
||||||
Q_PROPERTY(bool showProxies MEMBER showProxies NOTIFY dirty)
|
Q_PROPERTY(bool showProxies MEMBER showProxies NOTIFY dirty)
|
||||||
Q_PROPERTY(bool showViews MEMBER showViews NOTIFY dirty)
|
Q_PROPERTY(bool showViews MEMBER showViews NOTIFY dirty)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
bool freezeViews{ false };
|
||||||
bool showProxies{ false };
|
bool showProxies{ false };
|
||||||
bool showViews{ false };
|
bool showViews{ false };
|
||||||
signals:
|
signals:
|
||||||
|
@ -39,6 +41,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
render::ItemID _spaceRenderItemID{ render::Item::INVALID_ITEM_ID };
|
render::ItemID _spaceRenderItemID{ render::Item::INVALID_ITEM_ID };
|
||||||
|
bool _freezeViews{ false };
|
||||||
bool _showAllProxies{ false };
|
bool _showAllProxies{ false };
|
||||||
bool _showAllViews{ false };
|
bool _showAllViews{ false };
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
<@include gpu/Paint.slh@>
|
<@include gpu/Paint.slh@>
|
||||||
|
|
||||||
in vec4 varColor;
|
in vec4 varColor;
|
||||||
in vec2 varTexcoord;
|
in vec3 varTexcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
float r = sqrt(dot(varTexcoord.xy,varTexcoord.xy));
|
float r = sqrt(dot(varTexcoord.xyz,varTexcoord.xyz));
|
||||||
float a = paintStripe(r * varColor.w, 0.0, 1.0 / varColor.w, 0.05 / varColor.w);
|
float a = paintStripe(r * varColor.w, 0.0, 1.0 / varColor.w, 0.05 / varColor.w);
|
||||||
if (a <= 0.1 || r > 1.1) {
|
if (a <= 0.1 || r > 1.1) {
|
||||||
discard;
|
discard;
|
||||||
|
|
|
@ -48,7 +48,7 @@ WorkloadProxy getWorkloadProxy(int i) {
|
||||||
|
|
||||||
|
|
||||||
out vec4 varColor;
|
out vec4 varColor;
|
||||||
out vec2 varTexcoord;
|
out vec3 varTexcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec4 UNIT_SPRITE[3] = vec4[3](
|
const vec4 UNIT_SPRITE[3] = vec4[3](
|
||||||
|
@ -80,7 +80,7 @@ void main(void) {
|
||||||
// vec3 dirY = normalize(cross(dirZ, vec3(1.0, 0.0, 0.0)));
|
// vec3 dirY = normalize(cross(dirZ, vec3(1.0, 0.0, 0.0)));
|
||||||
|
|
||||||
vec4 pos = vec4(proxyPosEye.xyz + proxy.sphere.w * ( dirX * spriteVert.x + dirY * spriteVert.y /* + dirZ * spriteVert.z*/), 1.0);
|
vec4 pos = vec4(proxyPosEye.xyz + proxy.sphere.w * ( dirX * spriteVert.x + dirY * spriteVert.y /* + dirZ * spriteVert.z*/), 1.0);
|
||||||
varTexcoord = spriteVert.xy;
|
varTexcoord = spriteVert.xyz;
|
||||||
<$transformEyeToClipPos(cam, pos, gl_Position)$>
|
<$transformEyeToClipPos(cam, pos, gl_Position)$>
|
||||||
|
|
||||||
// Convert region to color
|
// Convert region to color
|
||||||
|
|
|
@ -48,23 +48,37 @@ WorkloadView getWorkloadView(int i) {
|
||||||
|
|
||||||
|
|
||||||
out vec4 varColor;
|
out vec4 varColor;
|
||||||
out vec2 varTexcoord;
|
out vec3 varTexcoord;
|
||||||
|
|
||||||
|
const int NUM_VERTICES_PER_VIEW = 27;
|
||||||
|
const int NUM_REGIONS_PER_VIEW = 3;
|
||||||
|
const int NUM_VERTICES_PER_VIEW_REGION = NUM_VERTICES_PER_VIEW / NUM_REGIONS_PER_VIEW;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec4 UNIT_SPRITE[3] = vec4[3](
|
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),
|
||||||
|
|
||||||
|
vec4(-1.0, 0.0, -1.0, 1.0),
|
||||||
|
vec4(3.0, 0.0, -1.0, 1.0),
|
||||||
|
vec4(-1.0, 0.0, 3.0, 1.0),
|
||||||
|
|
||||||
|
vec4(0.0, -1.0, -1.0, 1.0),
|
||||||
|
vec4(0.0, 3.0, -1.0, 1.0),
|
||||||
|
vec4(0.0, -1.0, 3.0, 1.0)
|
||||||
);
|
);
|
||||||
const int UNIT_SPRITE_INDICES[3] = int[3](
|
const int UNIT_SPRITE_INDICES[NUM_VERTICES_PER_VIEW_REGION] = int[NUM_VERTICES_PER_VIEW_REGION](
|
||||||
0, 1, 2
|
0, 1, 2, 3, 4, 5, 6, 7, 8
|
||||||
);
|
);
|
||||||
|
|
||||||
int viewID = gl_VertexID / 9;
|
int viewID = gl_VertexID / NUM_VERTICES_PER_VIEW;
|
||||||
int reminder = gl_VertexID - viewID * 9;
|
int viewVertexID = gl_VertexID - viewID * NUM_VERTICES_PER_VIEW;
|
||||||
int regionID = reminder / 3;
|
|
||||||
reminder = reminder - regionID * 3;
|
int regionID = viewVertexID / NUM_VERTICES_PER_VIEW_REGION;
|
||||||
int vertexID = reminder;
|
int regionVertexID = viewVertexID - regionID * NUM_VERTICES_PER_VIEW_REGION;
|
||||||
|
|
||||||
|
int vertexID = regionVertexID;
|
||||||
|
|
||||||
vec4 spriteVert = UNIT_SPRITE[UNIT_SPRITE_INDICES[vertexID]];
|
vec4 spriteVert = UNIT_SPRITE[UNIT_SPRITE_INDICES[vertexID]];
|
||||||
|
|
||||||
|
@ -78,15 +92,23 @@ void main(void) {
|
||||||
<$transformModelToEyePos(cam, obj, proxyPosWorld, proxyPosEye)$>
|
<$transformModelToEyePos(cam, obj, proxyPosWorld, proxyPosEye)$>
|
||||||
|
|
||||||
// Define the billboarded space
|
// Define the billboarded space
|
||||||
vec3 dirZ = -normalize(proxyPosEye.xyz);
|
vec3 dirZ = vec3(0.0, 0.0, 1.0);
|
||||||
vec3 dirX = normalize(cross(vec3(0.0, 1.0, 0.0), dirZ));
|
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);
|
||||||
// vec3 dirY = normalize(cross(dirZ, vec3(1.0, 0.0, 0.0)));
|
|
||||||
|
|
||||||
|
/*normalize(cross(vec3(0.0, 1.0, 0.0), dirZ));
|
||||||
|
if (dot(proxyPosEye.xyz, proxyPosEye.xyz) > 0.01) {
|
||||||
|
dirZ = -normalize(proxyPosEye.xyz);
|
||||||
|
}
|
||||||
|
vec3 dirX = normalize(cross(vec3(0.0, 1.0, 0.0), dirZ));
|
||||||
|
vec3 dirY = normalize(cross(dirZ, dirX));
|
||||||
|
*/
|
||||||
float regionRadius = view.radiuses[regionID];
|
float regionRadius = view.radiuses[regionID];
|
||||||
|
|
||||||
vec4 pos = vec4(proxyPosEye.xyz + regionRadius * ( dirX * spriteVert.x + dirY * spriteVert.y /* + dirZ * spriteVert.z*/), 1.0);
|
vec3 originSpaceVert = dirY * (-0.02) + regionRadius * ( dirX * spriteVert.x + dirY * spriteVert.y + dirZ * spriteVert.z);
|
||||||
varTexcoord = spriteVert.xy;
|
|
||||||
|
vec4 pos = vec4(proxyPosEye.xyz + originSpaceVert, 1.0);
|
||||||
|
varTexcoord = spriteVert.xyz;
|
||||||
<$transformEyeToClipPos(cam, pos, gl_Position)$>
|
<$transformEyeToClipPos(cam, pos, gl_Position)$>
|
||||||
|
|
||||||
// Convert region to color
|
// Convert region to color
|
||||||
|
|
|
@ -33,6 +33,12 @@ Rectangle {
|
||||||
HifiControls.Label {
|
HifiControls.Label {
|
||||||
text: "Workload"
|
text: "Workload"
|
||||||
}
|
}
|
||||||
|
HifiControls.CheckBox {
|
||||||
|
boxSize: 20
|
||||||
|
text: "Freeze Views"
|
||||||
|
checked: workload.spaceToRender["freezeViews"]
|
||||||
|
onCheckedChanged: { workload.spaceToRender["freezeViews"] = checked }
|
||||||
|
}
|
||||||
Separator {}
|
Separator {}
|
||||||
HifiControls.Label {
|
HifiControls.Label {
|
||||||
text: "Display"
|
text: "Display"
|
||||||
|
|
Loading…
Reference in a new issue