mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
add direction in shader for classification
This commit is contained in:
parent
40df5696b5
commit
bfbc62d613
@ -37,7 +37,9 @@ class QgsPointCloud3DSymbol : QgsAbstract3DSymbol /Abstract/
|
||||
//! Render the point cloud with a color ramp
|
||||
ColorRamp,
|
||||
//! Render the RGB colors of the point cloud
|
||||
RgbRendering
|
||||
RgbRendering,
|
||||
//! Render the point cloud with classified colors
|
||||
Classification
|
||||
};
|
||||
|
||||
QgsPointCloud3DSymbol();
|
||||
|
@ -3,13 +3,14 @@
|
||||
uniform bool triangulate;
|
||||
|
||||
in float parameter;
|
||||
flat in int classParameter;
|
||||
|
||||
in vec3 pointColor;
|
||||
in vec3 worldPosition; //used when points are triangulated
|
||||
in vec3 vertNorm; //used when points are triangulated
|
||||
out vec4 color;
|
||||
|
||||
// Sets the redering style, 0: unique color, 1: color ramp shader of terrain, 2: color ramp shader of 2D rendering
|
||||
// Sets the redering style, 0: unique color, 1: color ramp shader of terrain, 2: color ramp shader of 2D rendering, 3 : RGB, 4 : Classification
|
||||
uniform int u_renderingStyle;
|
||||
// Sets the unique mesh color
|
||||
uniform vec3 u_singleColor;
|
||||
@ -86,12 +87,18 @@ vec4 exactColorRamp()
|
||||
vec4 colorRampLine = texelFetch( u_colorRampTexture, i, 0 );
|
||||
vec3 color=colorRampLine.yzw;
|
||||
float value=colorRampLine.x;
|
||||
if ( abs( parameter - value ) < 0.01 )
|
||||
if ( abs( float(parameter) - value ) < 0.01 )
|
||||
return vec4( color, 1.0f );
|
||||
}
|
||||
return vec4(0.0, 0.0, 0.0, 1.0f);
|
||||
}
|
||||
|
||||
vec4 classification()
|
||||
{
|
||||
vec4 colorRampLine = texelFetch( u_colorRampTexture, classParameter - 1, 0 );
|
||||
return vec4(colorRampLine.yzw,1.0);
|
||||
}
|
||||
|
||||
vec4 colorRamp()
|
||||
{
|
||||
if (u_colorRampCount<=0)
|
||||
@ -130,6 +137,9 @@ void main(void)
|
||||
case 3: // RGB
|
||||
color = vec4(pointColor, 1.0f);
|
||||
break;
|
||||
case 4: // classification
|
||||
color = classification();
|
||||
break;
|
||||
}
|
||||
|
||||
//Apply light
|
||||
@ -138,7 +148,7 @@ void main(void)
|
||||
float ambianceFactor=0.15;
|
||||
vec3 diffuseColor;
|
||||
adModel(worldPosition, vertNorm, diffuseColor);
|
||||
color = vec4( color.xyz * (diffuseColor+ambianceFactor), 1 );
|
||||
color =vec4( color.xyz * (diffuseColor+ambianceFactor), 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,29 +9,41 @@ uniform float u_pointSize;
|
||||
// used parameter to choose point cloud points color: 0 for height, 1 for classID
|
||||
uniform int u_renderingParameter;
|
||||
|
||||
uniform int u_renderingStyle;
|
||||
|
||||
in vec3 vertexPosition;
|
||||
in float vertexParameter;
|
||||
in vec3 vertexColor;
|
||||
in vec3 vertexNormal; //used when points are triangulated
|
||||
|
||||
out float parameter;
|
||||
flat out int classParameter;
|
||||
out vec3 pointColor;
|
||||
out vec3 worldPosition; //used when points are triangulated
|
||||
out vec3 vertNorm; //used when points are triangulated
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//if (abs(cls-5) < 0.1)
|
||||
// gl_Position = vec4(0,0,0,0);
|
||||
//else
|
||||
gl_Position = modelViewProjection * vec4(vertexPosition, 1);
|
||||
|
||||
gl_PointSize = u_pointSize; //5 + vertexPosition.x * 10 + vertexPosition.y * 10;
|
||||
//gl_PointSize = viewportMatrix[1][1] * projectionMatrix[1][1] * 1.0 / gl_Position.w;
|
||||
//gl_PointSize = 100.0;
|
||||
gl_PointSize = u_pointSize;
|
||||
|
||||
worldPosition = vec3 (modelMatrix * vec4 (vertexPosition,1));
|
||||
vertNorm = vertexNormal;
|
||||
|
||||
switch (u_renderingStyle)
|
||||
{
|
||||
case 0: // no rendering
|
||||
case 1: // single color
|
||||
break;
|
||||
case 2: // color ramp
|
||||
parameter = vertexParameter;
|
||||
break;
|
||||
case 3: // RGB
|
||||
pointColor = vertexColor;
|
||||
break;
|
||||
case 4: // classification
|
||||
classParameter = int(vertexParameter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ QgsColorRampShader QgsClassificationPointCloud3DSymbol::colorRampShader() const
|
||||
void QgsClassificationPointCloud3DSymbol::fillMaterial( Qt3DRender::QMaterial *mat )
|
||||
{
|
||||
const QgsColorRampShader mColorRampShader = colorRampShader();
|
||||
Qt3DRender::QParameter *renderingStyle = new Qt3DRender::QParameter( "u_renderingStyle", QgsPointCloud3DSymbol::ColorRamp );
|
||||
Qt3DRender::QParameter *renderingStyle = new Qt3DRender::QParameter( "u_renderingStyle", QgsPointCloud3DSymbol::Classification );
|
||||
mat->addParameter( renderingStyle );
|
||||
Qt3DRender::QParameter *pointSizeParameter = new Qt3DRender::QParameter( "u_pointSize", QVariant::fromValue( mPointSize ) );
|
||||
mat->addParameter( pointSizeParameter );
|
||||
|
@ -51,7 +51,9 @@ class _3D_EXPORT QgsPointCloud3DSymbol : public QgsAbstract3DSymbol SIP_ABSTRACT
|
||||
//! Render the point cloud with a color ramp
|
||||
ColorRamp,
|
||||
//! Render the RGB colors of the point cloud
|
||||
RgbRendering
|
||||
RgbRendering,
|
||||
//! Render the point cloud with classified colors
|
||||
Classification
|
||||
};
|
||||
|
||||
//! Constructor for QgsPointCloud3DSymbol
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qgs3dsymbolregistry.h"
|
||||
#include "qgspointcloudattribute.h"
|
||||
#include "qgspointcloudrequest.h"
|
||||
#include "qgscolorramptexture.h"
|
||||
#include "qgs3dmapsettings.h"
|
||||
#include "qgspointcloudindex.h"
|
||||
#include "qgspointcloudblockrequest.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user