Skip to content

Commit

Permalink
Dev (#32)
Browse files Browse the repository at this point in the history
* Intial Commit

* Render outline in all 3D views

* Fix: cross window highlighting

* Add: onClick parameter to drawSpecial

* Optimization: proper elem selection

* remove forgotten console.log

* Backup Changes

* Optimization: reduced the draw calls even further

* Feature: Implemented highly optimized & modular code for OutlinePass

* remove forgotten console.log

* Remove redundant OutlinePass.atts property

* Feature: secondary selection for OutlinePass(wip)

* Add some comments explaining how we pass objs to OutlinePass
  • Loading branch information
osschar authored and Axel-Naumann committed May 9, 2019
1 parent f7982b9 commit c73e677
Show file tree
Hide file tree
Showing 6 changed files with 1,899 additions and 14 deletions.
13 changes: 6 additions & 7 deletions js/scripts/JSRootGeoPainter.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,17 +851,13 @@
TGeoPainter.prototype.createSSAO = function() {
if (!this._webgl || this._ssaoPass) return;

// var renderPass = new THREE.RenderPass( this._scene, this._camera );

// this._depthRenderTarget = new THREE.WebGLRenderTarget( this._scene_width, this._scene_height, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter } );
// Setup SSAO pass
this._ssaoPass = new THREE.SSAOPass( this._scene, this._camera, this._scene_width, this._scene_height );
this._ssaoPass.kernelRadius = 16;
this._ssaoPass.renderToScreen = true;

// Add pass to effect composer
this._effectComposer = new THREE.EffectComposer( this._renderer );
//this._effectComposer.addPass( renderPass );
this._effectComposer.addPass( this._ssaoPass );
}

Expand Down Expand Up @@ -1922,6 +1918,9 @@
this._enableSSAO = this.options.ssao;
this._enableClipping = !this._enableSSAO;

this._effectComposer = new THREE.EffectComposer( this._renderer );
this._effectComposer.addPass( new THREE.RenderPass( this._scene, this._camera ) );

if (this._enableSSAO)
this.createSSAO();

Expand Down Expand Up @@ -3058,8 +3057,8 @@

this.TestCameraPosition(tmout === -1);

// do rendering, most consuming time
if (this._webgl && this._enableSSAO && this._ssaoPass) {
// its needed for outlinePass - do rendering, most consuming time
if (this._effectComposer.passes.length > 1 || this._webgl && this._enableSSAO && this._ssaoPass) {
this._effectComposer.render();
} else {
// this._renderer.logarithmicDepthBuffer = true;
Expand Down Expand Up @@ -3609,7 +3608,7 @@
this._camera.aspect = this._scene_width / this._scene_height;
this._camera.updateProjectionMatrix();
this._renderer.setSize( this._scene_width, this._scene_height, !this._fit_main_area );
if (this._ssaoPass) this._ssaoPass.setSize( this._scene_width, this._scene_height );
this._effectComposer.setSize( this._scene_width, this._scene_height );

if (!this.drawing_stage) this.Render3D();
}
Expand Down
8 changes: 4 additions & 4 deletions tutorials/eve7/event_demo.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ REX::REvePointSet *getPointSet(int npoints = 2, float s=2, int color=28)
ps->SetNextPoint(r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));

ps->SetMarkerColor(color);
ps->SetMarkerSize(3+r.Uniform(1, 2));
ps->SetMarkerSize(3+r.Uniform(1, 7));
ps->SetMarkerStyle(4);
return ps;
}
Expand All @@ -71,11 +71,11 @@ void addPoints()
auto ps1 = getPointSet(20, 100);
ps1->SetName("Points_1");
pntHolder->AddElement(ps1);
/*

auto ps2 = getPointSet(10, 200, 4);
ps2->SetElementName("Points_2");
ps2->SetName("Points_2");
pntHolder->AddElement(ps2);
*/

event->AddElement(pntHolder);
}

