diff options
20 files changed, 377 insertions, 241 deletions
diff --git a/release/scripts/ui/buttons_texture.py b/release/scripts/ui/buttons_texture.py index 9765aa93ca4..6eab84afc42 100644 --- a/release/scripts/ui/buttons_texture.py +++ b/release/scripts/ui/buttons_texture.py @@ -175,14 +175,14 @@ class TEXTURE_PT_mapping(TextureSlotPanel): row.itemR(tex, "z_mapping", text="") if br: - layout.itemR(tex, "brush_map_mode", expand=True) + layout.itemR(tex, "map_mode", expand=True) row = layout.row() - row.active = tex.brush_map_mode in ('FIXED', 'TILED') + row.active = tex.map_mode in ('FIXED', 'TILED') row.itemR(tex, "angle") row = layout.row() - row.active = tex.brush_map_mode in ('TILED', '3D') + row.active = tex.map_mode in ('TILED', '3D') row.column().itemR(tex, "size") else: row = layout.row() diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index d60737d62fe..3549d3e372d 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -43,7 +43,7 @@ struct bContext; struct ReportList; #define BLENDER_VERSION 250 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e63b77a134e..f4f5a1364a3 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2057,7 +2057,7 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float } static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *rootco, float effector, float dfra, float cfra, float *length, float *vec) { - float force[3] = {0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}; + float force[3] = {0.0f,0.0f,0.0f}; ParticleKey eff_key; EffectedPoint epoint; @@ -3410,9 +3410,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float mtex=ma->mtex[m]; if(mtex && (ma->septex & (1<<m))==0 && mtex->pmapto){ float def=mtex->def_var; - float var=mtex->varfac; short blend=mtex->blendtype; - short neg=mtex->pmaptoneg; if((mtex->texco & TEXCO_UV) && fw) { if(!get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texco)) @@ -3427,18 +3425,18 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float ptex->time=0.0; setvars|=MAP_PA_TIME; } - ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,var,blend,neg & MAP_PA_TIME); + ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,mtex->timefac,blend); } if((event & mtex->pmapto) & MAP_PA_LENGTH) - ptex->length= texture_value_blend(def,ptex->length,value,var,blend,neg & MAP_PA_LENGTH); + ptex->length= texture_value_blend(def,ptex->length,value,mtex->lengthfac,blend); if((event & mtex->pmapto) & MAP_PA_CLUMP) - ptex->clump= texture_value_blend(def,ptex->clump,value,var,blend,neg & MAP_PA_CLUMP); + ptex->clump= texture_value_blend(def,ptex->clump,value,mtex->clumpfac,blend); if((event & mtex->pmapto) & MAP_PA_KINK) - ptex->kink= texture_value_blend(def,ptex->kink,value,var,blend,neg & MAP_PA_KINK); + ptex->kink= texture_value_blend(def,ptex->kink,value,mtex->kinkfac,blend); if((event & mtex->pmapto) & MAP_PA_ROUGH) - ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def,ptex->rough1,value,var,blend,neg & MAP_PA_ROUGH); + ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def,ptex->rough1,value,mtex->roughfac,blend); if((event & mtex->pmapto) & MAP_PA_DENS) - ptex->exist= texture_value_blend(def,ptex->exist,value,var,blend,neg & MAP_PA_DENS); + ptex->exist= texture_value_blend(def,ptex->exist,value,mtex->padensfac,blend); } } if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); } @@ -3462,10 +3460,8 @@ void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *p if(ma) for(m=0; m<MAX_MTEX; m++){ mtex=ma->mtex[m]; if(mtex && (ma->septex & (1<<m))==0 && mtex->pmapto){ - float var=mtex->varfac; float def=mtex->def_var; short blend=mtex->blendtype; - short neg=mtex->pmaptoneg; if((mtex->texco & TEXCO_UV) && ELEM(sim->psys->part->from, PART_FROM_FACE, PART_FROM_VOLUME)) { if(!get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texco)) { @@ -3482,29 +3478,31 @@ void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *p if((event & mtex->pmapto) & MAP_PA_TIME){ /* the first time has to set the base value for time regardless of blend mode */ if((setvars&MAP_PA_TIME)==0){ - ptex->time *= 1.0f - var; - ptex->time += var * ((neg & MAP_PA_TIME)? 1.0f - value : value); + int flip= (mtex->timefac < 0.0f); + float timefac= fabsf(mtex->timefac); + ptex->time *= 1.0f - timefac; + ptex->time += timefac * ((flip)? 1.0f - value : value); setvars |= MAP_PA_TIME; } else - ptex->time= texture_value_blend(def,ptex->time,value,var,blend,neg & MAP_PA_TIME); + ptex->time= texture_value_blend(def,ptex->time,value,mtex->timefac,blend); } if((event & mtex->pmapto) & MAP_PA_LIFE) - ptex->life= texture_value_blend(def,ptex->life,value,var,blend,neg & MAP_PA_LIFE); + ptex->life= texture_value_blend(def,ptex->life,value,mtex->lifefac,blend); if((event & mtex->pmapto) & MAP_PA_DENS) - ptex->exist= texture_value_blend(def,ptex->exist,value,var,blend,neg & MAP_PA_DENS); + ptex->exist= texture_value_blend(def,ptex->exist,value,mtex->padensfac,blend); if((event & mtex->pmapto) & MAP_PA_SIZE) - ptex->size= texture_value_blend(def,ptex->size,value,var,blend,neg & MAP_PA_SIZE); + ptex->size= texture_value_blend(def,ptex->size,value,mtex->sizefac,blend); if((event & mtex->pmapto) & MAP_PA_IVEL) - ptex->ivel= texture_value_blend(def,ptex->ivel,value,var,blend,neg & MAP_PA_IVEL); + ptex->ivel= texture_value_blend(def,ptex->ivel,value,mtex->ivelfac,blend); if((event & mtex->pmapto) & MAP_PA_PVEL) - texture_rgb_blend(ptex->pvel,rgba,ptex->pvel,value,var,blend); + texture_rgb_blend(ptex->pvel,rgba,ptex->pvel,value,mtex->pvelfac,blend); if((event & mtex->pmapto) & MAP_PA_LENGTH) - ptex->length= texture_value_blend(def,ptex->length,value,var,blend,neg & MAP_PA_LENGTH); + ptex->length= texture_value_blend(def,ptex->length,value,mtex->lengthfac,blend); if((event & mtex->pmapto) & MAP_PA_CLUMP) - ptex->clump= texture_value_blend(def,ptex->clump,value,var,blend,neg & MAP_PA_CLUMP); + ptex->clump= texture_value_blend(def,ptex->clump,value,mtex->clumpfac,blend); if((event & mtex->pmapto) & MAP_PA_KINK) - ptex->kink= texture_value_blend(def,ptex->kink,value,var,blend,neg & MAP_PA_CLUMP); + ptex->kink= texture_value_blend(def,ptex->kink,value,mtex->kinkfac,blend); } } if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 77cef689d09..d757372f17b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2217,11 +2217,12 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra) psys->tree = BLI_kdtree_new(psys->totpart); LOOP_SHOWN_PARTICLES { - if(pa->alive == PARS_ALIVE) + if(pa->alive == PARS_ALIVE) { if(pa->state.time == cfra) BLI_kdtree_insert(psys->tree, p, pa->prev_state.co, NULL); else BLI_kdtree_insert(psys->tree, p, pa->state.co, NULL); + } } BLI_kdtree_balance(psys->tree); @@ -3134,7 +3135,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) ParticleSystem *psys = sim->psys; ParticleSettings *part=psys->part; KDTree *tree=0; - IpoCurve *icu_esize= NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system + //IpoCurve *icu_esize= NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system /* Material *ma=give_current_material(sim->ob, part->omat); */ BoidBrainData bbd; PARTICLE_P; @@ -3331,7 +3332,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; - IpoCurve *icu_esize = NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system + //IpoCurve *icu_esize = NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system /* Material *ma = give_current_material(sim->ob,part->omat); */ PARTICLE_P; float disp, birthtime, dietime, *vg_size= NULL; // XXX ipotime=cfra diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 287396a85c8..3b8ae9a6c7f 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -559,6 +559,36 @@ void default_mtex(MTex *mtex) mtex->norfac= 1.0; mtex->varfac= 1.0; mtex->dispfac=0.2; + mtex->colspecfac= 1.0f; + mtex->mirrfac= 1.0f; + mtex->alphafac= 1.0f; + mtex->difffac= 1.0f; + mtex->specfac= 1.0f; + mtex->emitfac= 1.0f; + mtex->hardfac= 1.0f; + mtex->raymirrfac= 1.0f; + mtex->translfac= 1.0f; + mtex->ambfac= 1.0f; + mtex->colemitfac= 1.0f; + mtex->colreflfac= 1.0f; + mtex->coltransfac= 1.0f; + mtex->densfac= 1.0f; + mtex->scatterfac= 1.0f; + mtex->reflfac= 1.0f; + mtex->shadowfac= 1.0f; + mtex->zenupfac= 1.0f; + mtex->zendownfac= 1.0f; + mtex->blendfac= 1.0f; + mtex->timefac= 1.0f; + mtex->lengthfac= 1.0f; + mtex->clumpfac= 1.0f; + mtex->kinkfac= 1.0f; + mtex->roughfac= 1.0f; + mtex->padensfac= 1.0f; + mtex->lifefac= 1.0f; + mtex->sizefac= 1.0f; + mtex->ivelfac= 1.0f; + mtex->pvelfac= 1.0f; mtex->normapspace= MTEX_NSPACE_TANGENT; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d1da29bef70..6fce17a4892 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6186,7 +6186,70 @@ static void do_versions_gpencil_2_50(Main *main, bScreen *screen) } } +static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) +{ + MTex *mtex; + float varfac, colfac; + int a, neg; + if(!mtex_array) + return; + + for(a=0; a<MAX_MTEX; a++) { + if(mtex_array[a]) { + mtex= mtex_array[a]; + + neg= mtex->maptoneg; + varfac= mtex->varfac; + colfac= mtex->colfac; + + if(neg & MAP_DISP) mtex->dispfac= -mtex->dispfac; + if(neg & MAP_NORM) mtex->norfac= -mtex->norfac; + if(neg & MAP_WARP) mtex->warpfac= -mtex->warpfac; + + mtex->colspecfac= (neg & MAP_COLSPEC)? -colfac: colfac; + mtex->mirrfac= (neg & MAP_COLMIR)? -colfac: colfac; + mtex->alphafac= (neg & MAP_ALPHA)? -varfac: varfac; + mtex->difffac= (neg & MAP_REF)? -varfac: varfac; + mtex->specfac= (neg & MAP_SPEC)? -varfac: varfac; + mtex->emitfac= (neg & MAP_EMIT)? -varfac: varfac; + mtex->hardfac= (neg & MAP_HAR)? -varfac: varfac; + mtex->raymirrfac= (neg & MAP_RAYMIRR)? -varfac: varfac; + mtex->translfac= (neg & MAP_TRANSLU)? -varfac: varfac; + mtex->ambfac= (neg & MAP_AMB)? -varfac: varfac; + mtex->colemitfac= (neg & MAP_EMISSION_COL)? -colfac: colfac; + mtex->colreflfac= (neg & MAP_REFLECTION_COL)? -colfac: colfac; + mtex->coltransfac= (neg & MAP_TRANSMISSION_COL)? -colfac: colfac; + mtex->densfac= (neg & MAP_DENSITY)? -varfac: varfac; + mtex->scatterfac= (neg & MAP_SCATTERING)? -varfac: varfac; + mtex->reflfac= (neg & MAP_REFLECTION)? -varfac: varfac; + + mtex->timefac= (neg & MAP_PA_TIME)? -varfac: varfac; + mtex->lengthfac= (neg & MAP_PA_LENGTH)? -varfac: varfac; + mtex->clumpfac= (neg & MAP_PA_CLUMP)? -varfac: varfac; + mtex->kinkfac= (neg & MAP_PA_KINK)? -varfac: varfac; + mtex->roughfac= (neg & MAP_PA_ROUGH)? -varfac: varfac; + mtex->padensfac= (neg & MAP_PA_DENS)? -varfac: varfac; + mtex->lifefac= (neg & MAP_PA_LIFE)? -varfac: varfac; + mtex->sizefac= (neg & MAP_PA_SIZE)? -varfac: varfac; + mtex->ivelfac= (neg & MAP_PA_IVEL)? -varfac: varfac; + mtex->pvelfac= (neg & MAP_PA_PVEL)? -varfac: varfac; + + mtex->shadowfac= (neg & LAMAP_SHAD)? -colfac: colfac; + + mtex->zenupfac= (neg & WOMAP_ZENUP)? -colfac: colfac; + mtex->zendownfac= (neg & WOMAP_ZENDOWN)? -colfac: colfac; + mtex->blendfac= (neg & WOMAP_BLEND)? -varfac: varfac; + + if(idtype == ID_MA) + mtex->colfac= (neg & MAP_COL)? -colfac: colfac; + else if(idtype == ID_LA) + mtex->colfac= (neg & LAMAP_COL)? -colfac: colfac; + else if(idtype == ID_WO) + mtex->colfac= (neg & WOMAP_HORIZ)? -colfac: colfac; + } + } +} static void do_versions(FileData *fd, Library *lib, Main *main) { @@ -9728,11 +9791,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - /* put 2.50 compatibility code here until next subversion bump */ - { + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) { Scene *sce; Object *ob; Material *ma; + Lamp *la; + World *wo; Tex *tex; ParticleSettings *part; int do_gravity = 0; @@ -9750,19 +9814,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ob->rotmode= ROT_MODE_EUL; } - for (ma = main->mat.first; ma; ma=ma->id.next) { - if (ma->vol.reflection == 0.f) { + for(ma = main->mat.first; ma; ma=ma->id.next) { + if(ma->vol.reflection == 0.f) { ma->vol.reflection = 1.f; ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f; ma->vol.reflection_col[0] = ma->vol.reflection_col[1] = ma->vol.reflection_col[2] = 1.0f; } - } - for (tex = main->tex.first; tex; tex=tex->id.next) { - if (tex->vd) { - if (tex->vd->extend == 0) tex->vd->extend = TEX_CLIP; - } + do_version_mtex_factor_2_50(ma->mtex, ID_MA); } + + for(la = main->lamp.first; la; la=la->id.next) + do_version_mtex_factor_2_50(la->mtex, ID_LA); + + for(wo = main->world.first; wo; wo=wo->id.next) + do_version_mtex_factor_2_50(wo->mtex, ID_WO); + + for(tex = main->tex.first; tex; tex=tex->id.next) + if(tex->vd) + if(tex->vd->extend == 0) + tex->vd->extend = TEX_CLIP; for(sce= main->scene.first; sce; sce= sce->id.next) { @@ -9819,6 +9890,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + /* put 2.50 compatibility code here until next subversion bump */ + { + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index c0fb069fc41..d01266c8765 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -846,37 +846,35 @@ static void texture_rgb_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *o } } -static void texture_value_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, int flip, GPUNodeLink **in) +static void texture_value_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, GPUNodeLink **in) { - float flipf = (flip)? 1.0f: 0.0; - switch(blendtype) { case MTEX_BLEND: - GPU_link(mat, "mtex_value_blend", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_blend", out, tex, fact, facg, in); break; case MTEX_MUL: - GPU_link(mat, "mtex_value_mul", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_mul", out, tex, fact, facg, in); break; case MTEX_SCREEN: - GPU_link(mat, "mtex_value_screen", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_screen", out, tex, fact, facg, in); break; case MTEX_SUB: - GPU_link(mat, "mtex_value_sub", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_sub", out, tex, fact, facg, in); break; case MTEX_ADD: - GPU_link(mat, "mtex_value_add", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_add", out, tex, fact, facg, in); break; case MTEX_DIV: - GPU_link(mat, "mtex_value_div", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_div", out, tex, fact, facg, in); break; case MTEX_DIFF: - GPU_link(mat, "mtex_value_diff", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_diff", out, tex, fact, facg, in); break; case MTEX_DARK: - GPU_link(mat, "mtex_value_dark", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_dark", out, tex, fact, facg, in); break; case MTEX_LIGHT: - GPU_link(mat, "mtex_value_light", out, tex, fact, facg, GPU_uniform(&flipf), in); + GPU_link(mat, "mtex_value_light", out, tex, fact, facg, in); break; default: GPU_link(mat, "set_value_zero", &in); @@ -893,7 +891,7 @@ static void do_material_tex(GPUShadeInput *shi) GPUNodeLink *texco, *tin, *trgb, *tnor, *tcol, *stencil, *tnorfac; GPUNodeLink *texco_norm, *texco_orco, *texco_object, *texco_tangent; GPUNodeLink *texco_global, *texco_uv = NULL; - GPUNodeLink *colfac, *newnor, *varfac, *orn; + GPUNodeLink *newnor, *orn; char *lastuvname = NULL; float one = 1.0f, norfac, ofs[3]; int tex_nr, rgbnor, talpha; @@ -993,11 +991,6 @@ static void do_material_tex(GPUShadeInput *shi) /* mapping */ if(mtex->mapto & (MAP_COL+MAP_COLSPEC)) { /* stencil maps on the texture control slider, not texture intensity value */ - if(mtex->colfac == 1.0f) - colfac = stencil; - else - GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colfac), stencil, &colfac); - if((rgbnor & TEX_RGB)==0) { GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &tcol); } @@ -1012,21 +1005,30 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "set_value_one", &tin); } - if(mtex->mapto & MAP_COL) + if(mtex->mapto & MAP_COL) { + GPUNodeLink *colfac; + + if(mtex->colfac == 1.0f) colfac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colfac), stencil, &colfac); + texture_rgb_blend(mat, tcol, shi->rgb, tin, colfac, mtex->blendtype, &shi->rgb); + } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) - texture_rgb_blend(mat, tcol, shi->specrgb, tin, colfac, mtex->blendtype, &shi->specrgb); + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) { + GPUNodeLink *colspecfac; + + if(mtex->colspecfac == 1.0f) colspecfac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colspecfac), stencil, &colspecfac); + + texture_rgb_blend(mat, tcol, shi->specrgb, tin, colspecfac, mtex->blendtype, &shi->specrgb); + } } if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { - if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac; - else tex->norfac= mtex->norfac; - if((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP)) { tex->norfac = mtex->norfac; - if(mtex->maptoneg & MAP_NORM) + if(tex->norfac < 0.0f) GPU_link(mat, "mtex_negate_texnormal", tnor, &tnor); if(mtex->normapspace == MTEX_NSPACE_TANGENT) @@ -1034,7 +1036,7 @@ static void do_material_tex(GPUShadeInput *shi) else newnor = tnor; - norfac = MIN2(mtex->norfac, 1.0); + norfac = MIN2(fabsf(mtex->norfac), 1.0); if(norfac == 1.0f && !GPU_link_changed(stencil)) { shi->vn = newnor; } @@ -1053,11 +1055,6 @@ static void do_material_tex(GPUShadeInput *shi) } if((mtex->mapto & MAP_VARS)) { - if(mtex->varfac == 1.0f) - varfac = stencil; - else - GPU_link(mat, "math_multiply", GPU_uniform(&mtex->varfac), stencil, &varfac); - if(rgbnor & TEX_RGB) { if(talpha) GPU_link(mat, "mtex_alpha_from_col", trgb, &tin); @@ -1066,34 +1063,58 @@ static void do_material_tex(GPUShadeInput *shi) } if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { - int flip= mtex->maptoneg & MAP_REF; - texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->refl, tin, varfac, mtex->blendtype, flip, &shi->refl); + GPUNodeLink *difffac; + + if(mtex->difffac == 1.0f) difffac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->difffac), stencil, &difffac); + + texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->refl, tin, difffac, mtex->blendtype, &shi->refl); GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl); } if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { - int flip= mtex->maptoneg & MAP_SPEC; - texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->spec, tin, varfac, mtex->blendtype, flip, &shi->spec); + GPUNodeLink *specfac; + + if(mtex->specfac == 1.0f) specfac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->specfac), stencil, &specfac); + + texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->spec, tin, specfac, mtex->blendtype, &shi->spec); GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec); } if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { - int flip= mtex->maptoneg & MAP_EMIT; - texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->emit, tin, varfac, mtex->blendtype, flip, &shi->emit); + GPUNodeLink *emitfac; + + if(mtex->emitfac == 1.0f) emitfac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->emitfac), stencil, &emitfac); + + texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->emit, tin, emitfac, mtex->blendtype, &shi->emit); GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit); } if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { - int flip= mtex->maptoneg & MAP_HAR; + GPUNodeLink *hardfac; + + if(mtex->hardfac == 1.0f) hardfac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->hardfac), stencil, &hardfac); + GPU_link(mat, "mtex_har_divide", shi->har, &shi->har); - texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->har, tin, varfac, mtex->blendtype, flip, &shi->har); + texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->har, tin, hardfac, mtex->blendtype, &shi->har); GPU_link(mat, "mtex_har_multiply_clamp", shi->har, &shi->har); } if(mtex->mapto & MAP_ALPHA) { - int flip= mtex->maptoneg & MAP_ALPHA; - texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, varfac, mtex->blendtype, flip, &shi->alpha); + GPUNodeLink *alphafac; + + if(mtex->alphafac == 1.0f) alphafac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->alphafac), stencil, &alphafac); + + texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, alphafac, mtex->blendtype, &shi->alpha); GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha); } if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { - int flip= mtex->maptoneg & MAP_AMB; - texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->amb, tin, varfac, mtex->blendtype, flip, &shi->amb); + GPUNodeLink *ambfac; + + if(mtex->ambfac == 1.0f) ambfac = stencil; + else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->ambfac), stencil, &ambfac); + + texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->amb, tin, ambfac, mtex->blendtype, &shi->amb); GPU_link(mat, "mtex_value_clamp", shi->amb, &shi->amb); } } diff --git a/source/blender/gpu/intern/gpu_shader_material.glsl b/source/blender/gpu/intern/gpu_shader_material.glsl index 16ed38cb47d..0d7e00a541b 100644 --- a/source/blender/gpu/intern/gpu_shader_material.glsl +++ b/source/blender/gpu/intern/gpu_shader_material.glsl @@ -847,66 +847,66 @@ void mtex_rgb_color(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 i incol.rgb = col.rgb; } -void mtex_value_vars(inout float fact, float facg, out float facm, float flip) +void mtex_value_vars(inout float fact, float facg, out float facm) { - fact *= facg; + fact *= abs(facg); facm = 1.0-fact; - if(flip != 0.0) { + if(facg < 0.0) { float tmp = fact; fact = facm; facm = tmp; } } -void mtex_value_blend(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_blend(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); incol = fact*texcol + facm*outcol; } -void mtex_value_mul(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_mul(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); facm = 1.0 - facg; incol = (facm + fact*texcol)*outcol; } -void mtex_value_screen(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_screen(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); facm = 1.0 - facg; incol = 1.0 - (facm + fact*(1.0 - texcol))*(1.0 - outcol); } -void mtex_value_sub(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_sub(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); fact = -fact; incol = fact*texcol + outcol; } -void mtex_value_add(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_add(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); fact = fact; incol = fact*texcol + outcol; } -void mtex_value_div(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_div(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); if(texcol != 0.0) incol = facm*outcol + fact*outcol/texcol; @@ -914,27 +914,27 @@ void mtex_value_div(float outcol, float texcol, float fact, float facg, float fl incol = 0.0; } -void mtex_value_diff(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_diff(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); incol = facm*outcol + fact*abs(texcol - outcol); } -void mtex_value_dark(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_dark(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); float col = fact*texcol; if(col < outcol) incol = col; else incol = outcol; } -void mtex_value_light(float outcol, float texcol, float fact, float facg, float flip, out float incol) +void mtex_value_light(float outcol, float texcol, float fact, float facg, out float incol) { float facm; - mtex_value_vars(fact, facg, facm, flip); + mtex_value_vars(fact, facg, facm); float col = fact*texcol; if(col > outcol) incol = col; else incol = outcol; diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index b3a7e74e91d..a925b60ac33 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -313,7 +313,7 @@ typedef struct Material { #define MAP_AMB 2048 #define MAP_DISPLACE 4096 #define MAP_WARP 8192 -#define MAP_LAYER 16384 +#define MAP_LAYER 16384 /* unused */ /* volume mapto - reuse definitions for now - a bit naughty! */ #define MAP_DENSITY 128 diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index c8f35b4306f..a43e5c7ae13 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -61,9 +61,27 @@ typedef struct MTex { float r, g, b, k; float def_var, rt; - float colfac, norfac, varfac; - float dispfac; - float warpfac; + /* common */ + float colfac, varfac; + + /* material */ + float norfac, dispfac, warpfac; + float colspecfac, mirrfac, alphafac; + float difffac, specfac, emitfac, hardfac; + float raymirrfac, translfac, ambfac; + float colemitfac, colreflfac, coltransfac; + float densfac, scatterfac, reflfac; + + /* particles */ + float timefac, lengthfac, clumpfac; + float kinkfac, roughfac, padensfac; + float lifefac, sizefac, ivelfac, pvelfac; + + /* lamp */ + float shadowfac; + + /* world */ + float zenupfac, zendownfac, blendfac; } MTex; #ifndef DNA_USHORT_FIX diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index d5195110314..e87c8434a7d 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -96,8 +96,51 @@ static void rna_Brush_update(bContext *C, PointerRNA *ptr) WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, br); } +static float rna_BrushTextureSlot_angle_get(PointerRNA *ptr) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 57.295779506; + return tex->rot * conv; +} + +static void rna_BrushTextureSlot_angle_set(PointerRNA *ptr, float v) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 0.017453293; + tex->rot = v * conv; +} + #else +static void rna_def_brush_texture_slot(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_map_mode_items[] = { + {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""}, + {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, + {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot"); + RNA_def_struct_sdna(srna, "MTex"); + RNA_def_struct_ui_text(srna, "Brush Texture Slot", "Texture slot for textures in a Brush datablock."); + + prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "rot"); + RNA_def_property_range(prop, 0, 360); + RNA_def_property_float_funcs(prop, "rna_BrushTextureSlot_angle_get", "rna_BrushTextureSlot_angle_set", NULL); + RNA_def_property_ui_text(prop, "Angle", "Defines brush texture rotation."); + RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); + + prop= RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); + RNA_def_property_enum_items(prop, prop_map_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); +} + static void rna_def_brush(BlenderRNA *brna) { StructRNA *srna; @@ -258,7 +301,7 @@ static void rna_def_brush(BlenderRNA *brna) /* texture */ rna_def_mtex_common(srna, "rna_Brush_mtex_begin", "rna_Brush_active_texture_get", - "rna_Brush_active_texture_set", "TextureSlot", "rna_Brush_update"); + "rna_Brush_active_texture_set", "BrushTextureSlot", "rna_Brush_update"); /* clone tool */ prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE); @@ -329,6 +372,7 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna) void RNA_def_brush(BlenderRNA *brna) { rna_def_brush(brna); + rna_def_brush_texture_slot(brna); rna_def_operator_stroke_element(brna); } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 8e50ffe7b94..1ebf03425d4 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -197,6 +197,7 @@ void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, ch void rna_Object_update(struct bContext *C, struct PointerRNA *ptr); void rna_Object_update_data(struct bContext *C, struct PointerRNA *ptr); void rna_Mesh_update_draw(struct bContext *C, struct PointerRNA *ptr); +void rna_TextureSlot_update(struct bContext *C, struct PointerRNA *ptr); /* API functions */ diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index df04fe87bc5..4315a118c84 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -185,7 +185,7 @@ static void rna_def_lamp_mtex(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Lamp_update"); prop= RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "shadowfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Shadow Factor", "Amount texture affects shadow."); RNA_def_property_update(prop, 0, "rna_Lamp_update"); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 9b9fbb350a1..661b1c5e1c3 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -444,17 +444,17 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mapping", ""); RNA_def_property_update(prop, 0, "rna_Material_update"); - /* XXX: pmapto, pmaptoneg */ - prop= RNA_def_property(srna, "normal_map_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "normapspace"); RNA_def_property_enum_items(prop, prop_normal_map_space_items); RNA_def_property_ui_text(prop, "Normal Map Space", ""); RNA_def_property_update(prop, 0, "rna_Material_update"); - /* XXX: MTex.which_output */ - - /* XXX: MTex.k */ + prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "norfac"); + RNA_def_property_ui_range(prop, 0, 5, 10, 3); + RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values."); + RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "displacement_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dispfac"); @@ -469,7 +469,7 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "colorspec_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "colspecfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Specular Color Factor", "Amount texture affects specular color."); RNA_def_property_update(prop, 0, "rna_Material_update"); @@ -481,55 +481,55 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "mirror_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "mirrfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Mirror Factor", "Amount texture affects mirror color."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "alpha_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "alphafac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Alpha Factor", "Amount texture affects alpha."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "diffuse_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "difffac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Diffuse Factor", "Amount texture affects diffuse reflectivity."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "specfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Specular Factor", "Amount texture affects specular reflectivity."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "emit_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "emitfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Emit Factor", "Amount texture affects emission."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "hardness_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "hardfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Hardness Factor", "Amount texture affects hardness."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "raymir_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "raymirrfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Ray Mirror Factor", "Amount texture affects ray mirror."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "translucency_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "translfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Translucency Factor", "Amount texture affects translucency."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "ambient_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "ambfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Ambient Factor", "Amount texture affects ambient."); RNA_def_property_update(prop, 0, "rna_Material_update"); @@ -571,43 +571,43 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "coloremission_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "colemitfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Emission Color Factor", "Amount texture affects emission color."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "colorreflection_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "colreflfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Reflection Color Factor", "Amount texture affects color of out-scattered light"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "colortransmission_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "coltransfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Transmission Color Factor", "Amount texture affects result color after light has been scattered/absorbed."); RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "densfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects density."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "emission_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "emitfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Emission Factor", "Amount texture affects emission."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "scattering_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "scatterfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Scattering Factor", "Amount texture affects scattering."); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "reflection_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "reflfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Reflection Factor", "Amount texture affects brightness of out-scattered light."); RNA_def_property_update(prop, 0, "rna_Material_update"); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 7bc8570ce13..5c7a097a54d 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -124,7 +124,7 @@ static void rna_Texture_type_set(PointerRNA *ptr, int value) tex->type = value; } -static void rna_TextureSlot_update(bContext *C, PointerRNA *ptr) +void rna_TextureSlot_update(bContext *C, PointerRNA *ptr) { ID *id= ptr->id.data; @@ -276,20 +276,6 @@ static EnumPropertyItem *rna_ImageTexture_filter_itemf(bContext *C, PointerRNA * return item; } -static float rna_TextureSlot_angle_get(PointerRNA *ptr) -{ - MTex *tex= (MTex*)ptr->data; - const float conv = 57.295779506; - return tex->rot * conv; -} - -static void rna_TextureSlot_angle_set(PointerRNA *ptr, float v) -{ - MTex *tex= (MTex*)ptr->data; - const float conv = 0.017453293; - tex->rot = v * conv; -} - #else static void rna_def_color_ramp_element(BlenderRNA *brna) @@ -412,12 +398,6 @@ static void rna_def_mtex(BlenderRNA *brna) {MTEX_LIN_LIGHT , "LINEAR LIGHT", 0, "Linear Light", ""}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_map_mode_items[] = { - {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""}, - {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, - {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem output_node_items[] = { {0, "DUMMY", 0, "Dummy", ""}, {0, NULL, 0, NULL, NULL}}; @@ -480,35 +460,12 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "RGB to Intensity", "Converts texture RGB values to intensity (gray) values."); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); - prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "rot"); - RNA_def_property_range(prop, 0, 360); - RNA_def_property_float_funcs(prop, "rna_TextureSlot_angle_get", "rna_TextureSlot_angle_set", NULL); - RNA_def_property_ui_text(prop, "Angle", "Defines brush texture rotation."); - RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); - - prop= RNA_def_property(srna, "brush_map_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_map_mode_items); - RNA_def_property_ui_text(prop, "Mode", ""); - prop= RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "def_var"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Default Value", "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard."); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); - prop= RNA_def_property(srna, "variable_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Variable Factor", "Amount texture affects other values."); - RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); - - prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "norfac"); - RNA_def_property_ui_range(prop, 0, 5, 10, 3); - RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values."); - RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); - prop= RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "which_output"); RNA_def_property_enum_items(prop, output_node_items); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 0cbbe28967f..b2ed90eef03 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -174,7 +174,7 @@ static void rna_def_world_mtex(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "varfac"); + RNA_def_property_float_sdna(prop, NULL, "blendfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Blend Factor", "Amount texture affects color progression of the background."); RNA_def_property_update(prop, 0, "rna_World_update"); @@ -186,13 +186,13 @@ static void rna_def_world_mtex(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "zenupfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Zenith Up Factor", "Amount texture affects color of the zenith above."); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); + RNA_def_property_float_sdna(prop, NULL, "zendownfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Zenith Down Factor", "Amount texture affects color of the zenith below."); RNA_def_property_update(prop, 0, "rna_World_update"); diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index 15b59f2c8cc..069861df992 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -55,7 +55,7 @@ int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, f /* particle.c */ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg, int blendtype); -float texture_value_blend(float tex, float out, float fact, float facg, int blendtype, int flip); +float texture_value_blend(float tex, float out, float fact, float facg, int blendtype); /* node_composite.c */ void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result); diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 435e3ddc07f..134be189e8f 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -128,7 +128,6 @@ typedef struct ShadeInput /* individual copies: */ int har; /* hardness */ - float layerfac; /* texture coordinates */ float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4]; diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 621831fb341..30832db5c7d 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1024,7 +1024,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta); yn= tin*mtex->colfac; - zn= tin*mtex->varfac; + zn= tin*mtex->alphafac; if(mtex->mapto & MAP_COL) { zn= 1.0-yn; @@ -1156,7 +1156,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta); //yn= tin*mtex->colfac; - //zn= tin*mtex->varfac; + //zn= tin*mtex->alphafac; if(mtex->mapto & MAP_COL) { tex[0]=tr; tex[1]=tg; @@ -1175,11 +1175,11 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->b= in[2]; } if(mtex->mapto & MAP_ALPHA) - har->alfa = texture_value_blend(mtex->def_var,har->alfa,tin,mtex->varfac,mtex->blendtype,mtex->maptoneg & MAP_ALPHA); + har->alfa = texture_value_blend(mtex->def_var,har->alfa,tin,mtex->alphafac,mtex->blendtype); if(mtex->mapto & MAP_HAR) - har->hard = 1.0+126.0*texture_value_blend(mtex->def_var,((float)har->hard)/127.0,tin,mtex->varfac,mtex->blendtype,mtex->maptoneg & MAP_HAR); + har->hard = 1.0+126.0*texture_value_blend(mtex->def_var,((float)har->hard)/127.0,tin,mtex->hardfac,mtex->blendtype); if(mtex->mapto & MAP_RAYMIRR) - har->hasize = 100.0*texture_value_blend(mtex->def_var,har->hasize/100.0,tin,mtex->varfac,mtex->blendtype,mtex->maptoneg & MAP_RAYMIRR); + har->hasize = 100.0*texture_value_blend(mtex->def_var,har->hasize/100.0,tin,mtex->raymirrfac,mtex->blendtype); /* now what on earth is this good for?? */ //if(mtex->texco & 16) { // har->alfa= tin; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 02b7f6aad86..7b0e5d8abbc 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -1468,9 +1468,12 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg } } -float texture_value_blend(float tex, float out, float fact, float facg, int blendtype, int flip) +float texture_value_blend(float tex, float out, float fact, float facg, int blendtype) { float in=0.0, facm, col, scf; + int flip= (facg < 0.0f); + + facg= fabsf(facg); fact*= facg; facm= 1.0-fact; @@ -1813,7 +1816,7 @@ void do_material_tex(ShadeInput *shi) TexResult ttexr = {0, 0, 0, 0, 0, texres.talpha, NULL}; // temp TexResult float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv; const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); - const float bf = 0.04f*Tnor*((mtex->maptoneg & MAP_NORM) ? -mtex->norfac : mtex->norfac); + const float bf = 0.04f*Tnor*mtex->norfac; // disable internal bump eval float* nvec = texres.nor; texres.nor = NULL; @@ -2020,10 +2023,9 @@ void do_material_tex(ShadeInput *shi) /* mapping */ if(mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { - float tcol[3], colfac; + float tcol[3]; /* stencil maps on the texture control slider, not texture intensity value */ - colfac= mtex->colfac*stencilTin; tcol[0]=texres.tr; tcol[1]=texres.tg; tcol[2]=texres.tb; @@ -2043,15 +2045,19 @@ void do_material_tex(ShadeInput *shi) } if(mtex->mapto & MAP_COL) { + float colfac= mtex->colfac*stencilTin; texture_rgb_blend(&shi->r, tcol, &shi->r, texres.tin, colfac, mtex->blendtype); } if(mtex->mapto & MAP_COLSPEC) { - texture_rgb_blend(&shi->specr, tcol, &shi->specr, texres.tin, colfac, mtex->blendtype); + float colspecfac= mtex->colspecfac*stencilTin; + texture_rgb_blend(&shi->specr, tcol, &shi->specr, texres.tin, colspecfac, mtex->blendtype); } if(mtex->mapto & MAP_COLMIR) { + float mirrfac= mtex->mirrfac*stencilTin; + // exception for envmap only if(tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) { - fact= texres.tin*colfac; + fact= texres.tin*mirrfac; facm= 1.0- fact; shi->refcol[0]= fact + facm*shi->refcol[0]; shi->refcol[1]= fact*tcol[0] + facm*shi->refcol[1]; @@ -2059,14 +2065,13 @@ void do_material_tex(ShadeInput *shi) shi->refcol[3]= fact*tcol[2] + facm*shi->refcol[3]; } else { - texture_rgb_blend(&shi->mirr, tcol, &shi->mirr, texres.tin, colfac, mtex->blendtype); + texture_rgb_blend(&shi->mirr, tcol, &shi->mirr, texres.tin, mirrfac, mtex->blendtype); } } } if( (mtex->mapto & MAP_NORM) ) { if(texres.nor) { - if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac; - else tex->norfac= mtex->norfac; + tex->norfac= mtex->norfac; /* we need to code blending modes for normals too once.. now 1 exception hardcoded */ @@ -2074,7 +2079,7 @@ void do_material_tex(ShadeInput *shi) /* qdn: for normalmaps, to invert the normalmap vector, it is better to negate x & y instead of subtracting the vector as was done before */ tex->norfac = mtex->norfac; - if (mtex->maptoneg & MAP_NORM) { + if (tex->norfac < 0.0f) { texres.nor[0] = -texres.nor[0]; texres.nor[1] = -texres.nor[1]; } @@ -2159,8 +2164,7 @@ void do_material_tex(ShadeInput *shi) /* Now that most textures offer both Nor and Intensity, allow */ /* both to work, and let user select with slider. */ if(texres.nor) { - if(mtex->maptoneg & MAP_DISPLACE) tex->norfac= -mtex->norfac; - else tex->norfac= mtex->norfac; + tex->norfac= mtex->norfac; shi->displace[0]+= 0.2f*Tnor*tex->norfac*texres.nor[0]; shi->displace[1]+= 0.2f*Tnor*tex->norfac*texres.nor[1]; @@ -2172,12 +2176,7 @@ void do_material_tex(ShadeInput *shi) else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } - if(mtex->maptoneg & MAP_DISPLACE) { - factt= (texres.tin-0.5f)*mtex->dispfac*stencilTin; facmm= 1.0f-factt; - } - else { - factt= (0.5f-texres.tin)*mtex->dispfac*stencilTin; facmm= 1.0f-factt; - } + factt= (0.5f-texres.tin)*mtex->dispfac*stencilTin; facmm= 1.0f-factt; if(mtex->blendtype==MTEX_BLEND) { shi->displace[0]= factt*shi->vn[0] + facmm*shi->displace[0]; @@ -2200,7 +2199,6 @@ void do_material_tex(ShadeInput *shi) if(mtex->mapto & MAP_VARS) { /* stencil maps on the texture control slider, not texture intensity value */ - float varfac= mtex->varfac*stencilTin; if(rgbnor & TEX_RGB) { if(texres.talpha) texres.tin= texres.ta; @@ -2208,66 +2206,59 @@ void do_material_tex(ShadeInput *shi) } if(mtex->mapto & MAP_REF) { - int flip= mtex->maptoneg & MAP_REF; + float difffac= mtex->difffac*stencilTin; - shi->refl= texture_value_blend(mtex->def_var, shi->refl, texres.tin, varfac, mtex->blendtype, flip); + shi->refl= texture_value_blend(mtex->def_var, shi->refl, texres.tin, difffac, mtex->blendtype); if(shi->refl<0.0) shi->refl= 0.0; } if(mtex->mapto & MAP_SPEC) { - int flip= mtex->maptoneg & MAP_SPEC; + float specfac= mtex->specfac*stencilTin; - shi->spec= texture_value_blend(mtex->def_var, shi->spec, texres.tin, varfac, mtex->blendtype, flip); + shi->spec= texture_value_blend(mtex->def_var, shi->spec, texres.tin, specfac, mtex->blendtype); if(shi->spec<0.0) shi->spec= 0.0; } if(mtex->mapto & MAP_EMIT) { - int flip= mtex->maptoneg & MAP_EMIT; + float emitfac= mtex->emitfac*stencilTin; - shi->emit= texture_value_blend(mtex->def_var, shi->emit, texres.tin, varfac, mtex->blendtype, flip); + shi->emit= texture_value_blend(mtex->def_var, shi->emit, texres.tin, emitfac, mtex->blendtype); if(shi->emit<0.0) shi->emit= 0.0; } if(mtex->mapto & MAP_ALPHA) { - int flip= mtex->maptoneg & MAP_ALPHA; + float alphafac= mtex->alphafac*stencilTin; - shi->alpha= texture_value_blend(mtex->def_var, shi->alpha, texres.tin, varfac, mtex->blendtype, flip); + shi->alpha= texture_value_blend(mtex->def_var, shi->alpha, texres.tin, alphafac, mtex->blendtype); if(shi->alpha<0.0) shi->alpha= 0.0; else if(shi->alpha>1.0) shi->alpha= 1.0; } if(mtex->mapto & MAP_HAR) { - int flip= mtex->maptoneg & MAP_HAR; float har; // have to map to 0-1 + float hardfac= mtex->hardfac*stencilTin; har= ((float)shi->har)/128.0; - har= 128.0*texture_value_blend(mtex->def_var, har, texres.tin, varfac, mtex->blendtype, flip); + har= 128.0*texture_value_blend(mtex->def_var, har, texres.tin, hardfac, mtex->blendtype); if(har<1.0) shi->har= 1; else if(har>511.0) shi->har= 511; else shi->har= (int)har; } if(mtex->mapto & MAP_RAYMIRR) { - int flip= mtex->maptoneg & MAP_RAYMIRR; + float raymirrfac= mtex->raymirrfac*stencilTin; - shi->ray_mirror= texture_value_blend(mtex->def_var, shi->ray_mirror, texres.tin, varfac, mtex->blendtype, flip); + shi->ray_mirror= texture_value_blend(mtex->def_var, shi->ray_mirror, texres.tin, raymirrfac, mtex->blendtype); if(shi->ray_mirror<0.0) shi->ray_mirror= 0.0; else if(shi->ray_mirror>1.0) shi->ray_mirror= 1.0; } if(mtex->mapto & MAP_TRANSLU) { - int flip= mtex->maptoneg & MAP_TRANSLU; + float translfac= mtex->translfac*stencilTin; - shi->translucency= texture_value_blend(mtex->def_var, shi->translucency, texres.tin, varfac, mtex->blendtype, flip); + shi->translucency= texture_value_blend(mtex->def_var, shi->translucency, texres.tin, translfac, mtex->blendtype); if(shi->translucency<0.0) shi->translucency= 0.0; else if(shi->translucency>1.0) shi->translucency= 1.0; } - if(mtex->mapto & MAP_LAYER) { - int flip= mtex->maptoneg & MAP_LAYER; - - shi->layerfac= texture_value_blend(mtex->def_var, shi->layerfac, texres.tin, varfac, mtex->blendtype, flip); - if(shi->layerfac<0.0) shi->layerfac= 0.0; - else if(shi->layerfac>1.0) shi->layerfac= 1.0; - } if(mtex->mapto & MAP_AMB) { - int flip= mtex->maptoneg & MAP_AMB; + float ambfac= mtex->ambfac*stencilTin; - shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, varfac, mtex->blendtype, flip); + shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, ambfac, mtex->blendtype); if(shi->amb<0.0) shi->amb= 0.0; else if(shi->amb>1.0) shi->amb= 1.0; @@ -2386,10 +2377,9 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa if((mapto_flag & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL)) && (mtex->mapto & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL))) { - float tcol[3], colfac; + float tcol[3]; /* stencil maps on the texture control slider, not texture intensity value */ - colfac= mtex->colfac*stencilTin; if((rgbnor & TEX_RGB)==0) { tcol[0]= mtex->r; @@ -2410,21 +2400,23 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa /* used for emit */ if((mapto_flag & MAP_EMISSION_COL) && (mtex->mapto & MAP_EMISSION_COL)) { - texture_rgb_blend(col, tcol, col, texres.tin, colfac, mtex->blendtype); + float colemitfac= mtex->colemitfac*stencilTin; + texture_rgb_blend(col, tcol, col, texres.tin, colemitfac, mtex->blendtype); } if((mapto_flag & MAP_REFLECTION_COL) && (mtex->mapto & MAP_REFLECTION_COL)) { - texture_rgb_blend(col, tcol, col, texres.tin, colfac, mtex->blendtype); + float colreflfac= mtex->colreflfac*stencilTin; + texture_rgb_blend(col, tcol, col, texres.tin, colreflfac, mtex->blendtype); } if((mapto_flag & MAP_TRANSMISSION_COL) && (mtex->mapto & MAP_TRANSMISSION_COL)) { - texture_rgb_blend(col, tcol, col, texres.tin, colfac, mtex->blendtype); + float coltransfac= mtex->coltransfac*stencilTin; + texture_rgb_blend(col, tcol, col, texres.tin, coltransfac, mtex->blendtype); } } if((mapto_flag & MAP_VARS) && (mtex->mapto & MAP_VARS)) { /* stencil maps on the texture control slider, not texture intensity value */ - float varfac= mtex->varfac*stencilTin; /* convert RGB to intensity if intensity info isn't provided */ if (!(rgbnor & TEX_INT)) { @@ -2435,27 +2427,27 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa } if((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) { - int flip= mtex->maptoneg & MAP_EMISSION; + float emitfac= mtex->emitfac*stencilTin; - *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + *val = texture_value_blend(mtex->def_var, *val, texres.tin, emitfac, mtex->blendtype); if(*val<0.0) *val= 0.0; } if((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) { - int flip= mtex->maptoneg & MAP_DENSITY; + float densfac= mtex->densfac*stencilTin; - *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + *val = texture_value_blend(mtex->def_var, *val, texres.tin, densfac, mtex->blendtype); CLAMP(*val, 0.0, 1.0); } if((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) { - int flip= mtex->maptoneg & MAP_SCATTERING; + float scatterfac= mtex->scatterfac*stencilTin; - *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + *val = texture_value_blend(mtex->def_var, *val, texres.tin, scatterfac, mtex->blendtype); CLAMP(*val, 0.0, 1.0); } if((mapto_flag & MAP_REFLECTION) && (mtex->mapto & MAP_REFLECTION)) { - int flip= mtex->maptoneg & MAP_REFLECTION; + float reflfac= mtex->reflfac*stencilTin; - *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip); + *val = texture_value_blend(mtex->def_var, *val, texres.tin, reflfac, mtex->blendtype); CLAMP(*val, 0.0, 1.0); } } @@ -2770,7 +2762,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f if(mtex->mapto & WOMAP_BLEND) { if(rgb) texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); - *blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->varfac, mtex->blendtype, 0); + *blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype); } } } |