Commit: 392b5b82122e8c0fe19a8552dfa3934574506274
Author: Luca Rood
Date:   Mon May 15 16:25:52 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB392b5b82122e8c0fe19a8552dfa3934574506274

Implement matcaps for hair

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

M       release/scripts/startup/bl_ui/properties_collection.py
M       release/scripts/startup/bl_ui/properties_render.py
M       source/blender/draw/engines/clay/clay_engine.c
M       source/blender/draw/engines/clay/shaders/particle_strand_frag.glsl
M       source/blender/draw/engines/clay/shaders/particle_vert.glsl
M       source/blender/draw/intern/draw_cache_impl_particles.c
M       source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_collection.py 
b/release/scripts/startup/bl_ui/properties_collection.py
index 5ce180f6be7..6a8a7d188c2 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -68,16 +68,7 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, 
Panel):
         col.template_override_property(collection_props, scene_props, 
"ssao_factor_edge")
         col.template_override_property(collection_props, scene_props, 
"ssao_distance")
         col.template_override_property(collection_props, scene_props, 
"ssao_attenuation")
-        col.template_override_property(collection_props, scene_props, 
"world_intensity")
-
-        col.separator()
-        col.label("Hair Settings:")
-        col.template_override_property(collection_props, scene_props, 
"diffuse_intensity")
-        col.template_override_property(collection_props, scene_props, 
"specular_intensity")
-        col.template_override_property(collection_props, scene_props, 
"specular_hardness")
         col.template_override_property(collection_props, scene_props, 
"color_randomicity")
-        col.template_override_property(collection_props, scene_props, 
"hair_diffuse_color")
-        col.template_override_property(collection_props, scene_props, 
"hair_specular_color")
 
 
 class COLLECTION_PT_object_mode_settings(CollectionButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_render.py 
b/release/scripts/startup/bl_ui/properties_render.py
index e56c559a163..1bda0e65a98 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -614,16 +614,7 @@ class 
RENDER_PT_clay_collection_settings(RenderButtonsPanel, Panel):
         col.prop(props, "ssao_factor_edge")
         col.prop(props, "ssao_distance")
         col.prop(props, "ssao_attenuation")
-
-        col.separator()
-        col.label("Hair Settings:")
-        col.prop(props, "world_intensity")
-        col.prop(props, "diffuse_intensity")
-        col.prop(props, "specular_intensity")
-        col.prop(props, "specular_hardness")
         col.prop(props, "color_randomicity")
-        col.prop(props, "hair_diffuse_color")
-        col.prop(props, "hair_specular_color")
 
 class RENDER_PT_eevee_poststack_settings(RenderButtonsPanel, Panel):
     bl_label = "Post Process Stack"
diff --git a/source/blender/draw/engines/clay/clay_engine.c 
b/source/blender/draw/engines/clay/clay_engine.c
index f7cb606b7ae..7927b3df390 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -65,16 +65,11 @@ typedef struct CLAY_UBO_Material {
 BLI_STATIC_ASSERT_ALIGN(CLAY_UBO_Material, 16);
 
 typedef struct CLAY_HAIR_UBO_Material {
-       float hair_world;
-       float hair_diffuse;
-       float hair_specular;
-       float hair_hardness;
        float hair_randomicity;
-       float pad1[3];
-       float hair_diffuse_color[3];
-       float pad2;
-       float hair_specular_color[3];
-       float pad3;
+       float matcap_id;
+       float matcap_rot[2];
+       float matcap_hsv[3];
+       float pad;
 } CLAY_HAIR_UBO_Material; /* 48 bytes */
 
 #define MAX_CLAY_MAT 512 /* 512 = 9 bit material id */
@@ -157,9 +152,6 @@ static struct {
        struct GPUTexture *jitter_tx;
        struct GPUTexture *sampling_tx;
 
-       /* hair */
-       float hair_light[3];
-
        /* Just a serie of int from 0 to MAX_CLAY_MAT-1 */
        int ubo_mat_idxs[MAX_CLAY_MAT];
        int hair_ubo_mat_idxs[MAX_CLAY_MAT];
@@ -454,13 +446,6 @@ static void CLAY_engine_init(void *vedata)
                        e_data.cached_sample_num = ssao_samples;
                }
        }
-
-       /* hair setup */
-       {
-               e_data.hair_light[0] = 1.0f;
-               e_data.hair_light[1] = -0.5f;
-               e_data.hair_light[2] = -0.7f;
-       }
 }
 
 static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *vedata, DRWPass *pass, 
