~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to intern/cycles/kernel/svm/svm_image.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
__device_inline float svm_image_texture_frac(float x, int *ix)
47
47
{
48
 
        int i = (int)x - ((x < 0.0f)? 1: 0);
 
48
        int i = float_to_int(x) - ((x < 0.0f)? 1: 0);
49
49
        *ix = i;
50
50
        return x - (float)i;
51
51
}
52
52
 
53
 
__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb)
 
53
__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
54
54
{
55
55
        /* first slots are used by float textures, which are not supported here */
56
56
        if(id < TEX_NUM_FLOAT_IMAGES)
88
88
        r += ty*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + niy*width);
89
89
        r += ty*tx*svm_image_texture_read(kg, offset + nix + niy*width);
90
90
 
 
91
        if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
 
92
                float invw = 1.0f/r.w;
 
93
                r.x *= invw;
 
94
                r.y *= invw;
 
95
                r.z *= invw;
 
96
 
 
97
                if(id >= TEX_NUM_FLOAT_IMAGES) {
 
98
                        r.x = min(r.x, 1.0f);
 
99
                        r.y = min(r.y, 1.0f);
 
100
                        r.z = min(r.z, 1.0f);
 
101
                }
 
102
        }
 
103
 
91
104
        if(srgb) {
92
105
                r.x = color_srgb_to_scene_linear(r.x);
93
106
                r.y = color_srgb_to_scene_linear(r.y);
99
112
 
100
113
#else
101
114
 
102
 
__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb)
 
115
__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
103
116
{
104
117
        float4 r;
105
118
 
222
235
        }
223
236
#endif
224
237
 
 
238
        if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
 
239
                float invw = 1.0f/r.w;
 
240
                r.x *= invw;
 
241
                r.y *= invw;
 
242
                r.z *= invw;
 
243
 
 
244
                if(id >= TEX_NUM_FLOAT_IMAGES) {
 
245
                        r.x = min(r.x, 1.0f);
 
246
                        r.y = min(r.y, 1.0f);
 
247
                        r.z = min(r.z, 1.0f);
 
248
                }
 
249
        }
 
250
 
225
251
        if(srgb) {
226
252
                r.x = color_srgb_to_scene_linear(r.x);
227
253
                r.y = color_srgb_to_scene_linear(r.y);
241
267
        decode_node_uchar4(node.z, &co_offset, &out_offset, &alpha_offset, &srgb);
242
268
 
243
269
        float3 co = stack_load_float3(stack, co_offset);
244
 
        float4 f = svm_image_texture(kg, id, co.x, co.y, srgb);
 
270
        uint use_alpha = stack_valid(alpha_offset);
 
271
        float4 f = svm_image_texture(kg, id, co.x, co.y, srgb, use_alpha);
245
272
 
246
273
        if(stack_valid(out_offset))
247
274
                stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));
322
349
        uint id = node.y;
323
350
 
324
351
        float4 f = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 
352
        uint use_alpha = stack_valid(alpha_offset);
325
353
 
326
354
        if(weight.x > 0.0f)
327
 
                f += weight.x*svm_image_texture(kg, id, co.y, co.z, srgb);
 
355
                f += weight.x*svm_image_texture(kg, id, co.y, co.z, srgb, use_alpha);
328
356
        if(weight.y > 0.0f)
329
 
                f += weight.y*svm_image_texture(kg, id, co.x, co.z, srgb);
 
357
                f += weight.y*svm_image_texture(kg, id, co.x, co.z, srgb, use_alpha);
330
358
        if(weight.z > 0.0f)
331
 
                f += weight.z*svm_image_texture(kg, id, co.y, co.x, srgb);
 
359
                f += weight.z*svm_image_texture(kg, id, co.y, co.x, srgb, use_alpha);
332
360
 
333
361
        if(stack_valid(out_offset))
334
362
                stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));
355
383
        else
356
384
                uv = direction_to_mirrorball(co);
357
385
 
358
 
        float4 f = svm_image_texture(kg, id, uv.x, uv.y, srgb);
 
386
        uint use_alpha = stack_valid(alpha_offset);
 
387
        float4 f = svm_image_texture(kg, id, uv.x, uv.y, srgb, use_alpha);
359
388
 
360
389
        if(stack_valid(out_offset))
361
390
                stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));