6 ms·
Carmack on star fields in VR
- supernova87a 4y agoCan anyone explain this a bit more? > Stars (along with line art) are one of the most blatant tests for gamma correct rendering — if everything shimmers as you pan around, they are filtering in gamma space instead of linear space. It should all be rock solid. Something to do with as the underlying values are shifted between pixels (as you pan around), they increase/decrease pixel brightness inconsistently if you're mapping the intrinsic values to some curve before calculating the appropriate pixel brightness? (I'm unfamiliar with "gamma correct rendering")
- whatshisface 4y agoIf a star is halfway between two pixels, its brightness should be distributed evenly between both pixels so that the total emitted light from that area of your screen is the same as if it was all on one pixel. Applying a nonlinear function to the values will usually mess that up.
- supernova87a 4y agoThank you!
- pornel 4y agoHuman perception of brightness is not linearly proportional to the amount of light emitted (if you're in a dark room with 1 candle, and light 1 more candle this makes a big difference, but 100 → 101 candles is imperceptible. Physically both cases add the same amount of light). The relationship between perceived brightness and physical amount of light is approximately quadratic (~doubling amount of light is perceived as one incremental brightness step), which is called the gamma curve. So in graphics you have to choose whether your numeric brightness values are on a scale relevant to humans (gamma compressed values), or whether they're on a scale that better models physical properties of light (AKA linear light). This is generally confusing, and a lot of software gets it wrong (doesn't correct for the gamma curve where needed). For example, try blurring RGB red and green. In many programs it will give you a brown color, which is not the color of mixing red and green light, but a bad math on gamma-compressed values: √(A + B) ≠ √A + √B
- supernova87a 4y agoThanks!
- shmageggy 4y ago> The relationship between perceived brightness and physical amount of light is approximately quadratic (~doubling amount of light is perceived as one incremental brightness step), which is called the gamma curve. This sounds logarithmic to me, similar to the decibel system for audio loudness perception
- sylware 4y agoBTW, do we get a native elf/linux proper build? ...
- hoten 4y agoWhat does it mean to filter in gamma space vs linear space?
- dTal 4y ago"Filtering" is a graphics term of art that roughly means "interpolation". Imagine you want to represent a star with a single max brightness pixel. Suppose you want to smoothly pan that pixel to its neighbor. If you simply switch the pixel off and switch the neighbor on, it will look jumpy. So what you want to do is gradually dim the first pixel, while gradually brightening the second, so that the intensity smoothly moves over instead of jumping. The catch: at all times, the sum of the light intensity from both pixels must be constant. You want the star to move, not flicker. Seems easy, right? Subtract 1 from the first pixel and add 1 to the second, keeping the sum the same? Wrong! The relationship between the actual light emitted by a pixel and the number we use to represent it in software is not linear. It generally follows a power law, usually with an exponent of about 2.2, since this is a more efficient representation given that human perception also follows a power law. If 255 were actually twice as many photons as 127, you would find that they didn't actually look all that different - the range 0-255 would skew towards most values looking pretty bright. Instead the values "encode" the real brightness, and if you do math on these encoded values you are operating in "gamma space". So, in order to correctly do our 1-pixel panning, we need to "decode" our pixel value to linear brightness by taking the logarithm (base 2.2), add 1 / subtract 1 there, and then raise it back up. This is what Carmack means by "filtering in linear space". Obviously, many programmers are not aware of the requirement to do this, and just treat the pixel values as if they were real brightness values. Result: flicker.
- hoten 4y agoThanks for breaking it down! It seems like this was a necessity to allow for a larger range of representable colours in a single byte. Is this system largely a carry over from more constrained hardware days, or is it still appropriate for modern hardware? Like, we could represent colors with a few more bytes and toss out the gamma encoding to get back to the same level of control. Or am I overlooking more fundamental reasons why this is a good abstraction?
- phendrenad2 4y ago> Stars are perfect point light sources to the eye But that isn't true rofl. Stars are, in fact, (extremely) large spheres, and can take up more than one pixel if your pixels are small enough.
- GuB-42 4y agoHe said "to the eye". But indeed, not all stars are "point light": the sun as seen from the earth is not. And it is a good thing, because otherwise that would make our sun like a laser, our retinas won't last long...
- robocat 4y ago> our retinas won't last long I think you are mistaking cause end effect. If the sun were a point source, the layout of our eyes (and our behaviours) would have evolved differently to compensate. Alternatively, if the diameter of the sun (or the apparent diameter of the sun) quickly changed that much, our eyesight is the least of our worries.
- fshbbdssbbgdd 4y agoOther than the sun, are there any stars that should take up multiple pixels at the angular resolution available with current display technology?
- sbierwagen 4y agoAlpha Centauri is 4.344 light years away and about 0.00930093 AU in diameter, and if my math is right should subtend 3.12x10^-25 arc seconds. The Oculus Quest 2 has a horizontal FOV of 97 degrees. In order for α Centauri to cover two pixels, you would need a display with 6.2179487x10^26 horizontal pixels. 621 yottapixels. Something like a hundred sextillion times "4K" resolution. And that's linear resolution, tag on some more orders of magnitude for display area. There is a reason parallax is used to measure distance to stars, rather than directly measuring their visual diameter.
- 4y ago
- VanillaCafe 4y agoI can't seem to find the reference, but I seem to recall that Valve had specialized rendering logic for the power lines in Half Life 2? I presume that's basically the same fundamental problem as rendering line art and star fields...
- speps 4y agoPhone wire anti-aliasing: https://www.humus.name/index.php?page=3D&ID=89 https://www.humus.name/index.php?page=3D&ID=89
- himinlomax 4y agoHe mentions gamma space and linear space; wouldn't the actual solution for all these filtering problems to move to floating point buffers? Haven't SGI patents expired by now?
- graffix 4y ago> Stars are perfect point light sources to the eye, they will not cover multiple pixels unless you are doing an intentional bloom effect On any real camera, stars always cover multiple pixels (the entire screen strictly speaking). This is described by a point-spread function (PSF), where the "least blurry" physically realizable PSF is the Airy disk. The bloom effect occurs due to the long tails of the PSF. Inasmuch as stars appear as perfect points to the eye, it's down to perceptual limits and (I suspect) heavy filtering in the visual cortex. Not saying Carmack is wrong about VR and video game rendering here. Just that if you're trying to replicate real sensors, the right way is precisely what he says to avoid. You must somehow draw > large, dim stars During a recent effort to implement physically-accurate star rendering at work, I had access to a photograph of the night sky. Bright stars visibly and clearly covered 3x3 pixels- more in reality, due to the above.
- kridsdale1 4y agoI guess as a VR dev you have to first decide, are you making a first person perspective for a human with eyes, or for a pair of camera lenses, with all the mechanical and optical artifacts that comes with that? Humans don’t see lens flare. But our cinematic cultural library now makes us expect them in games, even if the character is biological and not wearing glasses.
- jws 4y agoHe touches on line graphics as having the same problem rendering. I run into that when making strip charts. In general, the higher level your graphics API, the harder it is to get horizontal and vertical lines to draw on the physical pixels. At the frame buffer level it is trivial. Cocoa and UIKit it is possible with some effort. SwiftUI it is impossible (you will end up using the escape hatch to Cocoa or UIKit). HTML is hopeless. When printing meant writing some Postscript it was a little work, but doable. Getting it onto a printer through a modern printer API is essentially impossible. Fundamentally this is why most graphs you see online look like they were drawn with a worn out felt tip marker. It hides the sins at the expense of limiting data density and precision.
- galangalalgol 4y agoIf you netcat a ps file to the ip of the printer that should still work yes?
- bno1 4y agoSounds like you want font hinting but for vector graphics.
- naikrovek 4y ago> When printing meant writing some Postscript it was a little work, but doable. Getting it onto a printer through a modern printer API is essentially impossible. Brother printers (at least some) support BR-script which is Postscript without the trademark violation. It's supported at the driver level, I think, which would render the PS on the PC then send the rendered document as one of the hardware-supported languages like PCL. I mention this as an interesting bit of info, and not to refute anything you said
- kllrnohj 4y agoIt's hard in HTML due to the clunky way it handles density scaling. You wont have any issue doing razer sharp pixel alignment on systems that are natively density aware, like Android, as then the rendering stack can just work in actual pixels like it should, and density handling is done by the layout system instead. So it's not about the number of layers of abstraction or general "high level"ness, but rather if those abstractions are trying to cover up mistakes made elsewhere.
- pyrolistical 4y agoHe is talking about actual star fields. Not to be confused with the upcoming game https://en.m.wikipedia.org/wiki/Starfield_(video_game) https://en.m.wikipedia.org/wiki/Starfield_(video_game) The title should fix the capitalization and use two worlds
- abudabi123 4y agoNASA should get gaming on this outreach operation potential and continue-on John Carmack's tradecraft. Seed $57 million to John Carmack's Kerbal Space Program to define and support "perfect" star fields in the compositor.
- Cullinet 4y ago
- Cullinet 4y agoapologies for the rapid appending of non destructive edits to my above comment, but does what I wrote warrant negative moderation? Are any log my stated facts incorrect? I can understand if cursory reading might lead to a inaccurate bias confirmation of anti American sentiment by someone who is (always understandably) biased against criticism of the American system, but I am a ageing hawk in every way, of no liberal leanings in politics or geopolitical views of any kind. Humanly I'm not at all aggressive, but there hasn't been such a shortfall in strategic stance by America in my nearing retirement lifetime. I advocate the separation of military and scientific space endeavour. The current commercial efforts offer just such a opportunity for so doing. For those who have personal or directly informed recollection, NASA and indeed the early moon mission objectives polled most unfavourably across red and blue States for some years.
- interroboink 4y agoYou got me curious on the creation of NASA. I read through the Executive Order[1] you mentioned (pretty short). I'm not sure I quite see the "psycho political" parts you indicate. Seems fairly straightforward, with quotes like "A science research agenda", "the exploration of technologies, demonstrations, and strategies, ... that could be used for sustainable human and robotic exploration", "encourage the interest of Americas youth in studying and pursuing careers in mathematics, science, and engineering...", and so-on. Certainly there was a political context in which that order was given, but ... am I missing something? [1] https://www.nasa.gov/missions/solarsystem/aldridge_executive_order.html https://www.nasa.gov/missions/solarsystem/aldridge_executive...
- HackerNot 4y ago
- the__alchemist 4y agoIf anyone hasn't played Space Engine, check it out! Labor of love.