moved texture_space scaling factor from glsl to C.

This commit is contained in:
M.G. Kishalmi 2011-01-30 16:57:28 +00:00
parent d5da54e1e6
commit 1b28e8c162
3 changed files with 798 additions and 796 deletions

@ -1056,12 +1056,14 @@ static void do_material_tex(GPUShadeInput *shi)
} else if( mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) {
/* ntap bumpmap image */
float hScale = 0.1f; // compatibility adjustment factor for all bumpspace types
float fScaleTex = 130.0f; // factor for scaling texspace bumps
float hScaleTex = 13.0f; // factor for scaling texspace bumps
GPUNodeLink *surf_pos = GPU_builtin(GPU_VIEW_POSITION);
GPUNodeLink *vR1, *vR2, *fDet;
GPUNodeLink *dBs, *dBt, *vN;
if( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
hScale = hScaleTex;
norfac = hScale * mtex->norfac;
tnorfac = GPU_uniform(&norfac);
@ -1094,7 +1096,7 @@ static void do_material_tex(GPUShadeInput *shi)
ima_x= ibuf->x; ima_y= ibuf->y;
GPU_link( mat, "mtex_bump_apply_texspace",
fDet, dBs, dBt, vR1, vR2, vN, GPU_image(tex->ima, &tex->iuser), texco, GPU_uniform(&fScaleTex),
fDet, dBs, dBt, vR1, vR2, vN, GPU_image(tex->ima, &tex->iuser), texco,
GPU_uniform(&ima_x), GPU_uniform(&ima_y), &shi->vn );
} else
GPU_link( mat, "mtex_bump_apply",

@ -1194,12 +1194,12 @@ void mtex_bump_apply( float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2, vec3
}
void mtex_bump_apply_texspace( float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2, vec3 vN,
sampler2D ima, vec3 texco, float scale, float ima_x, float ima_y, out vec3 perturbed_norm )
sampler2D ima, vec3 texco, float ima_x, float ima_y, out vec3 perturbed_norm )
{
vec2 TexDx = dFdx(texco.xy);
vec2 TexDy = dFdy(texco.xy);
vec3 vSurfGrad = sign(fDet) * scale * (
vec3 vSurfGrad = sign(fDet) * (
dBs / length( vec2(ima_x*TexDx.x, ima_y*TexDx.y) ) * normalize(vR1) +
dBt / length( vec2(ima_x*TexDy.x, ima_y*TexDy.y) ) * normalize(vR2) );
perturbed_norm = normalize( vN - vSurfGrad );

File diff suppressed because it is too large Load Diff