Git Product home page Git Product logo

Comments (8)

vorg avatar vorg commented on June 6, 2024

Discussion in AFrame repo aframevr/aframe#3757

from pex-renderer.

vorg avatar vorg commented on June 6, 2024

ThreeJS has this still unsolved as of March 2019

Editor: all colors/textures washed out in r102

I'd like to see this eventually be implicitly part of THREE.Color, perhaps with some colorManagement flag to disable it. When the user provides a hex code, it's implicitly sRGB, whereas fromArray() etc. would implicitly be linear.

Suggestion: add a bufferAttribute.convertGammaToLinear method

Adding convertSRGBToLinear utility for vertex color

We Need to Properly Handle Gamma Correction

THREE.Color: added sRGB conversion methods

from pex-renderer.

vorg avatar vorg commented on June 6, 2024

Babylon js has useScalarInLinearSpace but can't find any docs on it.

from pex-renderer.

vorg avatar vorg commented on June 6, 2024

Current thinking.

Assume float rgba array colors [r, g, b, a] are linear.
Assume html hex colors #FFDD33 are gamma
Assume byte 0.255 rgba array colors [rByte, gByte, bByte, aByte] from gui and are gamma (?)

Add gamma correction to pex-color.fromHex and pex-color.fromRGBBytes

What about vertex colors?

from pex-renderer.

vorg avatar vorg commented on June 6, 2024

Filament is most clear in the docs 👍

baseColor - Pre-multiplied linear RGB

About linear RGB

Several material model properties expect RGB colors. Filament materials use RGB colors in linear space and you must take proper care of supplying colors in that space. See the Linear colors section for more information.

About pre-multiplied RGB

Filament materials expect colors to use pre-multiplied alpha. See the Pre-multiplied alpha section for more information.

from pex-renderer.

vorg avatar vorg commented on June 6, 2024

What about vertex colors?

They should be linear KhronosGroup/glTF#1638

from pex-renderer.

vorg avatar vorg commented on June 6, 2024
color.fromHEX("#FF000") -> [1, 0, 0, 1]
color.toLinear(color.fromBytes([255, 0, 0])) -> [1, 0, 0, 1]

var red = color.fromBytes([255, 0, 0])
var red = [r / 255, g / 255, b / 255, 1] // floating point sRGB/gamma color

var linearRed = color.toLinear(red)
var linearishRed = [
   Math.pow(r / 255, 2.2),
   Math.pow(r / 255, 2.2),
   Math.pow(r / 255, 2.2),
   1
] // floating point sRGB/gamma color

var linearColorValue = [0, 0, 0, 0]
var colorValueLinear = [0, 0, 0, 0]
ctx.submit(myCommand, {
   uniforms: {
     uColor: color.convertToLinear(color.set(linearColorValue, colorIn.value)),
     uColor: color.fromGamma(linearColorValue),
     uColor: color.fromGammaToLinear(linearColorValue, colorIn.value),
     uColor: color.fromLinear(linearColorValue, colorIn.value)
     
      uColor: color.toLinear(colorIn.value),
      uColor: color.toLinear(colorIn.value, linearColorValue)
   }
})

color.getHex(color.toLinear(colorIn.value))

Can we assume all colors coming out of this library are linear? That would require 2.0 rewrite.

from pex-renderer.

vorg avatar vorg commented on June 6, 2024

Alternatively we simply add color.toLinear(oldSRGBColor, newLinearColor) and you keep track of the color space via variable name.

from pex-renderer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.