Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/render_texture.c
| Context not available. | |||||
| extern struct Render R; | extern struct Render R; | ||||
| /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ | ||||
| static RNG_THREAD_ARRAY *random_tex_array; | |||||
| void RE_init_texture_rng() | |||||
| { | |||||
| random_tex_array = BLI_rng_threaded_new(); | |||||
| } | |||||
| void RE_exit_texture_rng() | |||||
| { | |||||
| BLI_rng_threaded_free(random_tex_array); | |||||
| } | |||||
| static void init_render_texture(Render *re, Tex *tex) | static void init_render_texture(Render *re, Tex *tex) | ||||
| { | { | ||||
| Context not available. | |||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| static int texnoise(Tex *tex, TexResult *texres, int thread) | static int texnoise(Tex *tex, TexResult *texres) | ||||
| { | { | ||||
| float div=3.0; | float div=3.0; | ||||
| int val, ran, loop, shift = 30; | int val, ran, loop; | ||||
| ran= BLI_rng_thread_rand(random_tex_array, thread); | ran= BLI_rand(); | ||||
| val= (ran & 3); | |||||
| loop= tex->noisedepth; | loop= tex->noisedepth; | ||||
| /* start from top bits since they have more variance */ | |||||
| val= ((ran >> shift) & 3); | |||||
| while (loop--) { | while (loop--) { | ||||
| shift -= 2; | ran= (ran>>2); | ||||
| val += ((ran >> shift) & 3); | val*= (ran & 3); | ||||
| div += 3.0f; | div*= 3.0f; | ||||
| } | } | ||||
| texres->tin= ((float)val)/div; | texres->tin= ((float)val)/div; | ||||
| Context not available. | |||||
| retval = stucci(tex, texvec, texres); | retval = stucci(tex, texvec, texres); | ||||
| break; | break; | ||||
| case TEX_NOISE: | case TEX_NOISE: | ||||
| retval = texnoise(tex, texres, thread); | retval = texnoise(tex, texres); | ||||
| break; | break; | ||||
| case TEX_IMAGE: | case TEX_IMAGE: | ||||
| if (osatex) retval = imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool); | if (osatex) retval = imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool); | ||||
| Context not available. | |||||
| col[0]= texres.tr*la->energy; | col[0]= texres.tr*la->energy; | ||||
| col[1]= texres.tg*la->energy; | col[1]= texres.tg*la->energy; | ||||
| col[2]= texres.tb*la->energy; | col[2]= texres.tb*la->energy; | ||||
| if (effect & LA_SHAD_TEX) | texture_rgb_blend(col_r, col, col_r, texres.tin, mtex->colfac, mtex->blendtype); | ||||
| texture_rgb_blend(col_r, col, col_r, texres.tin, mtex->shadowfac, mtex->blendtype); | |||||
| else | |||||
| texture_rgb_blend(col_r, col, col_r, texres.tin, mtex->colfac, mtex->blendtype); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||