Skip to content
Snippets Groups Projects
Commit 3c3c2cd5 authored by Antony Riakiotakis's avatar Antony Riakiotakis
Browse files

Fix issue with texture painting: Tex slot scale was being applied twice.

parent a89ef761
Branches
Tags
No related merge requests found
...@@ -561,11 +561,8 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, ...@@ -561,11 +561,8 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
x /= (br->stencil_dimension[0]); x /= (br->stencil_dimension[0]);
y /= (br->stencil_dimension[1]); y /= (br->stencil_dimension[1]);
x *= mtex->size[0]; co[0] = x;
y *= mtex->size[1]; co[1] = y;
co[0] = x + mtex->ofs[0];
co[1] = y + mtex->ofs[1];
co[2] = 0.0f; co[2] = 0.0f;
hasrgb = externtex(mtex, co, &intensity, hasrgb = externtex(mtex, co, &intensity,
...@@ -621,11 +618,8 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, ...@@ -621,11 +618,8 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
y = flen * sinf(angle); y = flen * sinf(angle);
} }
x *= mtex->size[0]; co[0] = x;
y *= mtex->size[1]; co[1] = y;
co[0] = x + mtex->ofs[0];
co[1] = y + mtex->ofs[1];
co[2] = 0.0f; co[2] = 0.0f;
hasrgb = externtex(mtex, co, &intensity, hasrgb = externtex(mtex, co, &intensity,
...@@ -985,8 +979,9 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side, bool use_sec ...@@ -985,8 +979,9 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side, bool use_sec
{ {
unsigned int *texcache = NULL; unsigned int *texcache = NULL;
MTex *mtex = (use_secondary) ? &br->mask_mtex : &br->mtex; MTex *mtex = (use_secondary) ? &br->mask_mtex : &br->mtex;
TexResult texres = {0}; float intensity;
int hasrgb, ix, iy; float rgba[4];
int ix, iy;
int side = half_side * 2; int side = half_side * 2;
if (mtex->tex) { if (mtex->tex) {
...@@ -1003,19 +998,13 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side, bool use_sec ...@@ -1003,19 +998,13 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side, bool use_sec
/* This is copied from displace modifier code */ /* This is copied from displace modifier code */
/* TODO(sergey): brush are always cacheing with CM enabled for now. */ /* TODO(sergey): brush are always cacheing with CM enabled for now. */
hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL, true); externtex(mtex, co, &intensity,
rgba, rgba + 1, rgba + 2, rgba + 3, 0, NULL);
/* if the texture gave an RGB value, we assume it didn't give a valid
* intensity, so calculate one (formula from do_material_tex).
* if the texture didn't give an RGB value, copy the intensity across
*/
if (hasrgb & TEX_RGB)
texres.tin = rgb_to_grayscale(&texres.tr);
((char *)texcache)[(iy * side + ix) * 4] = ((char *)texcache)[(iy * side + ix) * 4] =
((char *)texcache)[(iy * side + ix) * 4 + 1] = ((char *)texcache)[(iy * side + ix) * 4 + 1] =
((char *)texcache)[(iy * side + ix) * 4 + 2] = ((char *)texcache)[(iy * side + ix) * 4 + 2] =
((char *)texcache)[(iy * side + ix) * 4 + 3] = (char)(texres.tin * 255.0f); ((char *)texcache)[(iy * side + ix) * 4 + 3] = (char)(intensity * 255.0f);
} }
} }
} }
......
...@@ -238,12 +238,6 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima ...@@ -238,12 +238,6 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
y = len * sinf(angle); y = len * sinf(angle);
} }
x *= mtex->size[0];
y *= mtex->size[1];
x += mtex->ofs[0];
y += mtex->ofs[1];
if (col) { if (col) {
float rgba[4]; float rgba[4];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment