Comments (4)
The following intrinsics have a limited domain where their output is defined and meaningful. Documentation for both HLSL shader model 3 and GLSL say that the output of sqrt(x)
where x < 0
, for instance, say the output is NaN. However, in reality this function returns sqrt(abs(x))
if x < 0
in DX9's shader model 3 implementation. This has been verified using BeatDrop 1.3.1 after installing DX9 (note that BeatDrop requires DX9 specifically; otherwise you'll get errors about shader model 3 being reported as supported but non-functional).
By creating a shader that plots the output of these intrinsics, we can easily verify the behavior of each intrinsic. Here are the presets I used to plot these intrinsics. The R+G channels plot the unmodified intrinsic. The B channel plots the modified function to be used in projectM. If the plot has no yellow or blue regions, these functions overlap perfectly.
The functions include:
acos
: Defined only on the range [-1,1]. Shader model 3 appears to implement this using hyperbolic functions (this is just a guess) that remain valid outside of this range, but the equation is unknown. In an attempt to qualitatively replicate this behavior in GLSL, I've created a simple polynomial function and piecewise extended the function outside of the range [-1:1].asin
: Same as theacos
implementation. The same polynomial is used to mimic the SM3 behavior.pow
: This function actually behaves identically in HLSL and GLSL. If the first argument is negative, the output should be NaN according to the documentation. The actual output ispow(abs(x),y)
unless y is actually a constant integer, in which case the result is actuallyx^y
. Note the difference in behavior between pow.milk and pow_constant.milk in the attached presets.rsqrt
: The inverse square root is defined on the range [0,inf). SM3 appears to take the absolute value before taking the inverse square root, so this is replaced withrsqrt(abs(x))
in GLSL.sqrt
: Same asrsqrt
.log, log2, log10
: Same asrsqrt
; shader model 3 appears to take the absolute value of the argument before taking the logarithm (note I forgot to include the log presets but you can easily create them).
The trigonometric functions are not perfect, but qualitatively mimic the shader model 3 implementation until the actual function can be found:
The sqrt
and rsqrt
functions clearly show the abs
behavior:
from projectm.
Note this isn't directly related to issue #725. While the other issue fixed some now superfluous negations in the u/v coordinates of the warp mesh, the issue here still remains unsolved.
from projectm.
@dpw13 has identified the issue to be undocumented, undefined and unexpected behavior in HLSL, causing some math functions like pow, sqrt and log to produce results even with negative input values, which - according to the HLSL documentation - should return NaN
or Inf
, but in reality seemingly take the absolute value of the parameter in question and thus return some kind of mirrored value.
Dane is fixing it in the hlslparser by adding abs()
around the problematic parameters to make the shader behave in a similar fashion.
from projectm.
There still are issues here and there, but the major part is done. Anything else, we'll fix over time - that is, if it's possible.
from projectm.
Related Issues (20)
- Nintendo Switch Support HOT 3
- Add the ability to control the actual running time from the outside. HOT 1
- Some way to cap how epileptic presets can be HOT 18
- White screen on Soft Cuts HOT 7
- Fix GLES/Emscripten rendering issues HOT 1
- preset soft transitions don't work on Mac
- Try out libniceshade as a replacement for hlslparser
- Tracking projectm in downstream package ecosystem HOT 3
- Broken transition? HOT 6
- Instance creation fails on some Android devices HOT 5
- Put the free version of the app to fdroid. HOT 1
- Android HOT 2
- Add API call to supply a "burn-in" texture for the next frame
- Crowdsourced localization ? HOT 3
- Preset Parser to Support Syntax Specifications HOT 6
- Foobar2000 visualization plugin HOT 1
- cannot get projectm to build on Fedora 40. can't locate OpenGL libraries[DEV BUG] HOT 2
- Integrating projectM into a web app HOT 27
- [FEATURE] winamp 5.9.2 plugin HOT 1
- Problems compiling ProjectM 4.1.1 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from projectm.