Update #35 - Fixes, improved dynamic lighting

This commit is contained in:
lax1dude
2024-06-16 16:47:12 -07:00
parent ad3579659d
commit 77c6c217f4
42 changed files with 385 additions and 172 deletions

View File

@ -170,7 +170,7 @@ void main() {
#ifdef COMPILE_ENABLE_FOG
vec3 fogPos = v_position4f.xyz / v_position4f.w;
float dist = sqrt(dot(fogPos, fogPos));
float dist = length(fogPos);
float fogDensity = u_fogParameters4f.y;
float fogStart = u_fogParameters4f.z;
float fogEnd = u_fogParameters4f.w;

View File

@ -69,7 +69,7 @@ void main() {
fragPos4f.xyz /= fragPos4f.w;
fragPos4f.w = 1.0;
float l = sqrt(dot(fragPos4f.xyz, fragPos4f.xyz));
float l = length(fragPos4f.xyz);
#ifdef COMPILE_FOG_LINEAR
float f = (l - u_linearFogParam2f.x) / (u_linearFogParam2f.y - u_linearFogParam2f.x);
#else

View File

@ -431,7 +431,7 @@ void main() {
float type = u_fogParameters4f.x - atmos;
fogBlend4f = mix(u_fogColorLight4f, u_fogColorDark4f, lightmapCoords2f.g);
float l = sqrt(dot(v_position4f.xyz, v_position4f.xyz));
float l = length(v_position4f.xyz);
if(type == 1.0) {
f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z);
}else {

View File

@ -292,7 +292,7 @@ void main() {
fogFade = mix(u_fogColorDark4f.a, u_fogColorLight4f.a, lightmapCoords2f.g);
float f;
float l = sqrt(dot(v_position4f.xyz, v_position4f.xyz));
float l = length(v_position4f.xyz);
if(type == 1.0) {
f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z);
}else {

View File

@ -397,7 +397,7 @@ void main() {
float type = u_fogParameters4f.x - atmos;
fogBlend4f = mix(u_fogColorLight4f, u_fogColorDark4f, lightmapCoords2f.g);
float f, l = sqrt(dot(v_position4f.xyz, v_position4f.xyz));
float f, l = length(v_position4f.xyz);
if(type == 1.0) {
f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z);
}else {

View File

@ -1,7 +1,7 @@
{
"name": "§eHigh Performance PBR",
"desc": "Pack made from scratch specifically for this client, designed to give what I call the best balance between quality and performance possible in a browser but obviously that's just my opinion",
"vers": "1.2.0",
"vers": "1.2.1",
"author": "lax1dude",
"api_vers": 1,
"features": [

View File

@ -48,7 +48,9 @@ void main() {
}
vec4 light;
float blockLight = v_lightmap2f.x;
float diffuse = 0.0;
float len;
if(u_dynamicLightCount1i > 0) {
vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f;
worldPosition4f.xyz /= worldPosition4f.w;
@ -57,11 +59,13 @@ void main() {
for(int i = 0; i < safeLightCount; ++i) {
light = u_dynamicLightArray[i];
light.xyz = light.xyz - worldPosition4f.xyz;
diffuse += max(dot(normalize(light.xyz), normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - sqrt(dot(light.xyz, light.xyz)), 0.0);
len = length(light.xyz);
diffuse += max(dot(light.xyz / len, normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - len, 0.0);
}
blockLight = min(blockLight + diffuse * 0.066667, 1.0);
}
color *= texture(u_lightmapTexture, vec2(min(v_lightmap2f.x + diffuse * 0.066667, 1.0), v_lightmap2f.y));
color *= texture(u_lightmapTexture, vec2(blockLight, v_lightmap2f.y));
output4f = color;
}

View File

@ -152,6 +152,12 @@ void main() {
#ifdef COMPILE_ENABLE_LIGHTMAP
float diffuse = 0.0;
#ifdef COMPILE_LIGHTMAP_ATTRIB
float blockLight = v_lightmap2f.x;
#else
float blockLight = u_textureCoords02.x;
#endif
float len;
vec4 light;
if(u_dynamicLightCount1i > 0) {
vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f;
@ -161,13 +167,15 @@ void main() {
for(int i = 0; i < safeLightCount; ++i) {
light = u_dynamicLightArray[i];
light.xyz = light.xyz - worldPosition4f.xyz;
diffuse += max(dot(normalize(light.xyz), normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - sqrt(dot(light.xyz, light.xyz)), 0.0);
len = length(light.xyz);
diffuse += max(dot(light.xyz / len, normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - len, 0.0);
}
blockLight = min(blockLight + diffuse * 0.066667, 1.0);
}
#ifdef COMPILE_LIGHTMAP_ATTRIB
color *= texture(u_samplerLightmap, vec2(min(v_lightmap2f.x + diffuse * 0.066667, 1.0), v_lightmap2f.y));
color *= texture(u_samplerLightmap, vec2(blockLight, v_lightmap2f.y));
#else
color *= texture(u_samplerLightmap, vec2(min(u_textureCoords02.x + diffuse * 0.066667, 1.0), u_textureCoords02.y));
color *= texture(u_samplerLightmap, vec2(blockLight, u_textureCoords02.y));
#endif
#endif