diff options
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 11 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 18 |
3 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index ce3a378ea00..2bf62b73424 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -629,7 +629,7 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i if(smoothnormal) { /* copy vertex normal */ normal_short_to_float_v3(&varray[start], mvert[f->v1].no); - normal_short_to_float_v3(&varray[start+3], mvert[f->v2].no); + normal_short_to_float_v3(&varray[start+3], mvert[f->v2].no); normal_short_to_float_v3(&varray[start+6], mvert[f->v3].no); if(f->v4) { @@ -1058,7 +1058,8 @@ void GPU_uvedge_setup(DerivedMesh *dm) GLStates |= GPU_BUFFER_VERTEX_STATE; } -static int GPU_typesize(int type) { +static int GPU_typesize(int type) +{ switch(type) { case GL_FLOAT: return sizeof(float); @@ -1075,7 +1076,8 @@ static int GPU_typesize(int type) { } } -int GPU_attrib_element_size(GPUAttrib data[], int numdata) { +int GPU_attrib_element_size(GPUAttrib data[], int numdata) +{ int i, elementsize = 0; for(i = 0; i < numdata; i++) { @@ -1086,7 +1088,8 @@ int GPU_attrib_element_size(GPUAttrib data[], int numdata) { return elementsize; } -void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata) { +void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata) +{ int i; int elementsize; intptr_t offset = 0; diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 4f79d577ae5..120c203e7bd 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -717,7 +717,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) } else { /* Do partial drawing. 'buffer' holds only the changed part. Needed for color corrected result */ - float *buffer = (float *)MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf"); + float *buffer = (float *)MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf"); IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h); glBindTexture(GL_TEXTURE_2D, ima->bindcode); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 40186c5a187..a792b51e1cf 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -903,7 +903,7 @@ static void do_material_tex(GPUShadeInput *shi) /*char *lastuvname = NULL;*/ /*UNUSED*/ float one = 1.0f, norfac, ofs[3]; int tex_nr, rgbnor, talpha; - int init_done = 0, iBumpSpacePrev; + int init_done = 0, iBumpSpacePrev = 0; /* Not necessary, quiting gcc warning. */ GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude; int iFirstTimeNMap=1; int found_deriv_map = 0; @@ -1091,6 +1091,9 @@ static void do_material_tex(GPUShadeInput *shi) float ima_x, ima_y; float hScale = 0.1f; // compatibility adjustment factor for all bumpspace types float hScaleTex = 13.0f; // factor for scaling texspace bumps + + float imag_tspace_dimension_x = 1024.0f; // only used for texture space variant + float aspect = 1.0f; GPUNodeLink *surf_pos = GPU_builtin(GPU_VIEW_POSITION); GPUNodeLink *vR1, *vR2; @@ -1098,7 +1101,12 @@ static void do_material_tex(GPUShadeInput *shi) if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) hScale = hScaleTex; - norfac = hScale * mtex->norfac; + + // The negate on norfac is done because the + // normal in the renderer points inward which corresponds + // to inverting the bump map. Should this ever change + // this negate must be removed. + norfac = -hScale * mtex->norfac; tnorfac = GPU_uniform(&norfac); if(GPU_link_changed(stencil)) @@ -1154,6 +1162,7 @@ static void do_material_tex(GPUShadeInput *shi) if(ibuf) { ima_x= ibuf->x; ima_y= ibuf->y; + aspect = ((float) ima_y) / ima_x; } } @@ -1174,10 +1183,11 @@ static void do_material_tex(GPUShadeInput *shi) if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - + float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x; GPU_link( mat, "mtex_bump_apply_texspace", fDet, dBs, dBt, vR1, vR2, - GPU_image(tex->ima, &tex->iuser), texco, GPU_uniform(&ima_x), GPU_uniform(&ima_y), vNacc, + GPU_image(tex->ima, &tex->iuser), texco, + GPU_uniform(&imag_tspace_dimension_x), GPU_uniform(&imag_tspace_dimension_y), vNacc, &vNacc, &shi->vn ); } else GPU_link( mat, "mtex_bump_apply", |