Skip to content

Commit 86702bc

Browse files
authored
Merge pull request #591 from gkjohnson/pt-support-ies-textures
Fix support for ies textures
2 parents db75099 + 7116dba commit 86702bc

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/core/DynamicPathTracingSceneGenerator.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function getTextures( materials ) {
3131
function getLights( objects ) {
3232

3333
const lights = [];
34+
const iesSet = new Set();
3435
for ( let i = 0, l = objects.length; i < l; i ++ ) {
3536

3637
objects[ i ].traverse( c => {
@@ -46,6 +47,12 @@ function getLights( objects ) {
4647

4748
lights.push( c );
4849

50+
if ( c.iesTexture ) {
51+
52+
iesSet.add( c.iesTexture );
53+
54+
}
55+
4956
}
5057

5158
}
@@ -54,7 +61,15 @@ function getLights( objects ) {
5461

5562
}
5663

57-
return lights;
64+
const iesTextures = Array.from( iesSet ).sort( ( a, b ) => {
65+
66+
if ( a.uuid < b.uuid ) return 1;
67+
if ( a.uuid > b.uuid ) return - 1;
68+
return 0;
69+
70+
} );
71+
72+
return { lights, iesTextures };
5873

5974
}
6075

@@ -174,7 +189,7 @@ export class DynamicPathTracingSceneGenerator {
174189
const result = staticGeometryGenerator.generate( geometry );
175190
const materials = result.materials;
176191
const textures = getTextures( materials );
177-
const lights = getLights( objects );
192+
const { lights, iesTextures } = getLights( objects );
178193

179194
if ( result.changeType !== NO_CHANGE ) {
180195

@@ -223,6 +238,7 @@ export class DynamicPathTracingSceneGenerator {
223238
bvhChanged: result.changeType !== NO_CHANGE,
224239
bvh: this.bvh,
225240
lights,
241+
iesTextures,
226242
geometry,
227243
materials,
228244
textures,

src/core/WebGLPathTracer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export class WebGLPathTracer {
234234

235235
const {
236236
lights,
237+
iesTextures,
237238
materials,
238239
textures,
239240
geometry,
@@ -248,7 +249,8 @@ export class WebGLPathTracer {
248249
const textureSize = this.textureSize;
249250

250251
// update scene information
251-
material.lights.updateFrom( lights );
252+
material.lights.updateFrom( lights, iesTextures );
253+
material.iesProfiles.updateFrom( renderer, iesTextures );
252254
material.lightCount = lights.length;
253255
material.textures.setTextures( renderer, textureSize.x, textureSize.y, textures );
254256
material.materials.updateFrom( materials, textures );

0 commit comments

Comments
 (0)