Hey all
I have written this displacement shader and am having problems getting
it to do what I want it too. Its about 70% way there, which is
annoying.
when I render, I am getting flat planes where there should be risers
and some of the risers are also inverted.
Here is the code below. Any help with this would be really
appreciated.
Thanx Dave Robinson
#define oddtile(x) (mod(x, 2) == 1)
#define eventile(x) (mod(x, 2) == 0)
#define whichtile(x,freq) (floor((x) * (freq)))
displacement CsDisplace( float Km = 0.3;
string texFile = "";
float modcontrol = 3.0;)
{
normal n = normalize(N);
float dispval = 0;
float row;
float col;
float ss = mod(s * modcontrol, 1);
float tt = mod(t * modcontrol, 1);
row = whichtile(s, modcontrol);
col = whichtile(t, modcontrol);
if(oddtile(col)){
if(oddtile(row)){
if (texFile != "")
dispval = texture(texFile, ss, tt);
}else{
dispval = texture(texFile, tt, ss);
}
}else{
if(oddtile(row)){
if (texFile != ""){
dispval = texture(texFile, t, s);
}else{
dispval = texture(texFile, s, t);
}
}
}
P = P - n * dispval * Km;
N = calculatenormal(P);
}


|