after12am / eisenscript

A programming language designed for generating awesome structures.
https://after12am.github.io/eisenscript-docs/
MIT License
46 stars 5 forks source link

CSG and render times #52

Closed kronpano closed 3 years ago

kronpano commented 7 years ago

This is not an issue but something I think is really good, interesting and to build on.

I used csg.js and ThreeCSG.js to use CSG to create my own frame.

This is what I used to create my frame: (Take a normal box and take away 3 boxes in the 3 axes that are a bit smaller in two dimensions)

var fbox = new ThreeBSP( new THREE.Mesh( new THREE.BoxGeometry( 1, 1, 1 ))); var cutframe1 =new ThreeBSP(new THREE.Mesh(new THREE.BoxGeometry(1, 0.8, 0.8))); var cutframe2 =new ThreeBSP(new THREE.Mesh(new THREE.BoxGeometry(0.8,1 , 0.8))); var cutframe3 =new ThreeBSP(new THREE.Mesh(new THREE.BoxGeometry(0.8, 0.8, 1))); var csg_result = fbox.subtract(cutframe1).subtract(cutframe2).subtract(cutframe3); Geometry.CSG = csg_result.toGeometry();

I also added a primitive called csg so I can use it from the script.

Now for the really positive part of using a CSG generated object:

Times using regular box: objects: 271 render time: 24421ms (24s)

times using CSG frame: objects: 271 render time: 24478ms (24s)

time using Structure synth frame (12 boxes to make a frame - see script below) objects: 3241 render time: 286136ms (about 5 minutes)

This is - I think - brilliant !!!!! A object created using CSG seems to add nearly no time to the rendering !!! That means offering CSG elements (or letting the user generate their own ones) makes it possible to render structures containing more "complex" primitives without extending render times.

I LIKE THAT A LOT!!!!

script used to test:

set maxobjects 4000

6 * {rz 60 } tower

//tower rule tower md 16 > end{ {s 5}csg //frame {y 4.5 rx 10 s 0.9 } tower }

rule end md 28{ {s 5}csg //frame {y 4.5 rx -2 s 1 } end }

// strucsynth frame rule frame{ twotri {z 4.5 x 4.5 ry 180}twotri }

rule twotri{ tri {y 4.5 x 4.5 rz -90 rx 90}tri } rule tri{ {z 2.25 s 0.5 0.5 5}box {x 2.25 s 5 0.5 0.5}box {y 2.25 s 0.5 5 0.5}box }

// csg frame {s 1}csg

after12am commented 4 years ago

@kronpano Performance tuning (#85) was done. Is there still anything I can do?

https://after12am.github.io/eisenscript-editor/#B/fY/NDsIgEITvPMWcTWyhkcZefBet+BdrE8AIJby7C1TtyQMBZuebzRhlMezdeLip3hpsOOesxQpBT2g5Iuz4UprVdbn1866KhOEI0WIH9TgGFgxk7M2ZjCe9HxQLHptKQjsIDgNedd+sWFKISxnN9i+9bogWxJKdyLqGsfrZG/+wFxRzTsvPwOxrtPrKwpR5V1I8xJbHeTRvLz8Cktsv3RPWHU+rO2IWQHJTblM1MheS+ch4GB0L7qPLz6Tofun/6bkIFZ4bUH+R+5dVaRBY9r0B

after12am commented 3 years ago

Because tuning was done, I close this issue.