[Bf-blender-cvs] [fd43d3b95a9] soc-2020-fluid-tools: Merge branch 'master' into soc-2020-fluid-tools

Sriharsha Kotcharlakot noreply at git.blender.org
Thu Sep 10 09:53:05 CEST 2020


Commit: fd43d3b95a94f43534a4f2e11c7f80e6ebdbdb2b
Author: Sriharsha Kotcharlakot
Date:   Thu Sep 10 13:12:53 2020 +0530
Branches: soc-2020-fluid-tools
https://developer.blender.org/rBfd43d3b95a94f43534a4f2e11c7f80e6ebdbdb2b

Merge branch 'master' into soc-2020-fluid-tools

===================================================================



===================================================================

diff --cc intern/opencolorio/ocio_impl_glsl.cc
index ae134cc0725,6a4b03976e4..8f84f8978b7
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@@ -295,30 -282,18 +282,19 @@@ static void ensureGLSLLut3d(OCIO_GLSLLu
  
    OCIO_GLSLLut3d *lut3d = OBJECT_GUARDED_NEW(OCIO_GLSLLut3d);
  
-   glGenTextures(3, &lut3d->texture);
+   int extent[3] = {LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE};
  
-   for (int i = 0; i < 2; i++) {
-     GLuint texture = (&lut3d->texture)[i];
- 
-     glActiveTexture(GL_TEXTURE1);
-     glBindTexture(GL_TEXTURE_3D, texture);
-     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
- 
-     glTexImage3D(GL_TEXTURE_3D,
-                  0,
-                  GL_RGB16F,
-                  LUT3D_EDGE_SIZE,
-                  LUT3D_EDGE_SIZE,
-                  LUT3D_EDGE_SIZE,
-                  0,
-                  GL_RGB,
-                  GL_FLOAT,
-                  NULL);
-   }
 -  lut3d->texture = GPU_texture_create_3d("OCIOLut", UNPACK3(extent), 1, GPU_RGB16F, NULL);
++  lut3d->texture = GPU_texture_create_3d(
++      "OCIOLut", UNPACK3(extent), 1, GPU_RGB16F, GPU_DATA_FLOAT, NULL);
+   GPU_texture_filter_mode(lut3d->texture, true);
+   GPU_texture_wrap_mode(lut3d->texture, false, true);
+ 
+   lut3d->texture_display = GPU_texture_create_3d(
 -      "OCIOLutDisplay", UNPACK3(extent), 1, GPU_RGB16F, NULL);
++      "OCIOLutDisplay", UNPACK3(extent), 1, GPU_RGB16F, GPU_DATA_FLOAT, NULL);
+   GPU_texture_filter_mode(lut3d->texture_display, true);
+   GPU_texture_wrap_mode(lut3d->texture_display, false, true);
+ 
+   lut3d->texture_dummy = GPU_texture_create_error(2, false);
  
    updateGLSLLut3d(lut3d, processor_scene_to_ui, processpr_ui_to_display, shaderDesc, cache_id);
  
diff --cc release/scripts/modules/rna_manual_reference.py
index eeb8e8278a8,a8c8b212ecf..44d40e974c1
--- a/release/scripts/modules/rna_manual_reference.py
+++ b/release/scripts/modules/rna_manual_reference.py
@@@ -147,10 -147,9 +153,10 @@@ url_manual_mapping = 
  	("bpy.types.linestylegeometrymodifier_2dtransform*", "render/freestyle/parameter_editor/line_style/modifiers/geometry/2d_transform.html#bpy-types-linestylegeometrymodifier-2dtransform"),
  	("bpy.types.linestylegeometrymodifier_beziercurve*", "render/freestyle/parameter_editor/line_style/modifiers/geometry/bezier_curve.html#bpy-types-linestylegeometrymodifier-beziercurve"),
  	("bpy.types.particlesettings.use_parent_particles*", "physics/particles/emitter/render.html#bpy-types-particlesettings-use-parent-particles"),
