Skip to content
Snippets Groups Projects
Commit ade1e74c authored by Alexander Rose's avatar Alexander Rose
Browse files

added sizeFactor to points, lines, spheres renderables

parent 5f8c5ce6
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,7 @@ export namespace Lines {
export const Params = {
...Geometry.Params,
sizeFactor: PD.Numeric(1, { min: 0, max: 10, step: 0.1 }),
lineSizeAttenuation: PD.Boolean(false),
}
export type Params = typeof Params
......@@ -123,6 +124,7 @@ export namespace Lines {
...transform,
...Geometry.createValues(props, counts),
uSizeFactor: ValueCell.create(props.sizeFactor),
dLineSizeAttenuation: ValueCell.create(props.lineSizeAttenuation),
dDoubleSided: ValueCell.create(true),
dFlipSided: ValueCell.create(false),
......@@ -131,6 +133,7 @@ export namespace Lines {
export function updateValues(values: LinesValues, props: PD.Values<Params>) {
Geometry.updateValues(values, props)
ValueCell.updateIfChanged(values.uSizeFactor, props.sizeFactor)
ValueCell.updateIfChanged(values.dLineSizeAttenuation, props.lineSizeAttenuation)
}
......
......@@ -57,6 +57,7 @@ export namespace Points {
export const Params = {
...Geometry.Params,
sizeFactor: PD.Numeric(1, { min: 0, max: 10, step: 0.1 }),
pointSizeAttenuation: PD.Boolean(false),
pointFilledCircle: PD.Boolean(false),
pointEdgeBleach: PD.Numeric(0.2, { min: 0, max: 1, step: 0.05 }),
......@@ -87,6 +88,7 @@ export namespace Points {
...transform,
...Geometry.createValues(props, counts),
uSizeFactor: ValueCell.create(props.sizeFactor),
dPointSizeAttenuation: ValueCell.create(props.pointSizeAttenuation),
dPointFilledCircle: ValueCell.create(props.pointFilledCircle),
uPointEdgeBleach: ValueCell.create(props.pointEdgeBleach),
......@@ -95,6 +97,7 @@ export namespace Points {
export function updateValues(values: PointsValues, props: PD.Values<Params>) {
Geometry.updateValues(values, props)
ValueCell.updateIfChanged(values.uSizeFactor, props.sizeFactor)
ValueCell.updateIfChanged(values.dPointSizeAttenuation, props.pointSizeAttenuation)
ValueCell.updateIfChanged(values.dPointFilledCircle, props.pointFilledCircle)
ValueCell.updateIfChanged(values.uPointEdgeBleach, props.pointEdgeBleach)
......
......@@ -53,6 +53,7 @@ export namespace Spheres {
export const Params = {
...Geometry.Params,
sizeFactor: PD.Numeric(1, { min: 0, max: 10, step: 0.1 }),
doubleSided: PD.Boolean(false),
}
export type Params = typeof Params
......@@ -90,6 +91,7 @@ export namespace Spheres {
padding: ValueCell.create(padding),
...Geometry.createValues(props, counts),
uSizeFactor: ValueCell.create(props.sizeFactor),
dDoubleSided: ValueCell.create(props.doubleSided),
}
}
......@@ -125,12 +127,15 @@ export namespace Spheres {
padding: ValueCell.create(sizeValue),
...Geometry.createValues(p, counts),
uSizeFactor: ValueCell.create(p.sizeFactor),
dDoubleSided: ValueCell.create(p.doubleSided),
}
}
export function updateValues(values: SpheresValues, props: PD.Values<Params>) {
Geometry.updateValues(values, props)
ValueCell.updateIfChanged(values.uSizeFactor, props.sizeFactor)
ValueCell.updateIfChanged(values.dDoubleSided, props.doubleSided)
}
export function updateBoundingSphere(values: SpheresValues, spheres: Spheres) {
......
......@@ -82,6 +82,7 @@ function createPoints() {
boundingSphere,
invariantBoundingSphere,
uSizeFactor: ValueCell.create(1),
dPointSizeAttenuation: ValueCell.create(true),
dPointFilledCircle: ValueCell.create(false),
uPointEdgeBleach: ValueCell.create(0.5),
......
......@@ -180,6 +180,7 @@ export const SizeSchema = {
uSizeTexDim: UniformSpec('v2'),
tSize: TextureSpec('image-uint8', 'alpha', 'ubyte', 'nearest'),
dSizeType: DefineSpec('string', ['uniform', 'attribute', 'instance', 'group', 'group_instance']),
uSizeFactor: UniformSpec('f'),
}
export type SizeSchema = typeof SizeSchema
export type SizeValues = Values<SizeSchema>
......
......@@ -12,4 +12,6 @@
#if defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)
size = decodeFloatLog(size);
#endif
\ No newline at end of file
#endif
size *= uSizeFactor;
\ No newline at end of file
......@@ -6,4 +6,6 @@
uniform vec2 uSizeTexDim;
uniform sampler2D tSize;
#pragma glslify: decodeFloatLog = require(../utils/decode-float-log.glsl)
#endif
\ No newline at end of file
#endif
uniform float uSizeFactor;
\ No newline at end of file
......@@ -11,20 +11,11 @@ precision highp int;
#pragma glslify: import('./chunks/common-vert-params.glsl')
#pragma glslify: import('./chunks/color-vert-params.glsl')
#pragma glslify: import('./chunks/size-vert-params.glsl')
uniform float uPixelRatio;
uniform float uViewportHeight;
#if defined(dSizeType_uniform)
uniform float uSize;
#elif defined(dSizeType_attribute)
attribute float aSize;
#elif defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)
varying vec4 vSize;
uniform vec2 uSizeTexDim;
uniform sampler2D tSize;
#endif
attribute vec3 aPosition;
attribute mat4 aTransform;
attribute float aInstance;
......@@ -46,19 +37,8 @@ void trimSegment(const in vec4 start, inout vec4 end) {
void main(){
#pragma glslify: import('./chunks/assign-color-varying.glsl')
// TODO move to chunk (also in point.vert)
#if defined(dSizeType_uniform)
float size = uSize;
#elif defined(dSizeType_attribute)
float size = aSize;
#elif defined(dSizeType_instance)
float size = readFromTexture(tSize, aInstance, uSizeTexDim).r;
#elif defined(dSizeType_group)
float size = readFromTexture(tSize, aGroup, uSizeTexDim).r;
#elif defined(dSizeType_groupInstance)
float size = readFromTexture(tSize, aInstance * float(uGroupCount) + aGroup, uSizeTexDim).r;
#endif
#pragma glslify: import('./chunks/assign-marker-varying.glsl')
#pragma glslify: import('./chunks/assign-size.glsl')
mat4 modelView = uView * uModel * aTransform;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment