Graphics Reference
In-Depth Information
uniform float uAmbient;
uniform float uBumpDensity; // glman slider uniform variables
uniform float uBumpSize;
uniform vec4 uSurfaceColor;
uniform float uAng;
uniform float uHeight;
in vec3 vBTNx, vBTNy, vBTNz;
in vec3 vLightDir;
in vec2 vST;
out vec4 fFragColor;
const float PI = 3.14159265;
float Cang, Sang;
vec3
ToXyz( vec3 btn )
{
float xp = btn.x*Cang - btn.y*Sang; // rotate by +Ang
btn.y = btn.x*Sang + btn.y*Cang;
btn.x = xp;
btn = normalize( btn );
vec3 xyz;
xyz.x = dot( vBTNx, btn ); // convert surface local to
// eye coords
xyz.y = dot( vBTNy, btn );
xyz.z = dot( vBTNz, btn );
return normalize( xyz );
}
void main( )
{
vec2 st = vST; // locate the bumps based on (s,t)
float Swidth = 1. / uBumpDensity;
float Theight= 1. / uBumpDensity;
float numInS = floor( st.s / Swidth );
float numInT = floor( st.t / Theight );
vec2 center;
center.s = numInS * Swidth + Swidth/2.;
center.t = numInT * Theight + Theight/2.;
st -= center; // st is now wrt the center of the bump
Cang = cos(uAng);
Search WWH ::




Custom Search