Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-05-29 13:11:03 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-30 13:25:20 +0300
commit328f8dc21c0e8a7e3da14f6578fb84a811f80b89 (patch)
tree6d7cbe0cb0bc0fee859bff5c73f98dbf9109b6f8 /source/blender/draw/intern/draw_hair_private.h
parent2faef3473c061e34a03668905c8d81672a72dd38 (diff)
DRW: Add new GPU hair system.
This new system use transform feedback to compute subdivided hair points position. For now no smoothing is done between input points. This new system decouple the strands data (uv, mcol) with the points position, requiring less update work if only simulation is running. In the future, we can have compute shader do the work of the feedback transform pass since it's really what it's meant to. Also we could generate the child particles during this pass, releasing some CPU time. draw_hair.c has been created to handle all of the Shading group creations as well as subdivision shaders. We store one final batch per settings combination because multiple viewport or render could use the same particle system with a different subdivision count or hair shape type.
Diffstat (limited to 'source/blender/draw/intern/draw_hair_private.h')
-rw-r--r--source/blender/draw/intern/draw_hair_private.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h
new file mode 100644
index 00000000000..2e6c9a0d3c1
--- /dev/null
+++ b/source/blender/draw/intern/draw_hair_private.h
@@ -0,0 +1,92 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2017 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, Mike Erwin, Dalai Felinto
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file draw_hair_private.h
+ * \ingroup draw
+ */
+
+#ifndef __DRAW_HAIR_PRIVATE_H__
+#define __DRAW_HAIR_PRIVATE_H__
+
+#define MAX_LAYER_NAME_CT 3 /* u0123456789, u, a0123456789 */
+#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(unsigned int) + 2
+#define MAX_THICKRES 2 /* see eHairType */
+#define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */
+
+struct Object;
+struct ParticleSystem;
+struct ModifierData;
+struct ParticleHairCache;
+
+typedef struct ParticleHairFinalCache {
+ /* Output of the subdivision stage: vertex buff sized to subdiv level. */
+ Gwn_VertBuf *proc_buf;
+ GPUTexture *proc_tex;
+
+ /* Just contains a huge index buffer used to draw the final hair. */
+ Gwn_Batch *proc_hairs[MAX_THICKRES];
+
+ int strands_res; /* points per hair, at least 2 */
+} ParticleHairFinalCache;
+
+typedef struct ParticleHairCache {
+ Gwn_VertBuf *pos;
+ Gwn_IndexBuf *indices;
+ Gwn_Batch *hairs;
+
+ /* Hair Procedural display: Interpolation is done on the GPU. */
+ Gwn_VertBuf *proc_point_buf; /* Input control points */
+ GPUTexture *point_tex;
+
+ Gwn_VertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */
+ GPUTexture *strand_tex;
+
+ Gwn_VertBuf *proc_uv_buf[MAX_MTFACE];
+ GPUTexture *uv_tex[MAX_MTFACE];
+ char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN];
+
+ Gwn_VertBuf *proc_col_buf[MAX_MCOL];
+ GPUTexture *col_tex[MAX_MCOL];
+ char col_layer_names[MAX_MCOL][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN];
+
+ int num_uv_layers;
+ int num_col_layers;
+
+ ParticleHairFinalCache final[MAX_HAIR_SUBDIV];
+
+ int strands_count;
+ int elems_count;
+ int point_count;
+} ParticleHairCache;
+
+bool particles_ensure_procedural_data(
+ struct Object *object,
+ struct ParticleSystem *psys,
+ struct ModifierData *md,
+ struct ParticleHairCache **r_hair_cache,
+ int subdiv,
+ int thickness_res);
+
+#endif /* __DRAW_HAIR_PRIVATE_H__ */