forked from bartvdbraak/blender
moved texture_space scaling factor from glsl to C.
This commit is contained in:
parent
d5da54e1e6
commit
1b28e8c162
@ -1056,12 +1056,14 @@ static void do_material_tex(GPUShadeInput *shi)
|
|||||||
} else if( mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) {
|
} else if( mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) {
|
||||||
/* ntap bumpmap image */
|
/* ntap bumpmap image */
|
||||||
float hScale = 0.1f; // compatibility adjustment factor for all bumpspace types
|
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 *surf_pos = GPU_builtin(GPU_VIEW_POSITION);
|
||||||
GPUNodeLink *vR1, *vR2, *fDet;
|
GPUNodeLink *vR1, *vR2, *fDet;
|
||||||
GPUNodeLink *dBs, *dBt, *vN;
|
GPUNodeLink *dBs, *dBt, *vN;
|
||||||
|
|
||||||
|
if( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
||||||
|
hScale = hScaleTex;
|
||||||
norfac = hScale * mtex->norfac;
|
norfac = hScale * mtex->norfac;
|
||||||
tnorfac = GPU_uniform(&norfac);
|
tnorfac = GPU_uniform(&norfac);
|
||||||
|
|
||||||
@ -1094,7 +1096,7 @@ static void do_material_tex(GPUShadeInput *shi)
|
|||||||
ima_x= ibuf->x; ima_y= ibuf->y;
|
ima_x= ibuf->x; ima_y= ibuf->y;
|
||||||
|
|
||||||
GPU_link( mat, "mtex_bump_apply_texspace",
|
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 );
|
GPU_uniform(&ima_x), GPU_uniform(&ima_y), &shi->vn );
|
||||||
} else
|
} else
|
||||||
GPU_link( mat, "mtex_bump_apply",
|
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,
|
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 TexDx = dFdx(texco.xy);
|
||||||
vec2 TexDy = dFdy(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) +
|
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) );
|
dBt / length( vec2(ima_x*TexDy.x, ima_y*TexDy.y) ) * normalize(vR2) );
|
||||||
perturbed_norm = normalize( vN - vSurfGrad );
|
perturbed_norm = normalize( vN - vSurfGrad );
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user