Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_image.h
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if(id < TEX_NUM_FLOAT_IMAGES) | ||||
| return make_float4(1.0f, 0.0f, 1.0f, 1.0f); | return make_float4(1.0f, 0.0f, 1.0f, 1.0f); | ||||
| id -= TEX_NUM_FLOAT_IMAGES; | id -= TEX_NUM_FLOAT_IMAGES; | ||||
| uint4 info = kernel_tex_fetch(__tex_image_packed_info, id); | uint4 info = kernel_tex_fetch(__tex_image_packed_info, id); | ||||
| uint width = info.x; | uint width = info.x; | ||||
| uint height = info.y; | uint height = info.y; | ||||
| uint offset = info.z; | uint offset = info.z; | ||||
| uint periodic = info.w; | uint periodic = (info.w & 0x1); | ||||
| uint interpolation = info.w >> 1; | |||||
| int ix, iy, nix, niy; | int ix, iy, nix, niy; | ||||
| float tx = svm_image_texture_frac(x*width, &ix); | float tx = svm_image_texture_frac(x*width, &ix); | ||||
| float ty = svm_image_texture_frac(y*height, &iy); | float ty = svm_image_texture_frac(y*height, &iy); | ||||
| if(periodic) { | if(periodic) { | ||||
| ix = svm_image_texture_wrap_periodic(ix, width); | ix = svm_image_texture_wrap_periodic(ix, width); | ||||
| iy = svm_image_texture_wrap_periodic(iy, height); | iy = svm_image_texture_wrap_periodic(iy, height); | ||||
| nix = svm_image_texture_wrap_periodic(ix+1, width); | nix = svm_image_texture_wrap_periodic(ix+1, width); | ||||
| niy = svm_image_texture_wrap_periodic(iy+1, height); | niy = svm_image_texture_wrap_periodic(iy+1, height); | ||||
| } | } | ||||
| else { | else { | ||||
| ix = svm_image_texture_wrap_clamp(ix, width); | ix = svm_image_texture_wrap_clamp(ix, width); | ||||
| iy = svm_image_texture_wrap_clamp(iy, height); | iy = svm_image_texture_wrap_clamp(iy, height); | ||||
| nix = svm_image_texture_wrap_clamp(ix+1, width); | nix = svm_image_texture_wrap_clamp(ix+1, width); | ||||
| niy = svm_image_texture_wrap_clamp(iy+1, height); | niy = svm_image_texture_wrap_clamp(iy+1, height); | ||||
| } | } | ||||
| float4 r = (1.0f - ty)*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + iy*width); | float4 r; | ||||
| if (interpolation == INTERPOLATION_CLOSEST){ | |||||
dingto: Code Style (Spaces) | |||||
| r = svm_image_texture_read(kg, offset + ix + iy*width); | |||||
| } | |||||
| else { /* We default to linear interpolation if it is not closest */ | |||||
| r = (1.0f - ty)*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + iy*width); | |||||
| r += (1.0f - ty)*tx*svm_image_texture_read(kg, offset + nix + iy*width); | r += (1.0f - ty)*tx*svm_image_texture_read(kg, offset + nix + iy*width); | ||||
| r += ty*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + niy*width); | r += ty*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + niy*width); | ||||
| r += ty*tx*svm_image_texture_read(kg, offset + nix + niy*width); | r += ty*tx*svm_image_texture_read(kg, offset + nix + niy*width); | ||||
| } | |||||
| if(use_alpha && r.w != 1.0f && r.w != 0.0f) { | if(use_alpha && r.w != 1.0f && r.w != 0.0f) { | ||||
| float invw = 1.0f/r.w; | float invw = 1.0f/r.w; | ||||
| r.x *= invw; | r.x *= invw; | ||||
| r.y *= invw; | r.y *= invw; | ||||
| r.z *= invw; | r.z *= invw; | ||||
| if(id >= TEX_NUM_FLOAT_IMAGES) { | if(id >= TEX_NUM_FLOAT_IMAGES) { | ||||
| ▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines | |||||
Code Style (Spaces)