Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8217472

Add attenuation for PointLight



    • Enhancement
    • Resolution: Fixed
    • P3
    • jfx16
    • jfx11, jfx12
    • javafx


      The current PointLight implementation does not take into account the reduction in light intensity by distance. The result is unrealistic lighting. Attenuation is added to simulate the intensity reduction over distance.

      -- API --

      4 DoubleProperties will be added to PointLight:

      * 1 maximum range property, which is the maximum distance the light will affect. This is important for performance reasons - it prevents attenuation calculation at "near infinity" by providing a hard cutoff. The developer is responsible for providing a sensible value. Must be >=0.

      * 3 attenuation factors 'a0', 'a1' and 'a2' (names subject to change) as defined by the formula:

      attenuation = 1 / (a0 + a1 * distance + a2 * distance^2)

      -- Implementation --

      The logic in the pixel/fragment is as follows (in pseudo-code):

      if (distance <= maximum range) {
          attenuation = 1 / (a0 + a1 * distance + a2 * distance^2);
          diffuseColor = diffuseColor * attenuation;
          specularColor = specularColor * attenuation;
      } // else skip this light

      -- Default Values --

      For backwards compatibility, the default values are:
      maximum range = Double.POSITIVE_INFINITY
      a0 = 1.0
      a1 = a2 = 0.0

      This means that all current PointLights take an immediate performance hit as they need to calculate attenuation for all objects in the scope. It is possible to add a 'BooleanProperty useAttenuation' set to false by default that will outright ignore attenuation (effectively setting it to 1).

      -- Pipelines --

      This enhancement will be split into 3 parts:

      1. d3d pipeline that includes the native code and d3d-only Java code.
      2. es2 pipeline that includes the native code and es2-only Java code.
      3. Common Java code.


        Issue Links



              nlisker Nir Lisker
              nlisker Nir Lisker
              0 Vote for this issue
              3 Start watching this issue