GPUMaterial: Make Mapping node use UBO storage
This means tweaking parameter is now interactive and does not need to recompile the shaders.
This commit is contained in:
parent
ad64cb6344
commit
e8dd5e5cc6
|
@ -238,13 +238,11 @@ void point_map_to_tube(vec3 vin, out vec3 vout)
|
|||
vout = vec3(u, v, 0.0);
|
||||
}
|
||||
|
||||
void mapping(vec3 vec, mat4 mat, vec3 minvec, vec3 maxvec, float domin, float domax, out vec3 outvec)
|
||||
void mapping(vec3 vec, vec4 m0, vec4 m1, vec4 m2, vec4 m3, vec3 minvec, vec3 maxvec, out vec3 outvec)
|
||||
{
|
||||
mat4 mat = mat4(m0, m1, m2, m3);
|
||||
outvec = (mat * vec4(vec, 1.0)).xyz;
|
||||
if (domin == 1.0)
|
||||
outvec = max(outvec, minvec);
|
||||
if (domax == 1.0)
|
||||
outvec = min(outvec, maxvec);
|
||||
outvec = clamp(outvec, minvec, maxvec);
|
||||
}
|
||||
|
||||
void camera(vec3 co, out vec3 outview, out float outdepth, out float outdist)
|
||||
|
|
|
@ -253,13 +253,18 @@ void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in
|
|||
float domax = (texmap->flag & TEXMAP_CLIP_MAX) != 0;
|
||||
|
||||
if (domin || domax || !(texmap->flag & TEXMAP_UNIT_MATRIX)) {
|
||||
GPUNodeLink *tmat = GPU_uniform((float *)texmap->mat);
|
||||
GPUNodeLink *tmin = GPU_uniform(texmap->min);
|
||||
GPUNodeLink *tmax = GPU_uniform(texmap->max);
|
||||
GPUNodeLink *tdomin = GPU_uniform(&domin);
|
||||
GPUNodeLink *tdomax = GPU_uniform(&domax);
|
||||
static float max[3] = { FLT_MAX, FLT_MAX, FLT_MAX};
|
||||
static float min[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
|
||||
GPUNodeLink *tmin, *tmax, *tmat0, *tmat1, *tmat2, *tmat3;
|
||||
|
||||
GPU_link(mat, "mapping", in[0].link, tmat, tmin, tmax, tdomin, tdomax, &in[0].link);
|
||||
tmin = GPU_uniform_buffer((domin) ? texmap->min : min, GPU_VEC3);
|
||||
tmax = GPU_uniform_buffer((domax) ? texmap->max : max, GPU_VEC3);
|
||||
tmat0 = GPU_uniform_buffer((float *)texmap->mat[0], GPU_VEC4);
|
||||
tmat1 = GPU_uniform_buffer((float *)texmap->mat[1], GPU_VEC4);
|
||||
tmat2 = GPU_uniform_buffer((float *)texmap->mat[2], GPU_VEC4);
|
||||
tmat3 = GPU_uniform_buffer((float *)texmap->mat[3], GPU_VEC4);
|
||||
|
||||
GPU_link(mat, "mapping", in[0].link, tmat0, tmat1, tmat2, tmat3, tmin, tmax, &in[0].link);
|
||||
|
||||
if (texmap->type == TEXMAP_TYPE_NORMAL)
|
||||
GPU_link(mat, "texco_norm", in[0].link, &in[0].link);
|
||||
|
|
|
@ -88,13 +88,18 @@ static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS
|
|||
TexMapping *texmap = node->storage;
|
||||
float domin = (texmap->flag & TEXMAP_CLIP_MIN) != 0;
|
||||
float domax = (texmap->flag & TEXMAP_CLIP_MAX) != 0;
|
||||
GPUNodeLink *tmat = GPU_uniform((float *)texmap->mat);
|
||||
GPUNodeLink *tmin = GPU_uniform(texmap->min);
|
||||
GPUNodeLink *tmax = GPU_uniform(texmap->max);
|
||||
GPUNodeLink *tdomin = GPU_uniform(&domin);
|
||||
GPUNodeLink *tdomax = GPU_uniform(&domax);
|
||||
static float max[3] = { FLT_MAX, FLT_MAX, FLT_MAX, 0.0};
|
||||
static float min[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX, 0.0};
|
||||
GPUNodeLink *tmin, *tmax, *tmat0, *tmat1, *tmat2, *tmat3;
|
||||
|
||||
GPU_stack_link(mat, node, "mapping", in, out, tmat, tmin, tmax, tdomin, tdomax);
|
||||
tmin = GPU_uniform_buffer((domin) ? texmap->min : min, GPU_VEC3);
|
||||
tmax = GPU_uniform_buffer((domax) ? texmap->max : max, GPU_VEC3);
|
||||
tmat0 = GPU_uniform_buffer((float *)texmap->mat[0], GPU_VEC4);
|
||||
tmat1 = GPU_uniform_buffer((float *)texmap->mat[1], GPU_VEC4);
|
||||
tmat2 = GPU_uniform_buffer((float *)texmap->mat[2], GPU_VEC4);
|
||||
tmat3 = GPU_uniform_buffer((float *)texmap->mat[3], GPU_VEC4);
|
||||
|
||||
GPU_stack_link(mat, node, "mapping", in, out, tmat0, tmat1, tmat2, tmat3, tmin, tmax);
|
||||
|
||||
if (texmap->type == TEXMAP_TYPE_NORMAL)
|
||||
GPU_link(mat, "texco_norm", out[0].link, &out[0].link);
|
||||
|
|
Loading…
Reference in New Issue