Skip to content

Commit

Permalink
TSL: Analyze lights and auto generate cache (#28509)
Browse files Browse the repository at this point in the history
* analyze lights, auto generate cache

* new cache for new function generator
  • Loading branch information
sunag authored May 28, 2024
1 parent 4c6d0c4 commit d2a7e15
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/jsm/nodes/core/ContextNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class ContextNode extends Node {

}

analyze( builder ) {

this.node.build( builder );

}

setup( builder ) {

const previousContext = builder.getContext();
Expand Down
7 changes: 7 additions & 0 deletions examples/jsm/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,18 @@ class NodeBuilder {

const previousFlow = this.flow;
const previousVars = this.vars;
const previousCache = this.cache;
const previousBuildStage = this.buildStage;
const previousStack = this.stack;

const flow = {
code: ''
};

this.flow = flow;
this.vars = {};
this.cache = new NodeCache();
this.stack = stack();

for ( const buildStage of defaultBuildStages ) {

Expand All @@ -932,6 +936,9 @@ class NodeBuilder {

this.flow = previousFlow;
this.vars = previousVars;
this.cache = previousCache;
this.stack = previousStack;

this.setBuildStage( previousBuildStage );

return flow;
Expand Down
17 changes: 17 additions & 0 deletions examples/jsm/nodes/lighting/LightsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ class LightsNode extends Node {

}

analyze( builder ) {

const properties = builder.getDataFromNode( this );

for ( const node of properties.nodes ) {

node.build( builder );

}

}

setup( builder ) {

const context = builder.context;
Expand All @@ -70,6 +82,11 @@ class LightsNode extends Node {

//

const properties = builder.getDataFromNode( this );
properties.nodes = stack.nodes;

//

lightingModel.start( context, stack, builder );

// lights
Expand Down

0 comments on commit d2a7e15

Please sign in to comment.