@@ -9,6 +9,9 @@ import {Div} from "./div/div";
99import { Project } from "./project/project" ;
1010import { Source } from "./source/source" ;
1111import { GPUAbstractRunner , RunnerType } from "../AbstractGPURunner" ;
12+ import { LightScene } from "./scene/scene" ;
13+ import { LightPropagation } from "../modules/light/propagation/light" ;
14+ import { MonteCarloPathTracing } from "../modules/light/monte_carlo_path_tracing/light" ;
1215
1316// Staggered Grid
1417/*
@@ -43,7 +46,9 @@ export class Fluid extends GPUAbstractRunner {
4346 render : Render ;
4447 poisson : Poisson ;
4548 div : Div ;
46- project : Project
49+ project : Project ;
50+ scene : LightScene ;
51+ light : LightPropagation ;
4752
4853 velocity : Texture ;
4954 density : Texture ;
@@ -80,6 +85,15 @@ export class Fluid extends GPUAbstractRunner {
8085 this . project = new Project ( this . poisson . pressurea , this . velocity , this . flags ) ;
8186 await this . project . Init ( ) ;
8287
88+ this . scene = new LightScene ( this . density )
89+ await this . scene . Init ( )
90+ /*
91+ this.light = new LightPropagation(this.scene.emitter)
92+ */
93+ this . light = new MonteCarloPathTracing ( this . scene . emitter , 20 )
94+ await this . light . Init ( )
95+
96+
8397 this . render = new Render ( this . density ) ;
8498 //this.render = new Render(this.div.div);
8599 //this.render = new Render(this.velocity);
@@ -108,6 +122,8 @@ export class Fluid extends GPUAbstractRunner {
108122 }
109123
110124 public async Destroy ( ) {
125+ await this . light . Destroy ( )
126+ await this . scene . Destroy ( )
111127 await this . project . Destroy ( )
112128 await this . poisson . Destroy ( )
113129 await this . div . Destroy ( )
@@ -121,28 +137,32 @@ export class Fluid extends GPUAbstractRunner {
121137
122138
123139 async Run ( ) {
124-
140+ this . light . Reset ( )
125141 GPU . device . queue . submit ( [
126142 this . source . GetCommandBuffer ( ) ,
127143 this . transport . GetCommandBuffer ( ) ,
128144 this . advect . GetCommandBuffer ( ) ,
129145 this . div . GetCommandBuffer ( ) ,
130146 this . poisson . GetCommandBuffer ( ) ,
131147 this . project . GetCommandBuffer ( ) ,
148+ this . scene . GetCommandBuffer ( ) ,
149+ //this.light.GetCommandBuffer(),
132150 ] )
133151 //await GPU.Render(this.transport.texturea);
134152 //await GPU.Render(this.transport.texturea);
135153 //await GPU.Render(this.poisson.pressurea);
136154 }
137155
138156 Render ( ) {
157+ //this.light.Render()
158+
139159 GPU . device . queue . submit ( [
140160 this . render . GetCommandBuffer ( )
141161 ] )
142162 }
143163
144164 async InitVelocity ( ) {
145- let vel = new Uint16Array ( this . width * this . height * 4 )
165+ let vel = new Uint16Array ( this . width * this . height * 4 )
146166/*
147167 for (let j = 0; j < this.height; j++)
148168 for (let i = 0; i < this.width; i++) {
0 commit comments