Vector displacement for the sculpting draw brush #104481
|
@ -55,6 +55,7 @@
|
|||
#include "paint_intern.h"
|
||||
/* still needed for sculpt_stroke_get_location, should be
|
||||
* removed eventually (TODO) */
|
||||
#include "IMB_colormanagement.h"
|
||||
#include "sculpt_intern.h"
|
||||
|
||||
/* TODOs:
|
||||
|
@ -200,10 +201,18 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
|
|||
y = len * sinf(angle);
|
||||
}
|
||||
|
||||
if (col) {
|
||||
float avg;
|
||||
float rgba[4];
|
||||
paint_get_tex_pixel(mtex, x, y, pool, thread_id, &avg, rgba);
|
||||
|
||||
paint_get_tex_pixel_color_with_clamp(mtex, x, y, rgba, pool, thread_id, convert_to_linear, colorspace);
|
||||
if (col) {
|
||||
if (convert_to_linear) {
|
||||
IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, colorspace);
|
||||
}
|
||||
|
||||
linearrgb_to_srgb_v3_v3(rgba, rgba);
|
||||
|
||||
clamp_v4(rgba, 0.0f, 1.0f);
|
||||
|
||||
buffer[index * 4] = rgba[0] * 255;
|
||||
buffer[index * 4 + 1] = rgba[1] * 255;
|
||||
|
@ -211,10 +220,6 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
|
|||
buffer[index * 4 + 3] = rgba[3] * 255;
|
||||
}
|
||||
else {
|
||||
float avg;
|
||||
float rgba_dummy[4];
|
||||
paint_get_tex_pixel(mtex, x, y, pool, thread_id, &avg, rgba_dummy);
|
||||
|
||||
avg += br->texture_sample_bias;
|
||||
|
||||
/* Clamp to avoid precision overflow. */
|
||||
|
|
|
@ -352,16 +352,12 @@ void paint_calc_redraw_planes(float planes[4][4],
|
|||
float paint_calc_object_space_radius(struct ViewContext *vc,
|
||||
const float center[3],
|
||||
float pixel_radius);
|
||||
|
||||
/**
|
||||
* Returns true when a color was sampled and false when a value was sampled.
|
||||
*/
|
||||
bool paint_get_tex_pixel(
|
||||
const struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread, float *r_intensity, float r_rgba[4]);
|
||||
void paint_get_tex_pixel_color_with_clamp(const struct MTex *mtex,
|
||||
float u,
|
||||
float v,
|
||||
float rgba[4],
|
||||
struct ImagePool *pool,
|
||||
int thread,
|
||||
bool convert,
|
||||
struct ColorSpace *colorspace);
|
||||
|
||||
/**
|
||||
* Used for both 3D view and image window.
|
||||
|
|
|
@ -157,47 +157,17 @@ bool paint_get_tex_pixel(const MTex *mtex,
|
|||
{
|
||||
const float co[3] = {u, v, 0.0f};
|
||||
float intensity;
|
||||
const bool hasRGB = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, r_rgba);
|
||||
const bool has_rgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, r_rgba);
|
||||
*r_intensity = intensity;
|
||||
|
||||
if (!hasRGB) {
|
||||
if (!has_rgb) {
|
||||
r_rgba[0] = intensity;
|
||||
r_rgba[1] = intensity;
|
||||
r_rgba[2] = intensity;
|
||||
r_rgba[3] = 1.0f;
|
||||
}
|
||||
|
||||
return hasRGB;
|
||||
}
|
||||
|
||||
void paint_get_tex_pixel_color_with_clamp(const MTex *mtex,
|
||||
float u,
|
||||
float v,
|
||||
float rgba[4],
|
||||
struct ImagePool *pool,
|
||||
int thread,
|
||||
bool convert_to_linear,
|
||||
struct ColorSpace *colorspace)
|
||||
{
|
||||
const float co[3] = {u, v, 0.0f};
|
||||
float intensity;
|
||||
|
||||
const bool hasRGB = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
|
||||
|
||||
if (!hasRGB) {
|
||||
rgba[0] = intensity;
|
||||
rgba[1] = intensity;
|
||||
rgba[2] = intensity;
|
||||
rgba[3] = 1.0f;
|
||||
}
|
||||
|
||||
if (convert_to_linear) {
|
||||
IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, colorspace);
|
||||
}
|
||||
|
||||
linearrgb_to_srgb_v3_v3(rgba, rgba);
|
||||
|
||||
clamp_v4(rgba, 0.0f, 1.0f);
|
||||
return has_rgb;
|
||||
}
|
||||
|
||||
void paint_stroke_operator_properties(wmOperatorType *ot)
|
||||
|
|
|
@ -2588,10 +2588,7 @@ static void sculpt_apply_texture(const SculptSession *ss,
|
|||
|
||||
if (!mtex->tex) {
|
||||
*r_value = 1.0f;
|
||||
r_rgba[0] = 1.0f;
|
||||
r_rgba[1] = 1.0f;
|
||||
r_rgba[2] = 1.0f;
|
||||
r_rgba[3] = 1.0f;
|
||||
copy_v4_fl(r_rgba, 1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue