Differential D13910 Diff 47464 source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
| #pragma BLENDER_REQUIRE(common_hair_lib.glsl) | #pragma BLENDER_REQUIRE(common_hair_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(common_view_lib.glsl) | #pragma BLENDER_REQUIRE(common_view_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_shader_interface_lib.glsl) | #pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_common_lib.glsl) | #pragma BLENDER_REQUIRE(workbench_common_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_material_lib.glsl) | #pragma BLENDER_REQUIRE(workbench_material_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_image_lib.glsl) | #pragma BLENDER_REQUIRE(workbench_image_lib.glsl) | ||||
| #ifndef WORKBENCH_SHADER_SHARED_H | |||||
| uniform samplerBuffer ac; /* active color layer */ | |||||
| uniform samplerBuffer au; /* active texture layer */ | |||||
| #endif | |||||
| /* From http://libnoise.sourceforge.net/noisegen/index.html */ | /* From http://libnoise.sourceforge.net/noisegen/index.html */ | ||||
| float integer_noise(int n) | float integer_noise(int n) | ||||
| { | { | ||||
| n = (n >> 13) ^ n; | n = (n >> 13) ^ n; | ||||
| int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; | int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; | ||||
| return (float(nn) / 1073741824.0); | return (float(nn) / 1073741824.0); | ||||
| } | } | ||||
| Show All 39 Lines | hair_get_pos_tan_binor_time(is_persp, | ||||
| thickness, | thickness, | ||||
| thick_time); | thick_time); | ||||
| gl_Position = point_world_to_ndc(world_pos); | gl_Position = point_world_to_ndc(world_pos); | ||||
| float hair_rand = integer_noise(hair_get_strand_id()); | float hair_rand = integer_noise(hair_get_strand_id()); | ||||
| vec3 nor = workbench_hair_random_normal(tan, binor, hair_rand); | vec3 nor = workbench_hair_random_normal(tan, binor, hair_rand); | ||||
| #ifdef USE_WORLD_CLIP_PLANES | view_clipping_distances(world_pos); | ||||
| world_clip_planes_calc_clip_distance(world_pos); | |||||
| #endif | |||||
| uv_interp = hair_get_customdata_vec2(au); | uv_interp = hair_get_customdata_vec2(au); | ||||
| normal_interp = normalize(normal_world_to_view(nor)); | normal_interp = normalize(normal_world_to_view(nor)); | ||||
| #ifndef WORKBENCH_SHADER_SHARED_H | |||||
| # ifdef OPAQUE_MATERIAL | |||||
| float metallic, roughness; | |||||
| # endif | |||||
| #endif | |||||
| workbench_material_data_get(resource_handle, color_interp, alpha_interp, roughness, metallic); | workbench_material_data_get(resource_handle, color_interp, alpha_interp, roughness, metallic); | ||||
| if (materialIndex == 0) { | if (materialIndex == 0) { | ||||
| color_interp = hair_get_customdata_vec3(ac); | color_interp = hair_get_customdata_vec3(ac); | ||||
| } | } | ||||
| /* Hairs have lots of layer and can rapidly become the most prominent surface. | /* Hairs have lots of layer and can rapidly become the most prominent surface. | ||||
| * So we lower their alpha artificially. */ | * So we lower their alpha artificially. */ | ||||
| alpha_interp *= 0.3; | alpha_interp *= 0.3; | ||||
| workbench_hair_random_material(hair_rand, color_interp, roughness, metallic); | workbench_hair_random_material(hair_rand, color_interp, roughness, metallic); | ||||
| #ifdef OPAQUE_MATERIAL | |||||
| packed_rough_metal = workbench_float_pair_encode(roughness, metallic); | |||||
| #endif | |||||
| object_id = int(uint(resource_handle) & 0xFFFFu) + 1; | object_id = int(uint(resource_handle) & 0xFFFFu) + 1; | ||||
| } | } | ||||