Skip to content

Commit 445dbc5

Browse files
raytranukwilleastcottslimbuck
authored
Fix Area Lights and Half angle fresnel changes (playcanvas#3190)
* fix area lights * remove whitespace Co-authored-by: Will Eastcott <will@playcanvas.com> Co-authored-by: Donovan Hutchence <slimbuck7@gmail.com>
1 parent d58f672 commit 445dbc5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/graphics/program-lib/chunks/ltc.frag

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,12 @@ float calcRectLightSpecular(vec3 tNormalW, vec2 uv) {
407407
return LTC_EvaluateRect( tNormalW, dViewDirW, vPositionW, mInv, dLTCCoords );
408408
}
409409

410-
float getRectLightSpecular() {
410+
vec3 getRectLightSpecular() {
411411
return dLightFresnel * calcRectLightSpecular(dNormalW, dLTCUV);
412412
}
413413

414414
#ifdef CLEARCOAT
415-
float getRectLightSpecularCC() {
415+
vec3 getRectLightSpecularCC() {
416416
return ccLightFresnel * calcRectLightSpecular(ccNormalW, ccLTCUV);
417417
}
418418
#endif
@@ -422,22 +422,22 @@ float calcDiskLightSpecular(vec3 tNormalW, vec2 uv) {
422422
return LTC_EvaluateDisk( tNormalW, dViewDirW, vPositionW, mInv, dLTCCoords );
423423
}
424424

425-
float getDiskLightSpecular() {
425+
vec3 getDiskLightSpecular() {
426426
return dLightFresnel * calcDiskLightSpecular(dNormalW, dLTCUV);
427427
}
428428

429429
#ifdef CLEARCOAT
430-
float getDiskLightSpecularCC() {
430+
vec3 getDiskLightSpecularCC() {
431431
return ccLightFresnel * calcDiskLightSpecular(ccNormalW, ccLTCUV);
432432
}
433433
#endif
434434

435-
float getSphereLightSpecular() {
435+
vec3 getSphereLightSpecular() {
436436
return dLightFresnel * calcDiskLightSpecular(dNormalW, dLTCUV);
437437
}
438438

439439
#ifdef CLEARCOAT
440-
float getSphereLightSpecularCC() {
440+
vec3 getSphereLightSpecularCC() {
441441
return ccLightFresnel * calcDiskLightSpecular(ccNormalW, ccLTCUV);
442442
}
443443
#endif

src/graphics/program-lib/programs/standard.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,15 +1279,16 @@ var standard = {
12791279

12801280
if (lighting) {
12811281
code += chunks.lightDiffuseLambertPS;
1282+
1283+
// used for energy conservation and to modulate specular with half-angle fresnel
1284+
code += "vec3 dLightFresnel;\n";
1285+
code += "vec3 ccLightFresnel;\n\n";
1286+
12821287
if (hasAreaLights) code += chunks.ltc;
12831288
}
12841289
var useOldAmbient = false;
12851290
if (options.useSpecular) {
12861291
if (lighting) {
1287-
// used for energy conservation and to modulate specular with half-angle fresnel
1288-
code += "vec3 dLightFresnel;\n";
1289-
code += "vec3 ccLightFresnel;\n\n";
1290-
12911292
code += options.shadingModel === SPECULAR_PHONG ? chunks.lightSpecularPhongPS : (options.enableGGXSpecular) ? chunks.lightSpecularAnisoGGXPS : chunks.lightSpecularBlinnPS;
12921293
}
12931294
if (options.sphereMap || cubemapReflection || options.dpAtlas || (options.fresnelModel > 0)) {

0 commit comments

Comments
 (0)