This commit is contained in:
Miloslav Ciz 2023-07-13 12:19:07 +02:00
parent e89960bcfb
commit 5cb3296fc9
11 changed files with 63 additions and 22 deletions

View file

@ -1,6 +1,6 @@
# Aliasing # Aliasing
Aliasing is a certain typically undesirable phenomenon that distorts signals (such as sounds or images) when they are [sampled](sampling.md) [discretely](discrete.md) (captured at periodic intervals) -- this can happen e.g. when capturing sound with digital recorders or when [rendering](rendering.md) computer graphics. There exist [antialiasing](antialiasing.md) methods for suppressing or even eliminating aliasing. Aliasing can be often seen on small checkerboard patterns as a moiré pattern (spatial aliasing), or maybe more famously on rotating wheels or helicopter rotor blades that in a video look like standing still or rotating the other way (temporal aliasing, caused by capturing images at intervals given by the camera's [FPS](fps.md)). Aliasing is a certain typically undesirable phenomenon that distorts signals (such as sounds or images) when they are [sampled](sampling.md) [discretely](discrete.md) (captured at single points, usually at periodic intervals) -- this can happen e.g. when capturing sound with digital recorders or when [rendering](rendering.md) computer graphics. There exist [antialiasing](antialiasing.md) methods for suppressing or even eliminating aliasing. Aliasing can be often seen on small checkerboard patterns as a moiré pattern (spatial aliasing), or maybe more famously on rotating wheels or helicopter rotor blades that in a video look like standing still or rotating the other way (temporal aliasing, caused by capturing images at intervals given by the camera's [FPS](fps.md)).
A simple example showing how sampling at discrete points can quite dramatically alter the recorded result: A simple example showing how sampling at discrete points can quite dramatically alter the recorded result:
@ -56,4 +56,4 @@ The same thing may happen in [ray tracing](ray_tracing.md) if we shoot a single
**Why doesn't aliasing happen in our eyes and ears?** Because our senses don't sample the world discretely, i.e. in single points -- our senses [integrate](integration.md). E.g. a rod or a cone in our eyes doesn't just see exactly one point in the world but rather an averaged light over a small area (which is ideally right next to another small area seen by another cell, so there is no information to "hide" in between them), and it also doesn't sample the world at specific moments like cameras do, its excitation by light falls off gradually which averages the light over time, preventing temporal aliasing (instead of aliasing we get [motion blur](motion_blur.md)). **Why doesn't aliasing happen in our eyes and ears?** Because our senses don't sample the world discretely, i.e. in single points -- our senses [integrate](integration.md). E.g. a rod or a cone in our eyes doesn't just see exactly one point in the world but rather an averaged light over a small area (which is ideally right next to another small area seen by another cell, so there is no information to "hide" in between them), and it also doesn't sample the world at specific moments like cameras do, its excitation by light falls off gradually which averages the light over time, preventing temporal aliasing (instead of aliasing we get [motion blur](motion_blur.md)).
So all in all, **how to prevent aliasing?** As said above, we always try to satisfy the sampling theorem, i.e. make our sampling frequency at least twice as high as the highest frequency in the signal we're sampling, or at least get close to this situation and lower the probability of aliasing. This can be done by either increasing sampling frequency (which can be done smart, some methods try to detect where sampling should be denser), or by preprocessing the input signal with a low pass filter or otherwise ensure there won't be too high frequencies. So all in all, **how to prevent aliasing?** As said above, we always try to satisfy the sampling theorem, i.e. make our sampling frequency at least twice as high as the highest frequency in the signal we're sampling, or at least get close to this situation and lower the probability of aliasing. This can be done by either increasing sampling frequency (which can be done smart, some methods try to detect where sampling should be denser), or by preprocessing the input signal with a low pass filter or otherwise ensure there won't be too high frequencies (e.g. using lower resolution textures).

View file

