Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_image.h
| Show All 10 Lines | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| ccl_device float4 | ccl_device float4 svm_image_texture(KernelGlobals kg, int id, float x, float y, uint flags) | ||||
| svm_image_texture(ccl_global const KernelGlobals *kg, int id, float x, float y, uint flags) | |||||
| { | { | ||||
| if (id == -1) { | if (id == -1) { | ||||
| return make_float4( | return make_float4( | ||||
| TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A); | TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A); | ||||
| } | } | ||||
| float4 r = kernel_tex_image_interp(kg, id, x, y); | float4 r = kernel_tex_image_interp(kg, id, x, y); | ||||
| const float alpha = r.w; | const float alpha = r.w; | ||||
| Show All 11 Lines | |||||
| } | } | ||||
| /* Remap coordinate from 0..1 box to -1..-1 */ | /* Remap coordinate from 0..1 box to -1..-1 */ | ||||
| ccl_device_inline float3 texco_remap_square(float3 co) | ccl_device_inline float3 texco_remap_square(float3 co) | ||||
| { | { | ||||
| return (co - make_float3(0.5f, 0.5f, 0.5f)) * 2.0f; | return (co - make_float3(0.5f, 0.5f, 0.5f)) * 2.0f; | ||||
| } | } | ||||
| ccl_device_noinline int svm_node_tex_image(ccl_global const KernelGlobals *kg, | ccl_device_noinline int svm_node_tex_image( | ||||
| ccl_private ShaderData *sd, | KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) | ||||
| ccl_private float *stack, | |||||
| uint4 node, | |||||
| int offset) | |||||
| { | { | ||||
| uint co_offset, out_offset, alpha_offset, flags; | uint co_offset, out_offset, alpha_offset, flags; | ||||
| svm_unpack_node_uchar4(node.z, &co_offset, &out_offset, &alpha_offset, &flags); | svm_unpack_node_uchar4(node.z, &co_offset, &out_offset, &alpha_offset, &flags); | ||||
| float3 co = stack_load_float3(stack, co_offset); | float3 co = stack_load_float3(stack, co_offset); | ||||
| float2 tex_co; | float2 tex_co; | ||||
| if (node.w == NODE_IMAGE_PROJ_SPHERE) { | if (node.w == NODE_IMAGE_PROJ_SPHERE) { | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | ccl_device_noinline int svm_node_tex_image( | ||||
| if (stack_valid(out_offset)) | if (stack_valid(out_offset)) | ||||
| stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z)); | stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z)); | ||||
| if (stack_valid(alpha_offset)) | if (stack_valid(alpha_offset)) | ||||
| stack_store_float(stack, alpha_offset, f.w); | stack_store_float(stack, alpha_offset, f.w); | ||||
| return offset; | return offset; | ||||
| } | } | ||||
| ccl_device_noinline void svm_node_tex_image_box(ccl_global const KernelGlobals *kg, | ccl_device_noinline void svm_node_tex_image_box(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node) | uint4 node) | ||||
| { | { | ||||
| /* get object space normal */ | /* get object space normal */ | ||||
| float3 N = sd->N; | float3 N = sd->N; | ||||
| N = sd->N; | N = sd->N; | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | ccl_device_noinline void svm_node_tex_image_box(KernelGlobals kg, | ||||
| } | } | ||||
| if (stack_valid(out_offset)) | if (stack_valid(out_offset)) | ||||
| stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z)); | stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z)); | ||||
| if (stack_valid(alpha_offset)) | if (stack_valid(alpha_offset)) | ||||
| stack_store_float(stack, alpha_offset, f.w); | stack_store_float(stack, alpha_offset, f.w); | ||||
| } | } | ||||
| ccl_device_noinline void svm_node_tex_environment(ccl_global const KernelGlobals *kg, | ccl_device_noinline void svm_node_tex_environment(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node) | uint4 node) | ||||
| { | { | ||||
| uint id = node.y; | uint id = node.y; | ||||
| uint co_offset, out_offset, alpha_offset, flags; | uint co_offset, out_offset, alpha_offset, flags; | ||||
| uint projection = node.w; | uint projection = node.w; | ||||
| Show All 21 Lines | |||||