Hacker News new | ask | show | jobs
by gattr 2743 days ago
I agree it's a great exercise. Years ago I added a very simple stack-based VM to my raytracer to allow procedural textures & normal maps. The scene script would e.g. contain a material description like this:

  material {
      diffuse rgb = [0, 0, 1] * (1-(0.5+0.5*noise(x*0.000002, y*0.000002, z*0.000002, 0.66, 2))) + [1, 1, 1] * (0.5+0.5*noise(x*0.000002, y*0.000002, z*0.000002, 0.66, 2));
  }
i.e. an expression with 3-vectors and scalars and a few basic functions (noise, sin/cos, etc.). This can be easily "compiled" (during script parsing) for execution on the VM. Then the overhead during actual raytracing was quite small.
2 comments

I don't suppose you have code or examples lying around? I'd love to see what you were trying to achieve, the results you had, and the code.

If you're comfortable sharing, that is.

I still have the code (old and ugly, so not on GitHub; but it still builds and works) and examples. Let me know where I should send it.
My email is in my profile.
Is it publicly visible? At the moment in your profile I can only see "about", submissions, comments, favorites.
Guess not. Huh. I added it to my 'about' block.
Could I trouble you to share the code with me as well? Email in profile about box. Thanks!