@ -2,7 +2,7 @@
*Capitalism is how you enslave people with their approval.* *Capitalism is how you enslave people with their approval.*
Capitali$m is the worst socioeconomic system we've yet seen in [history](history.md),^[source](logic.md) based on pure greed, culture of slavery and artificially sustained conflict between everyone in society (so called [competition](competition.md)), abandoning all morals and putting money and profit (so called [capital](capital.md)) above everything else including preservation of life itself, capitalism fuels the worst in people and forces them to compete and suffer for basic resources, even in a world where abundance of resources is already possible to achieve. Capitalism goes against progress (see e.g. [antivirus paradox](antivirus_paradox.md)), [good technology](lrs.md) and freedom, it supports immense waste of resources, wars, abuse of people and animals, destruction of environment, decline of morals, deterioration of art, invention of [bullshit](bullshit.md) (bullshit jobs, bullshit laws, ...), utilizing and perfecting methods of [torture](marketing.md), brainwashing, censorship and so on. In a sense capitalism can be seen as **slavery 2.0** or *universal slavery*, a more sophisticated form of slavery, one which denies the label by calling itself the polar opposite ("freedom") and manipulates people into them approving and voluntarily parttaking in their own enslavement. However wage and consumption slavery is only a small part of capitalist dystopia -- capitalism brings on destruction basically to every part of civilization. It it also often likened to a [cancer](cancer.md) of society; one that is ever expanding, destroying everything with commercialism, materialism, waste and destruction, growing uncontrollably with the sole goal of just never stop an ever accelerating growth. Nevertheless, it's been truthfully stated that "it is now easier to imagine the end of all life than any substantial change in capitalism." Another famous quote is that "capitalism is the belief that the worst of men driven by the nastiest motives will somehow work for the benefit of everyone", which is describes its principle quite well. Capitali$m is the worst socioeconomic system we've yet seen in [history](history.md),^[source](logic.md) based on pure greed, culture of slavery and artificially sustained conflict between everyone in society (so called [competition](competition.md)), abandoning all morals and putting money and profit (so called [capital](capital.md)) above everything else including preservation of life itself, capitalism fuels the worst in people and forces them to compete and suffer for basic resources, even in a world where abundance of resources is already possible to achieve. Capitalism goes against progress (see e.g. [antivirus paradox](antivirus_paradox.md)), [good technology](lrs.md) and freedom, it supports immense waste of resources, wars, abuse of people and animals, destruction of environment, decline of morals, deterioration of [art](art.md), invention of [bullshit](bullshit.md) (bullshit jobs, bullshit laws, ...), utilizing and perfecting methods of [torture](marketing.md), brainwashing, [censorship](censorship.md) and so on. In a sense capitalism can be seen as **slavery 2.0** or *universal slavery*, a more sophisticated form of slavery, one which denies the label by calling itself the polar opposite ("freedom") and manipulates people into them approving and voluntarily parttaking in their own enslavement. However wage and consumption slavery is only a small part of capitalist dystopia -- capitalism brings on destruction basically to every part of civilization. It it also often likened to a [cancer](cancer.md) of society; one that is ever expanding, destroying everything with commercialism, materialism, waste and destruction, growing uncontrollably with the sole goal of just never stop an ever accelerating growth. Nevertheless, it's been truthfully stated that "it is now easier to imagine the end of all life than any substantial change in capitalism." Another famous quote is that "capitalism is the belief that the worst of men driven by the nastiest motives will somehow work for the benefit of everyone", which describes its principle quite well.
{ Some web bashing capitalism I just found: http://digdeeper.club/articles/capitalismcancer.xhtml, read only briefly, seems to contain some nice gems capturing the rape of people. ~drummyfish } { Some web bashing capitalism I just found: http://digdeeper.club/articles/capitalismcancer.xhtml, read only briefly, seems to contain some nice gems capturing the rape of people. ~drummyfish }
@ -10,9 +10,9 @@ Capitali$m is the worst socioeconomic system we've yet seen in [history](history
**Capitalism produces the [worst imaginable technology](capitalist_software.md)** and rewards people for [being cruel to each other](entrepreneur.md). It points the direction of society towards a [collapse](collapse.md) and may very likely be the [great filter](great_filter.md) of civilizations; in capitalism people [de-facto](de_facto.md) own nothing and become wholly dependent on corporations which exploit this fact to abuse them as much as possible. This is achieved by [slowly boiling the frog](slowly_boiling_the_frog.md). No one owns anything, products become [services](saas.md) (your car won't drive without Internet connection and permission from its manufacturer), all independency and decentralization is lost in favor of a highly fragile and interdependent economy and infrastructure of services, each one controlled by the monopoly corporation. Then only a slight break in the chain is enough to bring the whole civilization down in a spectacular domino effect. **Capitalism produces the [worst imaginable technology](capitalist_software.md)** and rewards people for [being cruel to each other](entrepreneur.md). It points the direction of society towards a [collapse](collapse.md) and may very likely be the [great filter](great_filter.md) of civilizations; in capitalism people [de-facto](de_facto.md) own nothing and become wholly dependent on corporations which exploit this fact to abuse them as much as possible. This is achieved by [slowly boiling the frog](slowly_boiling_the_frog.md). No one owns anything, products become [services](saas.md) (your car won't drive without Internet connection and permission from its manufacturer), all independency and decentralization is lost in favor of a highly fragile and interdependent economy and infrastructure of services, each one controlled by the monopoly corporation. Then only a slight break in the chain is enough to bring the whole civilization down in a spectacular domino effect.
**The underlying issue of capitalism is [competition](competition.md)** and conflict -- competition is the root of all evil in any social system, however capitalism is the absolute glorification of competition, amplification of this evil to maximum. It is implemented by setting and supporting a very stupid idea that **everyone's primary and only goal is to be self-benefit**, i.e. maximization of capital. This is combined with the fact that the environment of [free market](free_market.md) is a system with **[evolutionary system](evolution.md)** which through natural selection extremely effectively and quickly optimizes the organisms (corporations) for achieving this given goal, i.e. generating maximum profit, on the detriment of all other values such as wellbeing of people, sustainability or morality. In other words capitalism has never promised a good society, it literally only states that everyone should try to benefit oneself as much as possible, i.e. defines the [fitness function](fitness_function.md) purely as the ability to seize as many resources as possible, and then selects and rewards those who best implement this function, i.e. those we would call sociopaths or "dicks", and to those is given the power in society. Yes, this is how nature works, but it must NOT be how a technologically advanced civilization with unlimited power of destruction should work. In other words we simply get what we set to achieve: find entities that are best at making profit at any cost. The inevitable decline of society can not possibly be prevented by laws, any effort of trying to stop evolution by inventing artificial rules on the go is a battle against nature itself and is extremely naive, the immense power of the evolutionary system that's constantly at work to find ways to bypass or cancel laws in the way of profit and abuse of others will prevails just as life will always find its way to survive and thrive even in the worst conditions on Earth. Trying to stop corporations with laws is like trying to stop a train by throwing sticks in its path. The problem is not that "people are dicks", it is that we choose to put in place a system that rewards the dicks, a system that fuels the worst in people and smothers the best in them. **The underlying issue of capitalism is [competition](competition.md)** and conflict -- competition is the root of all evil in any social system, however capitalism is the absolute glorification of competition, amplification of this evil to maximum. It is implemented by setting and supporting a very stupid idea that **everyone's primary and only goal is to be self-benefit**, i.e. maximization of capital. This is combined with the fact that the environment of [free market](free_market.md) is a an **[evolutionary system](evolution.md)** which through natural selection extremely effectively and quickly optimizes the organisms (corporations) for achieving this given goal, i.e. generating maximum profit, on the detriment of all other values such as wellbeing of people, sustainability or morality. In other words capitalism has never promised a good society, it literally only states that everyone should try to benefit oneself as much as possible, i.e. defines the [fitness function](fitness_function.md) purely as the ability to seize as many resources as possible, and then selects and rewards those who best implement this function, i.e. those we would call sociopaths or "dicks", and to those is given the power in society. Yes, this is how nature works, but it must NOT be how a technologically advanced civilization with unlimited power of destruction should work. In other words we simply get what we set to achieve: find entities that are best at making profit at any cost. The inevitable decline of society can not possibly be prevented by laws, any effort of trying to stop evolution by inventing artificial rules on the go is a battle against nature itself and is extremely naive, the immense power of the evolutionary system that's constantly at work to find ways to bypass or cancel laws in the way of profit and abuse of others will prevails just as life will always find its way to survive and thrive even in the worst conditions on Earth. Trying to stop corporations with laws is like trying to stop a train by throwing sticks in its path. The problem is not that "people are dicks", it is that we choose to put in place a system that rewards the dicks, a system that fuels the worst in people and smothers the best in them.
Even though nowadays quite a lot of time has passed since times of [Marx](marx.md) and capitalism has evolved to a stage with countless disastrous issues Marx couldn't even foresee, it is useful to mention one of the basic and earliest issues identified by Marx, which is that economically capitalism is based on **stealing the [surplus](surplus.md) value**, i.e. abuse of workers and consumers by owners of the means of production (factories, tools, machines etc.) -- a capitalist basically takes money for doing nothing, just for letting workers use tools he proclaims to own (a capitalist will proclaim to "own" land that he never even visited, machines he didn't make as they were developed over centuries, nowadays he even claims to own [information and ideas](intellectual_property.md)) -- as [Kropotkin](kropotkin.md) put it: the working man cannot purchase with his wage the wealth he has produced. This allows a capitalist oppressor to make exponentially more money for nothing and enables existence of monstrously rich and powerful individuals -- consider for example that nowadays there are people who own hundreds of buildings and cars plus a handful of private planes and a few private islands. It is not possible for any single human to work an equivalent of effort that's needed to produce what such an individual owns, even if he worked 24 hours a day for his whole life, he wouldn't get even close to matching the kind of effort that's needed to build the hundreds of buildings he owns -- any such great wealth is always stolen from countless workers whose salary is less than what's adequate for their work and also from consumers who pay more than it really costs to manufacture the goods they buy. Millions of people are giving their money (resources) for free to someone who just proclaims to "own" tools and even natural resources that have been there for billions of years. The difference in wealth and privileges this wealth provides divides society into antagonist classes that are constantly at war -- traditionally these classes are said to be the **[bourgeoisie](bourgeoisie.md)** (business owners, the upper class) and the **[proletariat](proletariat.md)** (workers, the lower class), though under modern capitalism the division of society is not so simple anymore -- there are more classes (for example small businesses work for larger businesses) but they are still all at war. Even though nowadays quite a lot of time has passed since times of [Marx](marx.md) and capitalism has evolved to a stage with countless disastrous issues Marx couldn't even foresee, it is useful to mention one of the basic and earliest issues identified by Marx, which is that economically capitalism is based on **stealing the [surplus](surplus.md) value**, i.e. abuse of workers and consumers by owners of the means of production (factories, tools, machines etc.) -- a capitalist basically takes money for doing nothing, just for letting workers use tools he proclaims to own (a capitalist will proclaim to "own" land that he never even visited, machines he didn't make as they were developed over centuries, nowadays he even claims to own [information and ideas](intellectual_property.md)) -- as [Kropotkin](kropotkin.md) put it: the working man cannot purchase with his wage the wealth he has produced. This allows a capitalist oppressor to make exponentially more money for nothing and enables existence of monstrously rich and powerful individuals in a world where millions are starving -- consider for example that nowadays there are people who own hundreds of buildings and cars plus a handful of private planes and a few private islands. It is not possible for any single human to work an equivalent of effort that's needed to produce what such an individual owns, even if he worked 24 hours a day for his whole life, he wouldn't get even close to matching the kind of effort that's needed to build the hundreds of buildings he owns -- any such great wealth is always stolen from countless workers whose salary is less than what's adequate for their work and also from consumers who pay more than it really costs to manufacture the goods they buy. Millions of people are giving their money (resources) for free to someone who just proclaims to "own" tools and even natural resources that have been there for billions of years. The difference in wealth and privileges this wealth provides divides society into antagonist classes that are constantly at war -- traditionally these classes are said to be the **[bourgeoisie](bourgeoisie.md)** (business owners, the upper class) and the **[proletariat](proletariat.md)** (workers, the lower class), though under modern capitalism the division of society is not so simple anymore -- there are more classes (for example small businesses work for larger businesses) but they are still all at war.
Nowadays **capitalism is NOT JUST an economic system** anymore. Technically perhaps, however in reality it takes over society to such a degree that it starts to redefine very basic social and moral values to the point of taking the role of a [religion](religion.md), or better said a brainwashing cult in which people are since childhood taught (e.g. by constant daily exposure to private media) to worship economy, brands, engage in cults of personalities (see myths about godlike entrepreneurs) and [productivity](productivity.md) (i.e. not usefulness, morality, efficiency or similar values, just the pure ability to produce something for its own sake). Close minded people will try to counter argue in shallow ways such as "but religion has to have some supernatural entity called God" etc. Again, technically speaking this may be correct, but if we don't limit our views by arbitrary definitions of words, we see that the effects of capitalism on society are [de facto](de_facto.md) of the same or even greater scale than those of religion, and they are certainly more negative. Capitalism itself works towards suppressing traditional religions (showing it is really competing with them and therefore aspiring for the same role) and their values and trying to replace them with worship of money, success and self interest, it permeates society to the deepest levels by making every single area of society a subject of business and acting on the minds of all people in the society every single day which is an enormously strong pressure that strongly shapes mentality of people, again mostly negatively towards a war mentality (constant competition with others), egoism, materialism, fascism, pure pursuit of profit etc. Nowadays **capitalism is NOT JUST an economic system** anymore. Technically perhaps, however in reality it takes over society to such a degree that it starts to redefine very basic social and moral values to the point of taking the role of a [religion](religion.md), or better said a brainwashing cult in which people are since childhood taught (e.g. by constant daily exposure to private media) to worship economy, brands, engage in cults of personalities (see myths about godlike entrepreneurs) and [productivity](productivity.md) (i.e. not usefulness, morality, efficiency or similar values, just the pure ability to produce something for its own sake). Close minded people will try to counter argue in shallow ways such as "but religion has to have some supernatural entity called God" etc. Again, technically speaking this may be correct, but if we don't limit our views by arbitrary definitions of words, we see that the effects of capitalism on society are [de facto](de_facto.md) of the same or even greater scale than those of religion, and they are certainly more negative. Capitalism itself works towards suppressing traditional religions (showing it is really competing with them and therefore aspiring for the same role) and their values and trying to replace them with worship of money, success and self interest, it permeates society to the deepest levels by making every single area of society a subject of business and acting on the minds of all people in the society every single day which is an enormously strong pressure that strongly shapes mentality of people, again mostly negatively towards a war mentality (constant competition with others), egoism, materialism, fascism, pure pursuit of profit etc.