Expand Down
25 changes: 23 additions & 2 deletions ui5/eve7/controller/GL.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sap.ui.define([
var pthis = this;

// one only can load EveScene after geometry painter
sap.ui.define(['rootui5/eve7/lib/EveScene'], function (_EveScene) {
sap.ui.define(['rootui5/eve7/lib/EveScene', 'rootui5/eve7/lib/OutlinePass', 'rootui5/eve7/lib/FXAAShader'], function (_EveScene) {
EveScene = _EveScene;
pthis._load_scripts = true;
pthis.checkViewReady();
Expand Down Expand Up @@ -325,6 +325,25 @@ sap.ui.define([
// this.geo_painter._highlight_handlers = [ this ]; // register ourself for highlight handling
this.last_highlight = null;

this.composer = this.geo_painter._effectComposer;
let width = this.geo_painter._scene_width;
let height = this.geo_painter._scene_height;

this.outlinePass = new THREE.OutlinePass( new THREE.Vector2( width, height ), this.geo_painter._scene, this.geo_painter._camera );
this.outlinePass.edgeStrength = 7.5;
this.outlinePass.edgeGlow = 0.5;
this.outlinePass.edgeThickness = 1.0;
this.outlinePass.usePatternTexture = false;
this.outlinePass.downSampleRatio = 2;
this.outlinePass.visibleEdgeColor.set('#dd1111');
this.outlinePass.hiddenEdgeColor.set('#1111dd');
this.composer.addPass( this.outlinePass );

this.effectFXAA = new THREE.ShaderPass( THREE.FXAAShader );
this.effectFXAA.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height );
this.effectFXAA.renderToScreen = true;
this.composer.addPass( this.effectFXAA );

// create only when geo painter is ready
this.createScenes();
this.redrawScenes();
Expand All @@ -343,8 +362,10 @@ sap.ui.define([

// TODO: should be specified somehow in XML file
this.getView().$().css("overflow", "hidden").css("width", "100%").css("height", "100%");
if (this.geo_painter)
if (this.geo_painter){
this.geo_painter.CheckResize();
this.effectFXAA.uniforms[ 'resolution' ].value.set( 1 / this.geo_painter._scene_width, 1 / this.geo_painter._scene_height );
}
}

});
Expand Down
32 changes: 31 additions & 1 deletion ui5/eve7/lib/EveScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ sap.ui.define([
if (ctrl.separateDraw)
{
var p2 = "s", p1 = "h";
// swap h1-h2
if (!prefer_highlight) { var h = h1; h1 = h2; h2 = h; p2 = "h"; p1 = "s"; }
if (ctrl.drawSpecial(h2 ? h2.col : null, h2 ? h2.indx : undefined, p2)) did_change = true;
if (ctrl.drawSpecial(h1 ? h1.col : null, h1 ? h1.indx : undefined, p1)) did_change = true;
Expand All @@ -418,8 +419,37 @@ sap.ui.define([
did_change = ctrl.drawSpecial(h ? h.col : null, h ? h.indx : undefined);
}

if (did_change && this.viewer)
if (did_change && this.viewer){
this.viewer.render();
if(!prefer_highlight){
if(!this.selected[mstrid]){
// delete if its not selected anymore?
delete this.viewer.outlinePass.id2obj_map[mstrid];
} else {
// is secondary selection
let sec_sel = this.selected[mstrid].indx;

// if its not secondary selection pass the object
if(!sec_sel)
this.viewer.outlinePass.id2obj_map[mstrid] = obj3d;
// if its secondary selection pass all the new objects returned by 'drawSpecial'
else {
this.viewer.outlinePass.id2obj_map[mstrid] = []; // reset
if(false){
if(obj3d.sl_special) this.viewer.outlinePass.id2obj_map[mstrid].push(obj3d.sl_special);
if(obj3d.sm_special) this.viewer.outlinePass.id2obj_map[mstrid].push(obj3d.sm_special);
} else {
for(const child of obj3d.children){
if(child.jsroot_special)
this.viewer.outlinePass.id2obj_map[mstrid].push(child);
}
}
// print the new elements
console.log(this.viewer.outlinePass.id2obj_map[mstrid]);
}
}
}
}

return did_change;
}
Expand Down
Loading

0 comments on commit c73e677

Please sign in to comment.