Fix ShapeSDF in case no distortion map is given

This commit is contained in:
Edwin Jakobs
2020-04-28 16:36:38 +02:00
parent 0cbd504d3a
commit 69a0b0c0ce
2 changed files with 7 additions and 6 deletions

View File

@@ -39,7 +39,6 @@ fun main() {
} }
} }
extend { extend {
drawer.background(ColorRGBa.PINK) drawer.background(ColorRGBa.PINK)
fd.apply(emptyArray(), uvmap) fd.apply(emptyArray(), uvmap)

View File

@@ -14,10 +14,10 @@ class ShapeSDF : Filter(filterShaderFromUrl(resourceUrl("/shaders/gl3/shape-sdf.
private var segmentCount = 0 private var segmentCount = 0
@BooleanParameter("use UV map") @BooleanParameter("use UV map")
var useUV:Boolean by parameters var useUV: Boolean by parameters
@BooleanParameter("rectify distance") @BooleanParameter("rectify distance")
var rectify:Boolean by parameters var rectify: Boolean by parameters
init { init {
@@ -53,7 +53,7 @@ class ShapeSDF : Filter(filterShaderFromUrl(resourceUrl("/shaders/gl3/shape-sdf.
for (v in from) { for (v in from) {
fromWriter.write(v) fromWriter.write(v)
} }
fromShadow.upload(0, from.size*4*4) fromShadow.upload(0, from.size * 4 * 4)
val toShadow = toBuffer.shadow val toShadow = toBuffer.shadow
val toWriter = toShadow.writer() val toWriter = toShadow.writer()
@@ -61,7 +61,7 @@ class ShapeSDF : Filter(filterShaderFromUrl(resourceUrl("/shaders/gl3/shape-sdf.
for (v in to) { for (v in to) {
toWriter.write(v) toWriter.write(v)
} }
toShadow.upload(0, to.size*4*4) toShadow.upload(0, to.size * 4 * 4)
segmentCount = from.size segmentCount = from.size
} }
@@ -73,6 +73,8 @@ class ShapeSDF : Filter(filterShaderFromUrl(resourceUrl("/shaders/gl3/shape-sdf.
parameters["fromBuffer"] = fromBuffer parameters["fromBuffer"] = fromBuffer
parameters["toBuffer"] = toBuffer parameters["toBuffer"] = toBuffer
parameters["segmentCount"] = segmentCount parameters["segmentCount"] = segmentCount
super.apply(source, target) // -- bit of an hack
val effectiveSource = if (source.isNotEmpty()) source else target
super.apply(effectiveSource, target)
} }
} }