0
\$\begingroup\$

I saw this How can I Compute steepness for heightmap while looking for a way to reflect pixels. But now that I have the steepness/slope I don't know how to calculate which angle it's pointing at. Imagine if I had an image parallel (directly above my heightmap) with my heightmap and 100(units/pixels) away/above from it, if the steepness is 0, then i just grab a pixel at that same [x,y]. Imagine that i am trying reflect what the heightmap would show if i was to be able to see through my image.

But let's say I have a steepness of 1 which i am guessing is 45 degrees since 1/1 is 45 degrees but which pixel should i be grabbing from my image how do I calculate what angle the pixel is coming from [x,y].

How would i calculate which pixel(location) is reflected onto the heightmap (imagining that the heightmap is a chrome surface).

I know if the angle is too steep it'll be way outside of the image but I'll just use min/max hack to grab border pixels (unless you can think of another method to handle that) but for angles that are inside my image still...how do I calculate which pixels to reflect.

Basically trying to render an image reflected by height-map when image is placed directly above heightmap with variable input of distance between image and heightmap (use like 100 units as example, but i want to allow user the ability to change this distand)

Please explain in easy terms as sometimes I don't understand rare mathematics notation/symbols.

Thanks in advance.

EDIT: This got me searching for calculating normal for heightmap I think I found what I was looking for.

\$\endgroup\$
9
  • \$\begingroup\$ Is it safe to assume you're looking down on this heightmap with a perspective camera? Do you need to model parallax & occlusion effects? (eg. a tall hill in the heightmap obscures some of the heightmap behind it) \$\endgroup\$
    – DMGregory
    Mar 12, 2018 at 16:27
  • \$\begingroup\$ tall hill in height map will not obscure anything as that's too complex with multiple bounces.. I just one one bounce of the image above it like high hills in height map will act as invisible objects so that lower valleys can reflect what can be seen from image above. \$\endgroup\$
    – Tin Tran
    Mar 12, 2018 at 16:34
  • \$\begingroup\$ Or unless it's not too complex I'll make it true reflection...but i think multiple bounces would be way above my udnerstanding capability \$\endgroup\$
    – Tin Tran
    Mar 12, 2018 at 16:35
  • \$\begingroup\$ I don't know what you mean by perspective camera...but I don't think i want to do real perpective calculations i just want it like if i was able to look down directly at every pixel on the heightmap \$\endgroup\$
    – Tin Tran
    Mar 12, 2018 at 16:36
  • \$\begingroup\$ or if methods are already developed for true reflection..how do I render the heightmap where the heightmap is made of chrome and put at bottom of a box, and the walls around it are all chrome, and an image is above on the top, how to calculate that. That would be cool too. I have never done .... real reflection anything. so how would you keep bouncing a ray against surfaces until you find information to reflect which is when it hits the above image. \$\endgroup\$
    – Tin Tran
    Mar 12, 2018 at 16:44

1 Answer 1

0
\$\begingroup\$

https://stackoverflow.com/questions/5281261/generating-a-normal-map-from-a-height-map

No real reflection or complex stuff like ray tracing. But I was able to use the 2nd answer to calculate normal of height-map which i then grabbed the pixel at that normal coordinate to use for my GIMP script.

\$\endgroup\$
1
  • \$\begingroup\$ Don't forget to mark this answer as Accepted if it worked for you. \$\endgroup\$
    – DMGregory
    Aug 12, 2022 at 13:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .