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