int *material_id)
@@ -489,7 +474,7 @@ static DRWShadingGroup *CLAY_hair_shgroup_create(DRWPass 
*pass, int *material_id
 {
        DRWShadingGroup *grp = DRW_shgroup_create(e_data.hair_sh, pass);
 
-       DRW_shgroup_uniform_vec3(grp, "light", e_data.hair_light, 1);
+       DRW_shgroup_uniform_texture(grp, "matcaps", e_data.matcap_array);
        DRW_shgroup_uniform_int(grp, "mat_id", material_id, 1);
 
        return grp;
@@ -522,28 +507,20 @@ static int search_mat_to_ubo(
        return -1;
 }
 
-static int search_hair_mat_to_ubo(CLAY_Storage *storage, float hair_world, 
float hair_diffuse, float hair_specular,
-                                  float hair_hardness, float hair_randomicity, 
const float *hair_diff_color,
-                                  const float *hair_spec_color)
+static int search_hair_mat_to_ubo(CLAY_Storage *storage, float matcap_rot, 
float matcap_hue, float matcap_sat,
+                                  float matcap_val, float hair_randomicity, 
int matcap_icon)
 {
        /* For now just use a linear search and test all parameters */
        /* TODO make a hash table */
        for (int i = 0; i < storage->hair_ubo_current_id; ++i) {
                CLAY_HAIR_UBO_Material *ubo = 
&storage->hair_mat_storage.materials[i];
 
-               if ((ubo->hair_world == hair_world) &&
-                   (ubo->hair_diffuse == hair_diffuse) &&
-                   (ubo->hair_specular == hair_specular) &&
-                   (ubo->hair_hardness == hair_hardness) &&
+               if ((ubo->matcap_rot[0] == cosf(matcap_rot * 3.14159f * 2.0f)) 
&&
+                   (ubo->matcap_hsv[0] == matcap_hue + 0.5f) &&
+                   (ubo->matcap_hsv[1] == matcap_sat * 2.0f) &&
+                   (ubo->matcap_hsv[2] == matcap_val * 2.0f) &&
                    (ubo->hair_randomicity == hair_randomicity) &&
-                   (ubo->hair_diffuse_color[0] == hair_diff_color[0]) &&
-                   (ubo->hair_diffuse_color[1] == hair_diff_color[1]) &&
-                   (ubo->hair_diffuse_color[2] == hair_diff_color[2]) &&
-                   (ubo->hair_diffuse_color[3] == hair_diff_color[3]) &&
-                   (ubo->hair_specular_color[0] == hair_spec_color[0]) &&
-                   (ubo->hair_specular_color[1] == hair_spec_color[1]) &&
-                   (ubo->hair_specular_color[2] == hair_spec_color[2]) &&
-                   (ubo->hair_specular_color[3] == hair_spec_color[3]))
+                   (ubo->matcap_id == matcap_to_index(matcap_icon)))
                {
                        return i;
                }
@@ -579,26 +556,22 @@ static int push_mat_to_ubo(CLAY_Storage *storage, float 
matcap_rot, float matcap
        return id;
 }
 
-static int push_hair_mat_to_ubo(CLAY_Storage *storage, float hair_world, float 
hair_diffuse, float hair_specular,
-                                  float hair_hardness, float hair_randomicity, 
const float *hair_diff_color,
-                                const float *hair_spec_color)
+static int push_hair_mat_to_ubo(CLAY_Storage *storage, float matcap_rot, float 
matcap_hue, float matcap_sat,
+                                float matcap_val, float hair_randomicity, int 
matcap_icon)
 {
        int id = storage->hair_ubo_current_id;
        CLAY_HAIR_UBO_Material *ubo = &storage->hair_mat_storage.materials[id];
 
-       ubo->hair_world = hair_world;
-       ubo->hair_diffuse = hair_diffuse;
-       ubo->hair_specular = hair_specular;
-       ubo->hair_hardness = hair_hardness;
+       ubo->matcap_rot[0] = cosf(matcap_rot * 3.14159f * 2.0f);
+       ubo->matcap_rot[1] = sinf(matcap_rot * 3.14159f * 2.0f);
+
+       ubo->matcap_hsv[0] = matcap_hue + 0.5f;
+       ubo->matcap_hsv[1] = matcap_sat * 2.0f;
+       ubo->matcap_hsv[2] = matcap_val * 2.0f;
+
        ubo->hair_randomicity = hair_randomicity;
-       ubo->hair_diffuse_color[0] = hair_diff_color[0];
-       ubo->hair_diffuse_color[1] = hair_diff_color[1];
-       ubo->hair_diffuse_color[2] = hair_diff_color[2];
-       ubo->hair_diffuse_color[3] = hair_diff_color[3];
-       ubo->hair_specular_color[0] = hair_spec_color[0];
-       ubo->hair_specular_color[1] = hair_spec_color[1];
-       ubo->hair_specular_color[2] = hair_spec_color[2];
-       ubo->hair_specular_color[3] = hair_spec_color[3];
+
+       ubo->matcap_id = matcap_to_index(matcap_icon);
 
        storage->hair_ubo_current_id++;
 
@@ -624,18 +597,17 @@ static int mat_in_ubo(CLAY_Storage *storage, float 
matcap_rot, float matcap_hue,
        return id;
 }
 
-static int hair_mat_in_ubo(CLAY_Storage *storage, float hair_world, float 
hair_diffuse, float hair_specular,
-                           float hair_hardness, float hair_randomicity, const 
float *hair_diff_color,
-                           const float *hair_spec_color)
+static int hair_mat_in_ubo(CLAY_Storage *storage, float matcap_rot, float 
matcap_hue, float matcap_sat,
+                           float matcap_val, float hair_randomicity, int 
matcap_icon)
 {
        /* Search material in UBO */
-       int id = search_hair_mat_to_ubo(storage, hair_world, hair_diffuse, 
hair_specular,
-                                       hair_hardness, hair_randomicity, 
hair_diff_color, hair_spec_color);
+       int id = search_hair_mat_to_ubo(storage, matcap_rot, matcap_hue, 
matcap_sat,
+                                       matcap_val, hair_randomicity, 
matcap_icon);
 
        /* if not found create it */
        if (id == -1) {
-               id = push_hair_mat_to_ubo(storage, hair_world, hair_diffuse, 
hair_specular,
-                                         hair_hardness, hair_randomicity, 
hair_diff_color, hair_spec_color);
+               id = push_hair_mat_to_ubo(storage, matcap_rot, matcap_hue, 
matcap_sat,
+                                         matcap_val, hair_randomicity, 
matcap_icon);
        }
 
        return id;
@@ -678,16 +650,15 @@ static DRWShadingGroup *CLAY_hair_shgrp_get(Object *ob, 
CLAY_StorageList *stl, C
        IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, 
COLLECTION_MODE_NONE, RE_engine_id_BLENDER_CLAY);
 
        /* Default Settings */
-       float hair_world = 
BKE_collection_engine_property_value_get_float(props, "world_intensity");
-       float hair_diffuse = 
BKE_collection_engine_property_value_get_float(props, "diffuse_intensity");
-       float hair_specular = 
BKE_collection_engine_property_value_get_float(props, "specular_intensity");
-       float hair_hardness = 
BKE_collection_engine_property_value_get_float(props, "specular_hardness");
+       float matcap_rot = 
BKE_collection_engine_property_value_get_float(props, "matcap_rotation");
+       float matcap_hue = 
BKE_collection_engine_property_value_get_float(props, "matcap_hue");
+       float matcap_sat = 
BKE_collection_engine_property_value_get_float(props, "matcap_saturation");
+       float matcap_val = 
BKE_collection_engine_property_value_get_float(props, "matcap_value");
        float hair_randomicity = 
BKE_collection_engine_property_value_get_float(props, "color_randomicity");
-       const float *hair_diff_color = BKE_collection_engi

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to