# How do I calculate where which pixel it's reflecting based on a height map?

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.

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

• 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) Mar 12, 2018 at 16:27
• 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. Mar 12, 2018 at 16:34
• 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 Mar 12, 2018 at 16:35
• 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 Mar 12, 2018 at 16:36
• 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. Mar 12, 2018 at 16:44