Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_volume.c
| Show First 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | if (BKE_volume_grid_dense_floats(volume, grid, &dense_grid)) { | ||||
| /* Create GPU texture. */ | /* Create GPU texture. */ | ||||
| eGPUTextureFormat format = (channels == 3) ? GPU_RGB16F : GPU_R16F; | eGPUTextureFormat format = (channels == 3) ? GPU_RGB16F : GPU_R16F; | ||||
| cache_grid->texture = GPU_texture_create_3d("volume_grid", | cache_grid->texture = GPU_texture_create_3d("volume_grid", | ||||
| UNPACK3(dense_grid.resolution), | UNPACK3(dense_grid.resolution), | ||||
| 1, | 1, | ||||
| format, | format, | ||||
| GPU_DATA_FLOAT, | GPU_DATA_FLOAT, | ||||
| dense_grid.voxels); | dense_grid.voxels); | ||||
| /* The texture can be null if the resolution along one axis is larger than | |||||
| * GL_MAX_3D_TEXTURE_SIZE. */ | |||||
| if (cache_grid->texture != NULL) { | |||||
| GPU_texture_swizzle_set(cache_grid->texture, (channels == 3) ? "rgb1" : "rrr1"); | GPU_texture_swizzle_set(cache_grid->texture, (channels == 3) ? "rgb1" : "rrr1"); | ||||
| GPU_texture_wrap_mode(cache_grid->texture, false, false); | GPU_texture_wrap_mode(cache_grid->texture, false, false); | ||||
| BKE_volume_dense_float_grid_clear(&dense_grid); | BKE_volume_dense_float_grid_clear(&dense_grid); | ||||
| } | } | ||||
| else { | |||||
| MEM_freeN(dense_grid.voxels); | |||||
| printf("Error: Could not allocate 3D texture for volume.\n"); | |||||
| } | |||||
| } | |||||
| /* Free grid from memory if it wasn't previously loaded. */ | /* Free grid from memory if it wasn't previously loaded. */ | ||||
| if (!was_loaded) { | if (!was_loaded) { | ||||
| BKE_volume_grid_unload(volume, grid); | BKE_volume_grid_unload(volume, grid); | ||||
| } | } | ||||
| return cache_grid; | return cache_grid; | ||||
| } | } | ||||
| Show All 12 Lines | |||||