| Blockland Forums > General Discussion |
| Who chose to use per-pixel lighting? |
| << < (3/5) > >> |
| otto-san:
chrisbot is right |
| Acerblock:
You're right Chris, in fact kompressor is credited for the Oct-Tree in the F1 menu. I didn't know what it was until now, it makes sense. It's actually pretty interesting. |
| Port:
--- Quote from: Altiris on May 25, 2013, 09:14:43 AM ---With Voxel lighting you don't have that annoying 8 light limit --- End quote --- Er, no, the lighting method has nothing to do with light limits. The reason we have a limit of 8 lights is because the point lighting uses a manually unrolled loop. --- Code: ---// Point lighting uniform vec4 pointLightPos0; uniform vec4 pointLightColor0; uniform float pointLightRadius0; uniform vec4 pointLightPos1; uniform vec4 pointLightColor1; uniform float pointLightRadius1; uniform vec4 pointLightPos2; uniform vec4 pointLightColor2; uniform float pointLightRadius2; uniform vec4 pointLightPos3; uniform vec4 pointLightColor3; uniform float pointLightRadius3; uniform vec4 pointLightPos4; uniform vec4 pointLightColor4; uniform float pointLightRadius4; uniform vec4 pointLightPos5; uniform vec4 pointLightColor5; uniform float pointLightRadius5; uniform vec4 pointLightPos6; uniform vec4 pointLightColor6; uniform float pointLightRadius6; uniform vec4 pointLightPos7; uniform vec4 pointLightColor7; uniform float pointLightRadius7; vec4 accumulatePointLights() { vec4 pointLightTotal = vec4(0.0f, 0.0f, 0.0f, 0.0f); vec3 lightDelta = vec3(0.0f, 0.0f, 0.0f); float lightDot = 0.0f; float ratio = 0.0f; // Calculate effects of the 8 point lights. lightDelta = worldPos.xyz - pointLightPos0.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius0); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor0.xyz; lightDelta = worldPos.xyz - pointLightPos1.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius1); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor1.xyz; lightDelta = worldPos.xyz - pointLightPos2.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius2); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor2.xyz; lightDelta = worldPos.xyz - pointLightPos3.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius3); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor3.xyz; lightDelta = worldPos.xyz - pointLightPos4.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius4); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor4.xyz; lightDelta = worldPos.xyz - pointLightPos5.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius5); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor5.xyz; lightDelta = worldPos.xyz - pointLightPos6.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius6); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor6.xyz; lightDelta = worldPos.xyz - pointLightPos7.xyz; lightDot = max(dot(-normalize(lightDelta), worldNormal), 0.0f); ratio = 1.0f - (length(lightDelta) / pointLightRadius7); ratio = ratio * ratio * ratio * 0.4f; ratio = max(ratio, 0.0f); pointLightTotal.xyz += ratio * lightDot * pointLightColor7.xyz; return pointLightTotal; } --- End code --- |
| Greek2me:
--- Quote from: Port on May 25, 2013, 01:28:09 PM ---Er, no, the lighting method has nothing to do with light limits. The reason we have a limit of 8 lights is because the point lighting uses a manually unrolled loop. --- End quote --- Do you remember why he did that? |
| Brian Smithers:
--- Quote from: Greek2me on May 25, 2013, 01:37:11 PM ---Do you remember why he did that? --- End quote --- He was on a lot of meth when he did that. |
| Navigation |
| Message Index |
| Next page |
| Previous page |