3Dickulus / FragM

Derived from https://github.com/Syntopia/Fragmentarium/
GNU General Public License v3.0
344 stars 30 forks source link

Cannot find `rand` function #193

Closed neozhaoliang closed 1 year ago

neozhaoliang commented 1 year ago

Hi, I'm new to FragM and I'm using the windows binary of FragM (downloaded from the release page), and I tried the demo neozhaoliang-Boyd-Maxwell-Ball-Packings in the example list. But it reports an error

rand: no matching overloaded function found

Is this a bug, or I'm missing something here?

3Dickulus commented 1 year ago

You need to... #include "MathUtils.frag" before #include "DE-Raytracer.frag" a.k.a. DE-Kn2cr11.frag

because the math functions reside in MathUtils.frag, check this file for special #defines for different random algorithms NV_RAND WANG_HASH etc.

if none are defined then you should at least get the default functions...

float rand(float v) float rand(vec2 pos) float rand(vec3 co) vec2 rand2(vec2 co)

there are also some other functions and useful defines as well along with notes in comment lines.

if you have specialized math functions you want to use in other frags then this file is the place for them ;)

Also, remove the files DE-Kn2cr11.frag 3DKn-1.0.5.frag BufferShader-1.0.2.frag from your folders so that your frag uses the ones from the distribution Examples/Include/ folder

If you have modified these files you will need to remove the rand() functions, all of the raytracer frags in the Examples/Include/ are expecting the functions from MathUtils.frag to be present and available.

you may have to add "#version 140" as the first line of your fragment too.

when I remove those files and add "#version 140" as the first line of your fragment it compiles and runs on my setup..

Vendor: NVIDIA Corporation Renderer: NVIDIA GeForce GTX 1650 SUPER/PCIe/SSE2 GL Driver: 4.5.0 NVIDIA 525.78.01 Display using GL 4.5 Core profile Screenshot_20230116_192907

3Dickulus commented 1 year ago

...and if you have made improvements to any of the DE 3D or BufferShader* frags I would be happy to review a pull or merge request.

neozhaoliang commented 1 year ago

Thanks for this detailed help! I have successfully made FragM run on my windows machine, and I'm planning to refactor & improve my example. Thank again for your help!

neozhaoliang commented 1 year ago

@3Dickulus Hi, I recently refactored my code, and there were two main changes:

  1. I rewrote https://github.com/neozhaoliang/Hyperbolic-Honeycombs/blob/main/3D-ball-packings/Ball-Packings-UpperHalfSpace.frag. In the previous version, the computations in this file were too computationally intensive, which made it impossible for users with lower-performing CPUs to run the program. Now, this example should be able to run on most Nvidia graphics cards.

  2. I added a 2D example: https://github.com/neozhaoliang/Hyperbolic-Honeycombs/blob/main/2D-circle-packings/circle-packings.frag. You can see the sample results here: https://github.com/neozhaoliang/Hyperbolic-Honeycombs#2d-circle-packings-rank--4-level--2.

Please let me know if these examples cannot be run in FragM. Thank you.