Hi, On Monday, October 24, 2011 10:27:11 thorsten.i.r...@jyu.fi wrote: > My understanding is that > > * the vertex shader computes stuff for each vertex Yes.
> If I don't use a fragment shader (as e.g. in the 3dclouds), things like > shading get a linear interpolation between vertices. You need to have both shaders if you use one of them. Just using one of which is not allowed by gl. To understand what happens I try to give a brief sketch on how this works: varying results from the vertex shader are fed into the rasterizer which takes the primitives and the varyings at the corners and generates fragments (pixels) for these geometries. The scanline algorithm is applied to the varyings which means along the edges of the primitives the varying is interpolated linearily according to its position between the vertices. Then along the scanline the varying result is taken at the two endpoints that are located on the edges the varying is again linearily interpolated for each fragment. This is still the same than it was done in the good old fixed function pipeline days. Just that you have today a variable amount of varyings with arbitrary names that are handled like the above. > * the fragment shader allows me to specify a non-linear function to > interpolate between vertices Hmm, I do not understand this. Understand the above and it gets clear what happens. > If I have two points with distances d1 and d2, I can either compute fog1 = > exp(-d1/vis) and fog2 = exp(-d2/vis) in the vertex shader. > > The result will then be a linear increase in fog from fog1 at d1 to fog2 > at d2 - which is in general very wrong for large d1-d2 because the actual > result is exponential and not linear. Or I can pass d1 and d2 to the > fragment shader and compute the non-linear exponential there - which would > give me the correct result, since a linear interpolation between d1 and d2 > actually should be an exact result. Ok, I see: In other words you are correclty claiming that exp(x*a) != x*exp(a) which just means that the exponential is *not* a linear function. Which means you can't just pull that out of the fragment shader into the vertex stage without changing the results. :) > So there should in fact not be any loss of accuracy when I move linear > quantity computations to the vertex shader, this should only be true if I > move non-linear quantities. > > Is this essentially correct? Essentially yes. Hope this helps Mathias ------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel