Hi dear devs,
Currently I’m trying to implement subsurface scattering effect into PlayCanvas just by changing refractionDynamicPS shader chunk. In process, I’ve encountered some difficulties about lights. Currently, lit-shader.js appends each lights code into fragment shader and each lights’ parameters are hard coded like light0_direction
(also see below)
backend.append(" dAtten *= getSpotEffect(light" + i + "_direction,
I’m having a hard time reaching every lights variables while developing shader. I tried to set them in an array in lightDirPointPS currently. But light0_color is unreachable. (which means another patch in getFalloffLinear())
#define LIGHTS_AVAILABLE
int pointLightCount = 0;
vec3 lightPointsPos[255];
void getLightDirPoint(vec3 lightPosW) {
dLightDirW = vPositionW - lightPosW;
dLightDirNormW = normalize(dLightDirW);
dLightPosW = lightPosW;
lightPointsPos[pointLightCount] = dLightPosW;
pointLightCount = pointLightCount + 1;
}
I think it would be nice to have lights values as arrays.
Btw, I wanna make PR about it but I’m stuck in this process. You can see effects results here: https://twitter.com/defektu_/status/1646825602530385920
Currently it has same light radius and intensity for each light. It would be cool to implement PlayCanvas’ default lights automatically.