Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!

GeoClipMap and Point Sampling with Linear Interpolation

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 PhillipHamlyn   Members   -  Reputation: 499


Posted 15 February 2013 - 11:46 AM



I just want to check an assumption before I go diving off into code; the standard Vertex Texture Fetch (text2dlod) with "manual" linear interpolation as shown here http://www.catalinzima.com/tutorials/4-uses-of-vtf/terrain-rendering-using-heightmaps/ wont work with a GeoClipMap style of heightmap rendering will it ?


I have an initial version which gives very weird results, and I'm attributing it to the fact that the point sampler used in text2dlod is a nearest point sampler, but linear interpolation examples that I've seen for VTF show a simple frac() of the initial texture coords to get the weighting for the neighbour texture pixels.  I think this wont be accurate will it ?; becuase the frac() is carried out on the initial texture coordinates, but the point sampler isn't working on a trunc() basis but a round() basis - if the geometry is fixed to that texture coord then you'd never notice it, but with a GeoClipMap the texture coord is calculated from world space dynamically and constantly changes - which means I get weird jumping artefacts as the camera moves and the vertexes texture coord slides from one pixel to another - suddenly jumping pixels when the rounding point is hit (I presume also that its Bankers Rounding so actually behaves differently for each pixel offset).


Can anyone with a geoclipmap implementation tell me if this is the right direction I'm going it, or am I chasing shadows ?


Phillip H


#2 PhillipHamlyn   Members   -  Reputation: 499


Posted 18 February 2013 - 01:15 PM



Just to keep the trail clean, and to answer my own question.


Since Point sampling is the only one allowed for a vertex texture fetch (VTF) and it works on nearest point (i.e. round()) not trunc() most examples of manual linear interpolation will not work if the Vertex position moves between frames (such as when you are doing a geoclipmap or other camera-anchored vertexes which then use world oriented data for height lookups or other stuff).


Most examples dont really care if the Lerp operation is offset agains the "wrong" pixel in the texture. When you are presenting a camera-anchored vertex buffer then the user will see all sorts of popping and flipping if you dont change the manual linear filter implementation.


I haven't tested this thoroughly, but I need to check the actual pixel that is sampled by calculating my texture offset using a trunc() of my initial texture UV * textureSize. I can then safely Lerp() the Frac() of the initial texture UV * textureSize since I know that I have definitely sampled the correct pixel, and not been rounded to the next one (in which case frac() would be useless).


I'll post my outcome once I've tested this.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.