- 	("bpy.types.rendersettings_simplify_gpencil_blend*", "render/cycles/render_settings/simplify.html#bpy-types-rendersettings-simplify-gpencil-blend"),
+ 	("bpy.types.rigidbodyconstraint.solver_iterations*", "physics/rigid_body/constraints/introduction.html#bpy-types-rigidbodyconstraint-solver-iterations"),
  	("bpy.types.toolsettings.gpencil_stroke_placement*", "grease_pencil/modes/draw/stroke_placement.html#bpy-types-toolsettings-gpencil-stroke-placement"),
  	("bpy.types.cyclesrendersettings.use_camera_cull*", "render/cycles/render_settings/simplify.html#bpy-types-cyclesrendersettings-use-camera-cull"),
 +	("bpy.types.fluiddomainsettings.coba_field_scale*", "physics/fluid/type/domain/gas/viewport_display.html#bpy-types-fluiddomainsettings-coba-field-scale"),
  	("bpy.types.fluiddomainsettings.guide_vel_factor*", "physics/fluid/type/domain/guides.html#bpy-types-fluiddomainsettings-guide-vel-factor"),
  	("bpy.types.fluideffectorsettings.use_plane_init*", "physics/fluid/type/effector.html#bpy-types-fluideffectorsettings-use-plane-init"),
  	("bpy.types.linestylegeometrymodifier_tipremover*", "render/freestyle/parameter_editor/line_style/modifiers/geometry/tip_remover.html#bpy-types-linestylegeometrymodifier-tipremover"),
diff --cc source/blender/draw/engines/workbench/workbench_volume.c
index 148760e3750,7aa089d440f..3f64622735c
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@@ -45,9 -45,9 +45,11 @@@ void workbench_volume_engine_init(WORKB
    if (txl->dummy_volume_tx == NULL) {
      const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
      const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-     txl->dummy_volume_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, zero, NULL);
-     txl->dummy_shadow_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, one, NULL);
-     txl->dummy_coba_tx = GPU_texture_create_1d(1, GPU_RGBA8, zero, NULL);
 -    txl->dummy_volume_tx = GPU_texture_create_3d("dummy_volume", 1, 1, 1, 1, GPU_RGBA8, zero);
 -    txl->dummy_shadow_tx = GPU_texture_create_3d("dummy_shadow", 1, 1, 1, 1, GPU_RGBA8, one);
++    txl->dummy_volume_tx = GPU_texture_create_3d(
++        "dummy_volume", 1, 1, 1, 1, GPU_RGBA8, GPU_DATA_FLOAT, zero);
++    txl->dummy_shadow_tx = GPU_texture_create_3d(
++        "dummy_shadow", 1, 1, 1, 1, GPU_RGBA8, GPU_DATA_FLOAT, one);
+     txl->dummy_coba_tx = GPU_texture_create_1d("dummy_coba", 1, 1, GPU_RGBA8, zero);
    }
  }
  
diff --cc source/blender/draw/intern/draw_cache_impl_volume.c
index 825fec83cf1,10b9623175c..e39c4976e38
--- a/source/blender/draw/intern/draw_cache_impl_volume.c
+++ b/source/blender/draw/intern/draw_cache_impl_volume.c
@@@ -258,17 -258,12 +258,12 @@@ static DRWVolumeGrid *volume_grid_cache
      BKE_volume_grid_dense_voxels(volume, grid, dense_min, dense_max, voxels);
  
      /* Create GPU texture. */
-     cache_grid->texture = GPU_texture_create_3d(resolution[0],
-                                                 resolution[1],
-                                                 resolution[2],
-                                                 (channels == 3) ? GPU_RGB16F : GPU_R16F,
-                                                 voxels,
-                                                 NULL);
- 
-     GPU_texture_bind(cache_grid->texture, 0);
+     eGPUTextureFormat format = (channels == 3) ? GPU_RGB16F : GPU_R16F;
+     cache_grid->texture = GPU_texture_create_3d(
 -        "volume_grid", UNPACK3(resolution), 1, format, voxels);
++        "volume_grid", UNPACK3(resolution), 1, format, GPU_DATA_FLOAT, voxels);
+ 
      GPU_texture_swizzle_set(cache_grid->texture, (channels == 3) ? "rgb1" : "rrr1");
      GPU_texture_wrap_mode(cache_grid->texture, false, false);
-     GPU_texture_unbind(cache_grid->texture);
  
      MEM_freeN(voxels);
  
diff --cc source/blender/draw/intern/draw_fluid.c
index d22440ef4b9,af14f11e6e9..8164ce398f1
--- a/source/blender/draw/intern/draw_fluid.c
+++ b/source/blender/draw/intern/draw_fluid.c
@@@ -128,20 -128,105 +128,117 @@@ static void swizzle_texture_channel_sin
  {
    /* Swizzle texture channels so that we get useful RGBA values when sampling
     * a texture with fewer channels, e.g. when using density as color. */
-   GPU_texture_bind(tex, 0);
    GPU_texture_swizzle_set(tex, "rrr1");
-   GPU_texture_unbind(tex);
+ }
+ 
+ static float *rescale_3d(const int dim[3],
+                          const int final_dim[3],
+                          int channels,
+                          const float *fpixels)
+ {
+   const uint w = dim[0], h = dim[1], d = dim[2];
+   const uint fw = final_dim[0], fh = final_dim[1], fd = final_dim[2];
+   const uint xf = w / fw, yf = h / fh, zf = d / fd;
+   const uint pixel_count = fw * fh * fd;
+   float *nfpixels = (float *)MEM_mallocN(channels * sizeof(float) * pixel_count, __func__);
+ 
+   if (nfpixels) {
+     printf("Performance: You need to scale a 3D texture, feel the pain!\n");
+ 
+     for (uint k = 0; k < fd; k++) {
+       for (uint j = 0; j < fh; j++) {
+         for (uint i = 0; i < fw; i++) {
+           /* Obviously doing nearest filtering here,
+            * it's going to be slow in any case, let's not make it worse. */
+           float xb = i * xf;
+           float yb = j * yf;
+           float zb = k * zf;
+           uint offset = k * (fw * fh) + i * fh + j;
+           uint offset_orig = (zb) * (w * h) + (xb)*h + (yb);
+ 
+           if (channels == 4) {
+             nfpixels[offset * 4] = fpixels[offset_orig * 4];
+             nfpixels[offset * 4 + 1] = fpixels[offset_orig * 4 + 1];
+             nfpixels[offset * 4 + 2] = fpixels[offset_orig * 4 + 2];
+             nfpixels[offset * 4 + 3] = fpixels[offset_orig * 4 + 3];
+           }
+           else if (channels == 1) {
+             nfpixels[offset] = fpixels[offset_orig];
+           }
+           else {
+             BLI_assert(0);
+           }
+         }
+       }
+     }
+   }
+   return nfpixels;
+ }
+ 
+ /* Will resize input to fit GL system limits. */
+ static GPUTexture *create_volume_texture(const int dim[3],
 -                                         eGPUTextureFormat format,
 -                                         const float *data)
++                                         eGPUTextureFormat texture_format,
++                                         eGPUDataFormat data_format,
++                                         const void *data)
+ {
+   GPUTexture *tex = NULL;
+   int final_dim[3] = {UNPACK3(dim)};
+ 
+   while (1) {
 -    tex = GPU_texture_create_3d("volume", UNPACK3(final_dim), 1, format, NULL);
++    tex = GPU_texture_create_3d(
++        "volume", UNPACK3(final_dim), 1, texture_format, data_format, NULL);
+ 
+     if (tex != NULL) {
+       break;
+     }
+ 
+     if (final_dim[0] == 1 && final_dim[1] == 1 && final_dim[2] == 1) {
+       break;
+     }
+ 
+     for (int i = 0; i < 3; i++) {
+       final_dim[i] = max_ii(1, final_dim[i] / 2);
+     }
+   }
+ 
+   if (tex == NULL) {
+     printf("Error: Could not create 3D texture.\n");
+     tex = GPU_texture_create_error(3, false);
+   }
+   else if (equals_v3v3_int(dim, final_dim)) {
+     /* No need to resize, just upload the data. */
 -    GPU_texture_update_sub(tex, GPU_DATA_FLOAT, data, 0, 0, 0, UNPACK3(final_dim));
++    GPU_texture_update_sub(tex, data_format, data, 0, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list