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
|
//! Render the point cloud with a color ramp
|
||||||
ColorRamp,
|
ColorRamp,
|
||||||
//! Render the RGB colors of the point cloud
|
//! Render the RGB colors of the point cloud
|
||||||
RgbRendering
|
RgbRendering,
|
||||||
|
//! Render the point cloud with classified colors
|
||||||
|
Classification
|
||||||
};
|
};
|
||||||
|
|
||||||
QgsPointCloud3DSymbol();
|
QgsPointCloud3DSymbol();
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
uniform bool triangulate;
|
uniform bool triangulate;
|
||||||
|
|
||||||
in float parameter;
|
in float parameter;
|
||||||
|
flat in int classParameter;
|
||||||
|
|
||||||
in vec3 pointColor;
|
in vec3 pointColor;
|
||||||
in vec3 worldPosition; //used when points are triangulated
|
in vec3 worldPosition; //used when points are triangulated
|
||||||
in vec3 vertNorm; //used when points are triangulated
|
in vec3 vertNorm; //used when points are triangulated
|
||||||
out vec4 color;
|
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;
|
uniform int u_renderingStyle;
|
||||||
// Sets the unique mesh color
|
// Sets the unique mesh color
|
||||||
uniform vec3 u_singleColor;
|
uniform vec3 u_singleColor;
|
||||||
@ -86,12 +87,18 @@ vec4 exactColorRamp()
|
|||||||
vec4 colorRampLine = texelFetch( u_colorRampTexture, i, 0 );
|
vec4 colorRampLine = texelFetch( u_colorRampTexture, i, 0 );
|
||||||
vec3 color=colorRampLine.yzw;
|
vec3 color=colorRampLine.yzw;
|
||||||
float value=colorRampLine.x;
|
float value=colorRampLine.x;
|
||||||
if ( abs( parameter - value ) < 0.01 )
|
if ( abs( float(parameter) - value ) < 0.01 )
|
||||||
return vec4( color, 1.0f );
|
return vec4( color, 1.0f );
|
||||||
}
|
}
|
||||||
return vec4(0.0, 0.0, 0.0, 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()
|
vec4 colorRamp()
|
||||||
{
|
{
|
||||||
if (u_colorRampCount<=0)
|
if (u_colorRampCount<=0)
|
||||||
@ -130,6 +137,9 @@ void main(void)
|
|||||||
case 3: // RGB
|
case 3: // RGB
|
||||||
color = vec4(pointColor, 1.0f);
|
color = vec4(pointColor, 1.0f);
|
||||||
break;
|
break;
|
||||||
|
case 4: // classification
|
||||||
|
color = classification();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply light
|
//Apply light
|
||||||
@ -138,7 +148,7 @@ void main(void)
|
|||||||
float ambianceFactor=0.15;
|
float ambianceFactor=0.15;
|
||||||
vec3 diffuseColor;
|
vec3 diffuseColor;
|
||||||
adModel(worldPosition, vertNorm, 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
|
// used parameter to choose point cloud points color: 0 for height, 1 for classID
|
||||||
uniform int u_renderingParameter;
|
uniform int u_renderingParameter;
|
||||||
|
|
||||||
|
uniform int u_renderingStyle;
|
||||||
|
|
||||||
in vec3 vertexPosition;
|
in vec3 vertexPosition;
|
||||||
in float vertexParameter;
|
in float vertexParameter;
|
||||||
in vec3 vertexColor;
|
in vec3 vertexColor;
|
||||||
in vec3 vertexNormal; //used when points are triangulated
|
in vec3 vertexNormal; //used when points are triangulated
|
||||||
|
|
||||||
out float parameter;
|
out float parameter;
|
||||||
|
flat out int classParameter;
|
||||||
out vec3 pointColor;
|
out vec3 pointColor;
|
||||||
out vec3 worldPosition; //used when points are triangulated
|
out vec3 worldPosition; //used when points are triangulated
|
||||||
out vec3 vertNorm; //used when points are triangulated
|
out vec3 vertNorm; //used when points are triangulated
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
//if (abs(cls-5) < 0.1)
|
gl_Position = modelViewProjection * vec4(vertexPosition, 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 = u_pointSize;
|
||||||
//gl_PointSize = viewportMatrix[1][1] * projectionMatrix[1][1] * 1.0 / gl_Position.w;
|
|
||||||
//gl_PointSize = 100.0;
|
|
||||||
|
|
||||||
worldPosition = vec3 (modelMatrix * vec4 (vertexPosition,1));
|
worldPosition = vec3 (modelMatrix * vec4 (vertexPosition,1));
|
||||||
vertNorm = vertexNormal;
|
vertNorm = vertexNormal;
|
||||||
parameter = vertexParameter;
|
|
||||||
pointColor = vertexColor;
|
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 )
|
void QgsClassificationPointCloud3DSymbol::fillMaterial( Qt3DRender::QMaterial *mat )
|
||||||
{
|
{
|
||||||
const QgsColorRampShader mColorRampShader = colorRampShader();
|
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 );
|
mat->addParameter( renderingStyle );
|
||||||
Qt3DRender::QParameter *pointSizeParameter = new Qt3DRender::QParameter( "u_pointSize", QVariant::fromValue( mPointSize ) );
|
Qt3DRender::QParameter *pointSizeParameter = new Qt3DRender::QParameter( "u_pointSize", QVariant::fromValue( mPointSize ) );
|
||||||
mat->addParameter( pointSizeParameter );
|
mat->addParameter( pointSizeParameter );
|
||||||
|
@ -51,7 +51,9 @@ class _3D_EXPORT QgsPointCloud3DSymbol : public QgsAbstract3DSymbol SIP_ABSTRACT
|
|||||||
//! Render the point cloud with a color ramp
|
//! Render the point cloud with a color ramp
|
||||||
ColorRamp,
|
ColorRamp,
|
||||||
//! Render the RGB colors of the point cloud
|
//! Render the RGB colors of the point cloud
|
||||||
RgbRendering
|
RgbRendering,
|
||||||
|
//! Render the point cloud with classified colors
|
||||||
|
Classification
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Constructor for QgsPointCloud3DSymbol
|
//! Constructor for QgsPointCloud3DSymbol
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "qgs3dsymbolregistry.h"
|
#include "qgs3dsymbolregistry.h"
|
||||||
#include "qgspointcloudattribute.h"
|
#include "qgspointcloudattribute.h"
|
||||||
#include "qgspointcloudrequest.h"
|
#include "qgspointcloudrequest.h"
|
||||||
|
#include "qgscolorramptexture.h"
|
||||||
#include "qgs3dmapsettings.h"
|
#include "qgs3dmapsettings.h"
|
||||||
#include "qgspointcloudindex.h"
|
#include "qgspointcloudindex.h"
|
||||||
#include "qgspointcloudblockrequest.h"
|
#include "qgspointcloudblockrequest.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user