diff options
author | Morten Mikkelsen <mikkelsen7@gmail.com> | 2011-12-10 05:00:12 +0400 |
---|---|---|
committer | Morten Mikkelsen <mikkelsen7@gmail.com> | 2011-12-10 05:00:12 +0400 |
commit | 82b9e4d16f08e8ca1b3fee84226334b3012aaed3 (patch) | |
tree | 23645a68a5a6dff0edea555df4e9cb35d01927bc /source/blender | |
parent | 965c287630b7528a4a0b146212e8f1783a904948 (diff) |
verify existence of dm
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 5 | ||||
-rw-r--r-- | source/blender/render/intern/source/render_texture.c | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 6a11010002f..2d2da3c592d 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1156,11 +1156,14 @@ int GPU_enable_material(int nr, void *attribs) if(gattribs && GMS.gmatbuf[nr]) { /* bind glsl material and get attributes */ Material *mat = GMS.gmatbuf[nr]; + float auto_bump_scale; gpumat = GPU_material_from_blender(GMS.gscene, mat); GPU_material_vertex_attributes(gpumat, gattribs); GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); - GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, GMS.gob->derivedFinal->auto_bump_scale); + + auto_bump_scale = GMS.gob->derivedFinal!=0 ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f; + GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, auto_bump_scale); GMS.gboundmat= mat; /* for glsl use alpha blend mode, unless it's set to solid and diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index e55d2676b17..fe9312e37d5 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1960,13 +1960,16 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } if(found_deriv_map) { - float dBdu, dBdv, auto_bump; + float dBdu, dBdv, auto_bump = 1.0f; float s = 1; // negate this if flipped texture coordinate texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); - auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale; - auto_bump /= sqrtf((float) (dimx*dimy)); + if(shi->obr->ob->derivedFinal) + { + auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale; + auto_bump /= sqrtf((float) (dimx*dimy)); + } // this variant using a derivative map is described here // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html |