[Bf-committers] Bump mapping computation issue
Stephane SOPPERA
stephane.soppera at wanadoo.fr
Mon Dec 6 09:06:45 CET 2004
Jonathan Merritt wrote:
> Hi Stephane,
>
> I have a couple of quick questions. You seem to be quite familiar
> with this, so I thought I'd ask first before digging into the code... :-)
>
> Stephane SOPPERA wrote:
>
>> So if I'm not wrong, textures in blender already returns a vector
>> that contains the coordinates in texture space of the vector to add
>> to the normal:
>>
>> tex->nor[0]= (val1-val2);
>> tex->nor[1]= (val1-val3);
>
>
>
> Do you know where these come from? How are they calculated?
I got those two lines from image.c, line 1525.
As far as I know:
tex->nor[0]=image(u+du,v)-image(u)
tex->nor[1]=image(u,v+dv)-image(v)
so for me they represent dI/du and dI/dv (see my first mail). In these
formula, u and v are texture coordinates (that also happen to be image
coordinates).
> I'm asking because a common approach for bump mapping in REYES based
> renderers is to perturb the micropolygon coordinates and calculate the
> effective surface normals numerically. The function
> "calculatenormal()" is provided specifically for this purpose:
> Pshad = P + displacement * N;
Is that for bump mapping only, or does it implements displacement mapping?
I don't know how REYES renderers work, so maybe my question does not
make sense.
> N = calculatenormal(Pshad);
> where:
> Pshad - the "effective" location of the point used for shading
> calculations
> displacement - scalar displacement (eg: from a single channel texture)
> N - surface normal vector
> calculatenormal(Pshad) = dPshad/du (cross product with) dPshad/dv
How dPshad/du and dPshad/dv computed? Are they considered constant on a
triangle? (I excpect the answer to be no, otherwise the shading would be
uniform for each triangle, wouldn't it?)
u and v are texture coordinates? or are they pixel coordinates? (once
again, I don't know REYES renderers, so maybe my question does not make
sense)
>
> In practice this can be done because entire grids of micropolygons are
> shaded at once, so the Pshad values are all set (stored in the
> micropolygon data shading structures) before calculatenormal() is called.
>
> So, maybe nor[0] and nor[1] already incorporate dP/du and dP/dv?
What do you mean by "incorporate"? I'm not sure to understand.
Given what I wrote before about the meaning of (nor[0],nor[1])=(dI/du,
dI/dv), I think that the answer to you question is no, it does not
incorporate them.
Bye,
Stephane
--
Stephane SOPPERA
http://perso.wanadoo.fr/stephane.soppera
More information about the Bf-committers
mailing list