Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/texture_procedural.c
| Show First 20 Lines • Show All 1,204 Lines • ▼ Show 20 Lines | return multitex_nodes_intern(tex, | ||||
| scene_color_manage, | scene_color_manage, | ||||
| skip_load_image, | skip_load_image, | ||||
| false, | false, | ||||
| false); | false); | ||||
| } | } | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| void RE_texture_mapping_transform(const MTex *mtex, const float in_co[3], float out_co[3]) | |||||
| { | |||||
| /* placement */ | |||||
| if (mtex->projx) { | |||||
| out_co[0] = mtex->size[0] * (in_co[mtex->projx - 1] + mtex->ofs[0]); | |||||
| } | |||||
| else { | |||||
| out_co[0] = mtex->size[0] * (mtex->ofs[0]); | |||||
| } | |||||
| if (mtex->projy) { | |||||
| out_co[1] = mtex->size[1] * (in_co[mtex->projy - 1] + mtex->ofs[1]); | |||||
| } | |||||
| else { | |||||
| out_co[1] = mtex->size[1] * (mtex->ofs[1]); | |||||
| } | |||||
| if (mtex->projz) { | |||||
| out_co[2] = mtex->size[2] * (in_co[mtex->projz - 1] + mtex->ofs[2]); | |||||
| } | |||||
| else { | |||||
| out_co[2] = mtex->size[2] * (mtex->ofs[2]); | |||||
| } | |||||
| } | |||||
| /* ------------------------------------------------------------------------- */ | |||||
| float texture_value_blend(float tex, float out, float fact, float facg, int blendtype) | float texture_value_blend(float tex, float out, float fact, float facg, int blendtype) | ||||
| { | { | ||||
| float in = 0.0, facm, col, scf; | float in = 0.0, facm, col, scf; | ||||
| int flip = (facg < 0.0f); | int flip = (facg < 0.0f); | ||||
| facg = fabsf(facg); | facg = fabsf(facg); | ||||
| fact *= facg; | fact *= facg; | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| bool RE_texture_evaluate(const MTex *mtex, | bool RE_texture_evaluate(const MTex *mtex, | ||||
| const float vec[3], | const float vec[3], | ||||
| const int thread, | const int thread, | ||||
| struct ImagePool *pool, | struct ImagePool *pool, | ||||
| const bool skip_load_image, | |||||
| const bool texnode_preview, | |||||
| /* Return arguments. */ | /* Return arguments. */ | ||||
| float *r_intensity, | float *r_intensity, | ||||
| float r_rgba[4]) | float r_rgba[4]) | ||||
| { | { | ||||
| Tex *tex; | Tex *tex; | ||||
| TexResult texr; | TexResult texr; | ||||
| float dxt[3], dyt[3], texvec[3]; | float dxt[3], dyt[3], texvec[3]; | ||||
| int rgb; | int rgb; | ||||
| tex = mtex->tex; | tex = mtex->tex; | ||||
| if (tex == NULL) { | if (tex == NULL) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* placement */ | /* placement */ | ||||
| if (mtex->projx) { | RE_texture_mapping_transform(mtex, vec, texvec); | ||||
| texvec[0] = mtex->size[0] * (vec[mtex->projx - 1] + mtex->ofs[0]); | |||||
| } | |||||
| else { | |||||
| texvec[0] = mtex->size[0] * (mtex->ofs[0]); | |||||
| } | |||||
| if (mtex->projy) { | |||||
| texvec[1] = mtex->size[1] * (vec[mtex->projy - 1] + mtex->ofs[1]); | |||||
| } | |||||
| else { | |||||
| texvec[1] = mtex->size[1] * (mtex->ofs[1]); | |||||
| } | |||||
| if (mtex->projz) { | |||||
| texvec[2] = mtex->size[2] * (vec[mtex->projz - 1] + mtex->ofs[2]); | |||||
| } | |||||
| else { | |||||
| texvec[2] = mtex->size[2] * (mtex->ofs[2]); | |||||
| } | |||||
| /* texture */ | /* texture */ | ||||
| if (tex->type == TEX_IMAGE) { | if (tex->type == TEX_IMAGE) { | ||||
| do_2d_mapping(mtex, texvec, NULL, dxt, dyt); | do_2d_mapping(mtex, texvec, NULL, dxt, dyt); | ||||
| } | } | ||||
| rgb = multitex(tex, | rgb = multitex( | ||||
| texvec, | tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output, pool, false, false, true); | ||||
| dxt, | |||||
| dyt, | |||||
| 0, | |||||
| &texr, | |||||
| thread, | |||||
| mtex->which_output, | |||||
| pool, | |||||
| skip_load_image, | |||||
| texnode_preview, | |||||
| true); | |||||
| if (rgb) { | if (rgb) { | ||||
| texr.tin = IMB_colormanagement_get_luminance(texr.trgba); | texr.tin = IMB_colormanagement_get_luminance(texr.trgba); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_fl3(texr.trgba, mtex->r, mtex->g, mtex->b); | copy_v3_fl3(texr.trgba, mtex->r, mtex->g, mtex->b); | ||||
| } | } | ||||
| *r_intensity = texr.tin; | *r_intensity = texr.tin; | ||||
| copy_v4_v4(r_rgba, texr.trgba); | copy_v4_v4(r_rgba, texr.trgba); | ||||
| return (rgb != 0); | return (rgb != 0); | ||||
| } | } | ||||