View file

@ -2,7 +2,7 @@
*"God doesn't play dice."* --[some German dude](einstein.md) *"God doesn't play dice."* --[some German dude](einstein.md)
Deterministic system (such as a computer program or an equation) is one which over time evolves without any involvement of [randomness](randomness.md) and probability; i.e. its current state along with the rules according to which it behaves unambiguously and precisely determine its following states. This means that a deterministic [algorithm](algorithm.md) will always give the same result if run multiple times with the same input values. Determinism is an extremely important concept in [computer science](compsci.md) and [programming](programming.md) (and in many other fields of science and philosophy). Deterministic system (such as a computer program or an equation) is one which over time evolves without any involvement of [randomness](randomness.md); i.e. its current state along with the rules according to which it behaves unambiguously and precisely determine its following states. This means that a deterministic [algorithm](algorithm.md) will always give the same result if run multiple times with the same input values. Determinism is an extremely important concept in [computer science](compsci.md) and [programming](programming.md) (and in many other fields of science and philosophy).
Determinism is also a **philosophical theory** and aspect of physics theories -- here it signifies that our Universe is deterministic, i.e. that everything is already predetermined by the state of the universe and the laws of physics, i.e. that we don't have "[free will](free_will.md)" (whatever it means) because our brains are just machines following laws of physics like any other matter etc. Many normies believe [quantum physics](quantum.md) disproves determinism which is however not the case, there may e.g. exist hidden variables that still make quantum physics deterministic -- some believe the Bell test disproved hidden variables but again this is NOT the case as it relies on statistical independence of the experimenters, determinism is already possible if we consider the choices of experimenters are also predetermined (this is called [superdeterminism](superdeterminism.md)). [Einstein](einstein.md) and many others still believed determinism was the way the Universe works even after quantum physics emerged. { This also seems correct to me. Sabine Hossenfelder is another popular physicist promoting determinism. ~drummyfish } Anyway, this is already beyond the scope of technological determinism. Determinism is also a **philosophical theory** and aspect of physics theories -- here it signifies that our Universe is deterministic, i.e. that everything is already predetermined by the state of the universe and the laws of physics, i.e. that we don't have "[free will](free_will.md)" (whatever it means) because our brains are just machines following laws of physics like any other matter etc. Many normies believe [quantum physics](quantum.md) disproves determinism which is however not the case, there may e.g. exist hidden variables that still make quantum physics deterministic -- some believe the Bell test disproved hidden variables but again this is NOT the case as it relies on statistical independence of the experimenters, determinism is already possible if we consider the choices of experimenters are also predetermined (this is called [superdeterminism](superdeterminism.md)). [Einstein](einstein.md) and many others still believed determinism was the way the Universe works even after quantum physics emerged. { This also seems correct to me. Sabine Hossenfelder is another popular physicist promoting determinism. ~drummyfish } Anyway, this is already beyond the scope of technological determinism.

View file

@ -1,6 +1,6 @@
# Floating Point # Floating Point
Floating point arithmetic (colloquially just *float*) is a method of computer representation of [fractional](rational_number.md) numbers and approximating [real numbers](real_number.md), i.e. numbers with higher than [integer](integer.md) precision (such as 5.13), which is more complex than e.g. [fixed point](fixed_point.md). The core idea of it is to use a radix ("decimal") point that's not fixed but can move around so as to allow representation of both very small and very big values. Nowadays floating point is the standard way of [approximating](approximation.md) [real numbers](real_number.md) in computers (floating point types are called *real* in some programming languages, even though they represent only [rational numbers](rational_number.md), floats can't e.g. represent [pi](pi.md) exactly), basically all of the popular [programming languages](programming_language.md) have a floating point [data type](data_type.md) that adheres to the IEEE 754 standard, all personal computers also have the floating point hardware unit (FPU) and so it is widely used in all [modern](modern.md) programs. However most of the time a simpler representation of fractional numbers, such as the mentioned [fixed point](fixed_point.md), suffices, and weaker computers (e.g. [embedded](embedded.md)) may lack the hardware support so floating point operations are emulated in software and therefore slow -- remember, float rhymes with [bloat](bloat.md). Prefer fixed point. In programming floating point (colloquially just *float*) is a way of representing [fractional](rational_number.md) numbers (such as 5.13) and approximating [real numbers](real_number.md) (i.e. numbers with higher than [integer](integer.md) precision), which is a bit more complex than simpler methods for doing so (such as [fixed point](fixed_point.md)). The core idea of it is to use a radix ("decimal") point that's not fixed but can move around so as to allow representation of both very small and very big values. Nowadays floating point is the standard way of [approximating](approximation.md) [real numbers](real_number.md) in computers (floating point types are called *real* in some programming languages, even though they represent only [rational numbers](rational_number.md), floats can't e.g. represent [pi](pi.md) exactly), basically all of the popular [programming languages](programming_language.md) have a floating point [data type](data_type.md) that adheres to the IEEE 754 standard, all personal computers also have the floating point hardware unit (FPU) and so it is widely used in all [modern](modern.md) programs. However most of the time a simpler representation of fractional numbers, such as the mentioned [fixed point](fixed_point.md), suffices, and weaker computers (e.g. [embedded](embedded.md)) may lack the hardware support so floating point operations are emulated in software and therefore slow -- remember, float rhymes with [bloat](bloat.md). Prefer fixed point.
**Floating point is tricky**, it works most of the time but a danger lies in programmers relying on this kind of [magic](magic.md) too much, some new generation programmers may not even be very aware of how float works. Even though the principle is not so hard, the emergent complexity of the math is really complex. One floating point expression may evaluate differently on different systems, e.g. due to different rounding settings. One possible pitfall is working with big and small numbers at the same time -- due to differing precision at different scales small values simply get lost when mixed with big numbers and sometimes this has to be worked around with tricks (see e.g. [this](http://the-witness.net/news/2022/02/a-shader-trick/) devlog of The Witness where a float time variable sent into [shader](shader.md) is periodically reset so as to not grow too large and cause the mentioned issue). Another famous trickiness of float is that you shouldn't really be comparing them for equality with a normal `==` operator as small rounding errors may make even mathematically equal expressions unequal (i.e. you should use some range comparison instead). **Floating point is tricky**, it works most of the time but a danger lies in programmers relying on this kind of [magic](magic.md) too much, some new generation programmers may not even be very aware of how float works. Even though the principle is not so hard, the emergent complexity of the math is really complex. One floating point expression may evaluate differently on different systems, e.g. due to different rounding settings. One possible pitfall is working with big and small numbers at the same time -- due to differing precision at different scales small values simply get lost when mixed with big numbers and sometimes this has to be worked around with tricks (see e.g. [this](http://the-witness.net/news/2022/02/a-shader-trick/) devlog of The Witness where a float time variable sent into [shader](shader.md) is periodically reset so as to not grow too large and cause the mentioned issue). Another famous trickiness of float is that you shouldn't really be comparing them for equality with a normal `==` operator as small rounding errors may make even mathematically equal expressions unequal (i.e. you should use some range comparison instead).

3
hack.md Normal file
View file

@ -0,0 +1,3 @@
# Hack
See [hacking](hacking.md).

View file

@ -58,6 +58,7 @@ A great many commonly used tricks in programming could be regarded as hacks even
- **[bytebeat](bytebeat.md)**: A [demoscene](demoscene.md) hack that utilizes integer [overflows](overflow.md) to create rhythm and produce music. - **[bytebeat](bytebeat.md)**: A [demoscene](demoscene.md) hack that utilizes integer [overflows](overflow.md) to create rhythm and produce music.
- Computer [graphics](graphics.md) uses many clever tricks that could possibly be called hacks, e.g. in times when 3D graphics was primitive and didn't allow achieving such effects as mirror reflections easily, some [games](game.md) faked mirrors simply with a hole in the wall behind which the whole mirrored room was placed -- this achieved the same effect as a mirror and didn't require any extra rendering passes or shaders. - Computer [graphics](graphics.md) uses many clever tricks that could possibly be called hacks, e.g. in times when 3D graphics was primitive and didn't allow achieving such effects as mirror reflections easily, some [games](game.md) faked mirrors simply with a hole in the wall behind which the whole mirrored room was placed -- this achieved the same effect as a mirror and didn't require any extra rendering passes or shaders.
- **[quine](quine.md)**: A cleverly constructed self-replicating program in [programming language](programming_language.md) that prints its own source code -- this is a common exercise of language hackers. - **[quine](quine.md)**: A cleverly constructed self-replicating program in [programming language](programming_language.md) that prints its own source code -- this is a common exercise of language hackers.
- **MetaGolfScript [esoteric languages](esolang.md)**: rather than being a nicely designed [code golfing](code_golf.md) language MetaGolfScript invents infinitely many languages, each of which solves one problem with a zero-length program, making it possible to win any golfing contest that allows arbitrary choice of language just by choosing the correct MetaGolfScript language.
- TODO: moar - TODO: moar
## See Also ## See Also

View file

@ -4,7 +4,7 @@ Mipmap (from Latin *multum in parvo*, *many in little*), is a digital image that
A basic form of a mipmap can be explained on the following example. Let's say we have an [RGB](rgb.md) image of size 1024x1024 pixels. To create its mipmap we call the base image level 0 and create progressively smaller versions (different levels) of the image by reducing the size four times (twice along one dimension) at each step. I.e. level 1 will be the base image downscaled to the size 512x512. If we are to use the mipmap for the common purpose of reducing aliasing, the downscaling itself has to be done in a way that doesn't introduce aliasing; this can be done e.g. by downscaling 2x2 areas in the base image into a single pixel by **averaging** the values of those 4 pixels (the averaging is what will prevent aliasing; other downscaling methods may be used depending on the mipmap's purpose, for example for a use as an accelerating structure we may take a maximum or minimum of the 4 pixels). Level 2 will be an image with resolution 256x256 obtained from the 512x512 image, and so on until the last level with size 1x1. In this case we'll have 11 levels which together form our mipmap. A basic form of a mipmap can be explained on the following example. Let's say we have an [RGB](rgb.md) image of size 1024x1024 pixels. To create its mipmap we call the base image level 0 and create progressively smaller versions (different levels) of the image by reducing the size four times (twice along one dimension) at each step. I.e. level 1 will be the base image downscaled to the size 512x512. If we are to use the mipmap for the common purpose of reducing aliasing, the downscaling itself has to be done in a way that doesn't introduce aliasing; this can be done e.g. by downscaling 2x2 areas in the base image into a single pixel by **averaging** the values of those 4 pixels (the averaging is what will prevent aliasing; other downscaling methods may be used depending on the mipmap's purpose, for example for a use as an accelerating structure we may take a maximum or minimum of the 4 pixels). Level 2 will be an image with resolution 256x256 obtained from the 512x512 image, and so on until the last level with size 1x1. In this case we'll have 11 levels which together form our mipmap.
This RGB mipmap can be shown (and represented in memory) as a "fractal image": This RGB mipmap can be shown (and represented in memory) as a "[fractal](fractal.md) image":
``` ```
_______________________________ _______________________________

View file

@ -51,9 +51,9 @@ Let's keep in mind that true LRS computers would be different from the current c
The system might likely lack features one would nowadays call essential for an OS, such as multiple user support (no need if everyone has his own computer and [security](security.md) is not an issue), [virtual memory](virtual_memory.md), complex [GUI](gui.md) etc. There might even be no [multitasking](multitasking.md); a possibility to make a multitasking OS exists, but let's keep in mind that even such things as programs interacting via [pipes](pipe.md) may be somewhat implemented without it (using temporary buffer files into which one program's output is stored before running the next program). The system might likely lack features one would nowadays call essential for an OS, such as multiple user support (no need if everyone has his own computer and [security](security.md) is not an issue), [virtual memory](virtual_memory.md), complex [GUI](gui.md) etc. There might even be no [multitasking](multitasking.md); a possibility to make a multitasking OS exists, but let's keep in mind that even such things as programs interacting via [pipes](pipe.md) may be somewhat implemented without it (using temporary buffer files into which one program's output is stored before running the next program).
The universal OS would assume well behaved programs, as programs would likely be given full control over the computer when run -- this would greatly simplify the system and also computing in general. Doing so would be possible thanks to non-existence of malicious programs (as in good society there would be no need for them) and eliminations of [update culture](update_culture.md). Users would only install a few programs they choose carefully -- programs that have been greatly tested and don't need to be updated. The universal OS would assume well behaved programs, as programs would likely be given full control over the computer when run -- this would greatly simplify the system and also computing in general. Doing so would be possible thanks to non-existence of malicious programs (as in good society there would be no need for them) and elimination of [update culture](update_culture.md). Users would only install a few programs they choose carefully -- programs that have been greatly tested and don't need to be updated.
**On user interface**: the basic interaction mode would of course be the text interface. Programs would have the option to switch to a graphical mode in which they would be able to draw to screen. There would be no such [bloat](bloat.md) as [window managers](window_manager.md) or [desktop environments](desktop_environment.md) -- these are capitalist inventions that aren't really needed as users practically always interacts with just one program at a time. Even in a multitasking system only one program would be drawing to the screen at a time, with user having the option to "alt-tab" between them. This would also simplify program greatly as they wouldn't have to handle bullshit such as dynamically resizing and rearranging their window content. If someone REALLY wanted to have two programs at the screen at the same time, something akin a "screen splitter" might be made to create two virtual screens on one physical screen. **On user interface**: the basic interaction mode would of course be the text interface. Programs would have the option to switch to a graphical mode in which they would be able to draw to screen. There would be no such [bloat](bloat.md) as [window managers](window_manager.md) or [desktop environments](desktop_environment.md) -- these are capitalist inventions that aren't really needed as users practically always interacts with just one program at a time. Even in a multitasking system only one program would be drawing to the screen at a time, with user having the option to "alt-tab" between them. This would also simplify programs greatly as they wouldn't have to handle bullshit such as dynamically resizing and rearranging their window content. If someone REALLY wanted to have two programs at the screen at the same time, something akin a "screen splitter" might be made to create two virtual screens on one physical screen.
**A bit more technical details**: the universal OS could simply be a program that gets executed after computer restart. This program would offer a [shell](shell.md) (textual, graphical, ...) that would allow inspecting the computer, configuring it, and mainly running other programs. Once the user chose to run some program, the OS would load the program to memory and jump to executing it. To get back to the OS the program could hand back control to the OS, or the computer could simply be restarted. If the program crashes, the computer simply restarts back to OS. The OS could also contain functions, kind of an [API](api.md), as part of its code that "userland" programs might call, e.g. for drawing to the screen, reading input etc. (just as e.g. a BIOS usually offers similar functions). Note that shell [scripting](script.md) that executes other programs could still be possible, e.g. by remembering the state of script execution in a file on disc. Same thing could be used for communicating between the OS and programs (e.g. clipboard), i.e. there would still be no need for multitasking. **A bit more technical details**: the universal OS could simply be a program that gets executed after computer restart. This program would offer a [shell](shell.md) (textual, graphical, ...) that would allow inspecting the computer, configuring it, and mainly running other programs. Once the user chose to run some program, the OS would load the program to memory and jump to executing it. To get back to the OS the program could hand back control to the OS, or the computer could simply be restarted. If the program crashes, the computer simply restarts back to OS. The OS could also contain functions, kind of an [API](api.md), as part of its code that "userland" programs might call, e.g. for drawing to the screen, reading input etc. (just as e.g. a BIOS usually offers similar functions). Note that shell [scripting](script.md) that executes other programs could still be possible, e.g. by remembering the state of script execution in a file on disc. Same thing could be used for communicating between the OS and programs (e.g. clipboard), i.e. there would still be no need for multitasking.

View file

@ -14,7 +14,7 @@ Using **[fractals](fractal.md)** (e.g. those in a form of [L-system](l_system.md
There are also other techniques such as [wave function](wave_function.md) collapse which is used especially in tile map generation. Here we basically have some constraints set (such as which tiles can be neighbors) and then consider the initial map a [superposition](superposition.md) of all possible maps that satisfy these constraints -- we then set a random tile (chosen from those with lowest [entropy](entropy.md), i.e. fewest possible options) to a random specific value and propagate the consequences of it to other tiles causing a cascading effect of collapsing the whole map into one of the possible solutions. There are also other techniques such as [wave function](wave_function.md) collapse which is used especially in tile map generation. Here we basically have some constraints set (such as which tiles can be neighbors) and then consider the initial map a [superposition](superposition.md) of all possible maps that satisfy these constraints -- we then set a random tile (chosen from those with lowest [entropy](entropy.md), i.e. fewest possible options) to a random specific value and propagate the consequences of it to other tiles causing a cascading effect of collapsing the whole map into one of the possible solutions.
A good example to think of is generating procedural [textures](texture.md). This is generally done by first generating a basis image or multiple images, e.g. with [noise](noise.md) functions such as [Perlin noise](perlin_noise.md) (it gives us a grayscale image that looks a bit like clouds). We then further process this base image(s) and combine the results in various ways, for example we may use different transformations, [modulations](modulation.md), blending, adding color using [color ramps](color_ramp.md) etc. The whole texture is therefore described by a [graph](graph.md) in which nodes represent the operations we apply; this can literally be done visually in software like [Blender](blender.md) (see its [shader](shader.md) editor). The nice thing is that we can now for example generalize the texture to 3 dimensions, i.e. not only have a flat image, but have a whole volume of a texture that can extremely easily be mapped to 3D objects simply by intersecting it with their surfaces which will yield a completely smooth texturing without any seams; this is quite often used along with [raytracing](raytracing.md) -- we can texture an object by simply taking the coordinates of the ray hit as the 3D texture coordinates, it's that simple. Or we can animate a 2D texture by doing a moving cross section of 3D texture. We can also write the algorithm so that the generated texture has no seams if repeated side-by-side (by using modular "wrap-around" coordinates). We can also generate the texture at any arbitrary resolution as we have a continuous mathematical description of it; we may perform an infinite zoom into it if we want. As if that's not enough, we can also generate almost infinitely many slightly different versions of this texture by simply changing the [seed](seed.md) of [pseudorandom](pseudorandom.md) generator we use. A good example to think of is generating procedural [textures](texture.md). This is generally done by first generating a basis image or multiple images, e.g. with **[noise](noise.md) functions** such as [Perlin noise](perlin_noise.md) (it gives us a grayscale image that looks a bit like clouds). We then further process this base image(s) and combine the results in various ways, for example we may use different transformations, [modulations](modulation.md), blending, adding color using [color ramps](color_ramp.md) etc. The whole texture is therefore described by a [graph](graph.md) in which nodes represent the operations we apply; this can literally be done visually in software like [Blender](blender.md) (see its [shader](shader.md) editor). The nice thing is that we can now for example generalize the texture to 3 dimensions, i.e. not only have a flat image, but have a whole volume of a texture that can extremely easily be mapped to 3D objects simply by intersecting it with their surfaces which will yield a completely smooth texturing without any seams; this is quite often used along with [raytracing](raytracing.md) -- we can texture an object by simply taking the coordinates of the ray hit as the 3D texture coordinates, it's that simple. Or we can animate a 2D texture by doing a moving cross section of 3D texture. We can also write the algorithm so that the generated texture has no seams if repeated side-by-side (by using modular "wrap-around" coordinates). We can also generate the texture at any arbitrary resolution as we have a continuous mathematical description of it; we may perform an infinite zoom into it if we want. As if that's not enough, we can also generate almost infinitely many slightly different versions of this texture by simply changing the [seed](seed.md) of [pseudorandom](pseudorandom.md) generator we use.
We use procedural generation mainly in two ways: We use procedural generation mainly in two ways:

View file

@ -1,8 +1,8 @@
# RGB332 # RGB332
RGB332 is a general 256 color [palette](palette.md) that encodes one color with 1 byte (i.e. 8 bits): 3 bits for red, 3 bits for green and 2 bits for blue (human eye is least sensitive to blue). RGB332 is an implicit palette -- it doesn't have to be stored in memory because the color index itself determines the color and vice versa. Compared to the classic 24 bit RGB (which assigns 8 bits to each of the RGB components), RGB332 is very "[KISS](kiss.md)/[suckless](suckless.md)" and often [good enough](good_enough.md) (especially with [dithering](dithering.md)) as it saves memory, avoids headaches with [endianness](byte_sex.md) and represents each color with just a single number (as opposed to 3), so it is often used in simple and limited computers such as [embedded](embedded.md). It is also in the [public domain](public_domain.md), unlike some other palettes, so it's additionally a legally safe choice. RGB332 also has a "sister palette" called [RGB565](rgb565.md) which uses two bytes instead of one and so offers many more colors. RGB332 is a general 256 color [palette](palette.md) that encodes one color with 1 [byte](byte.md) (i.e. 8 [bits](bit.md)): 3 bits (highest) for red, 3 bits for green and 2 bits (lowest) for blue (as human eye is least sensitive to blue). RGB332 is an implicit palette -- it doesn't have to be stored in memory because the color index itself determines the color and vice versa. Compared to the classic 24 bit RGB (which assigns 8 bits to each of the RGB components), RGB332 is very "[KISS](kiss.md)/[suckless](suckless.md)" and often [good enough](good_enough.md) (especially with [dithering](dithering.md)) as it saves memory, avoids headaches with [endianness](byte_sex.md) and represents each color with just a single number (as opposed to 3), so it is often used in simple and limited computers such as [embedded](embedded.md). It is also in the [public domain](public_domain.md), unlike some other palettes, so it's additionally a legally safe choice. RGB332 also has a "sister palette" called [RGB565](rgb565.md) which uses two bytes instead of one and so offers many more colors.
A disadvantage of plain 332 palette is the linearity of each component's intensity, i.e. lack of [gamma correction](gamma_correction.md), so there are too many almost indistinguishable bright colors while too few darker ones { TODO: does a gamma corrected 332 exist? make it? ~drummyfish }. Another disadvantage is the non-alignment of the blue component with red and green components, i.e. while R/G components have 8 levels of intensity and so step from 0 to 255 by 36.4, the B component only has 4 levels and steps by exactly 85, which makes it impossible to create exact shades of grey (which has to have all R, G and B components equal). A disadvantage of plain 332 palette lies in the linearity of each component's intensity, i.e. lack of [gamma correction](gamma_correction.md), so there are too many almost indistinguishable bright colors while too few darker ones { TODO: does a gamma corrected 332 exist? make it? ~drummyfish }. Another disadvantage is the non-alignment of the blue component with red and green components, i.e. while R/G components have 8 levels of intensity and so step from 0 to 255 by 36.4, the B component only has 4 levels and steps by exactly 85, which makes it impossible to create exact shades of grey (which of course have to have all R, G and B components equal).
The RGB values of the 332 palette are following: The RGB values of the 332 palette are following:
@ -41,15 +41,52 @@ The RGB values of the 332 palette are following:
#ffda00 #ffda55 #ffdaaa #ffdaff #ffff00 #ffff55 #ffffaa #ffffff #ffda00 #ffda55 #ffdaaa #ffdaff #ffff00 #ffff55 #ffffaa #ffffff
``` ```
With RGB332 addition/subtraction of colors can be [approximated](approximation.md) in a very fast way using the [OR](or.md)/[AND](and.md) operation -- however this only works sometimes (check visually). For example if you need to quickly brighten/darken all pixels in a 332 image, you can just OR/AND each pixel with these values: ## Operations
Here are [C](c.md) functions for converting RGB332 to RGB24 and back:
``` ```
unsigned char rgbTo332(unsigned char red, unsigned char green, unsigned char blue)
{
return ((red / 32) << 5) | ((green / 32) << 2) | (blue / 64);
}
void rgbFrom332(unsigned char colorIndex, unsigned char *red, unsigned char *green, unsigned char *blue)
{
unsigned char value = (colorIndex >> 5) & 0x07;
*red = value != 7 ? value * 36 : 255;
value = (colorIndex >> 2) & 0x07;
*green = value != 7 ? value * 36 : 255;
value = colorIndex & 0x03;
*blue = (value != 3) ? value * 72 : 255;
}
```
Addition/subtraction of two RGB332 colors can be performed by simply adding/subtracting the two color values as long as no over/underflow occurs in either component -- by adding the values we basically perform a parallel addition/subtraction of all three components with only one operation. Unfortunately checking for when exactly such overflow occurs is not easy to do quickly { Or is it? ~drummyfish }, but to rule out e.g. an overflow with addition we may for example check whether the highest bit of each component in both colors to be added is 0 (i.e. `if (((color1 & 0x92) | (color2 & 0x92)) == 0) newColor = color1 + color2;`). { Code untested. ~drummyfish }
Addition/subtraction of colors can also be [approximated](approximation.md) in a very fast way using the [OR](or.md)/[AND](and.md) operation instead of arithmetic addition/subtraction -- however this only works sometimes (check visually). For example if you need to quickly brighten/darken all pixels in a 332 image, you can just OR/AND each pixel with these values:
```
brighten by more: doesn't really work anymore
brighten by 3: | 0x6d (011 011 01) brighten by 3: | 0x6d (011 011 01)
brighten by 2: | 0x49 (010 010 01) brighten by 2: | 0x49 (010 010 01)
brighten by 1: | 0x24 (001 001 00) brighten by 1: | 0x24 (001 001 00)
darken by 1: & 0xdb (110 110 11) darken by 1: & 0xdb (110 110 11)
darken by 2: & 0xb6 (101 101 10) darken by 2: & 0xb6 (101 101 10)
darken by 3: & 0x92 (100 100 10) darken by 3: & 0x92 (100 100 10)
darken by more: doesn't really work anymore
``` ```
TODO: conversion to/from RGB24 { TODO: Would it be possible to accurately add two 332 colors by adding all components in parallel using bitwise operators somehow? I briefly tried but the result seemed too complex to be worth it though. ~drummyfish }
Inverting a 332 color is done simply by inverting all bits in the color value.
TODO: blending?
## See Also
- [RGB565](rgb565.md)
- [palette](palette.md)
- [grayscale](grayscale.md)

View file

@ -4,4 +4,4 @@
TODO TODO
In Unicode every character is unique like unicorn. In Unicode every character is unique like a unicorn.