[Bf-blender-cvs] [a7404958148] blender2.8: Eevee: Add "uber" Shader Output Nodes.
Clément Foucault
noreply at git.blender.org
Wed May 3 12:09:03 CEST 2017
Commit: a7404958148f1030483c7d6238ebf48abc26cf24
Author: Clément Foucault
Date: Tue May 2 19:25:25 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBa7404958148f1030483c7d6238ebf48abc26cf24
Eevee: Add "uber" Shader Output Nodes.
Include Metallic and Specular workflow.
Clearcoat and are not implemented yet.
===================================================================
M release/scripts/startup/nodeitems_builtins.py
M source/blender/blenkernel/BKE_node.h
M source/blender/blenkernel/intern/node.c
M source/blender/draw/engines/eevee/eevee_engine.c
M source/blender/draw/engines/eevee/eevee_private.h
M source/blender/draw/engines/eevee/shaders/default_frag.glsl
M source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
M source/blender/gpu/shaders/gpu_shader_material.glsl
M source/blender/nodes/CMakeLists.txt
M source/blender/nodes/NOD_shader.h
M source/blender/nodes/NOD_static_types.h
A source/blender/nodes/shader/nodes/node_shader_output_metallic.c
A source/blender/nodes/shader/nodes/node_shader_output_specular.c
===================================================================
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index bee6ae80590..2e2684a0524 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -216,6 +216,8 @@ shader_node_categories = [
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
]),
ShaderNewNodeCategory("SH_NEW_OUTPUT", "Output", items=[
+ NodeItem("ShaderNodeOutputMetallic", poll=object_shader_nodes_poll),
+ NodeItem("ShaderNodeOutputSpecular", poll=object_shader_nodes_poll),
NodeItem("ShaderNodeOutputMaterial", poll=object_shader_nodes_poll),
NodeItem("ShaderNodeOutputLamp", poll=object_shader_nodes_poll),
NodeItem("ShaderNodeOutputWorld", poll=world_shader_nodes_poll),
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 219bca0a1a9..42d62297243 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -794,6 +794,8 @@ struct ShadeResult;
#define SH_NODE_UVALONGSTROKE 191
#define SH_NODE_TEX_POINTDENSITY 192
#define SH_NODE_BSDF_PRINCIPLED 193
+#define SH_NODE_OUTPUT_METALLIC 194
+#define SH_NODE_OUTPUT_SPECULAR 195
/* custom defines options for Material node */
#define SH_NODE_MAT_DIFF 1
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 4b7dcc1b9b5..7c382bccfc9 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -3588,6 +3588,8 @@ static void registerShaderNodes(void)
register_node_type_sh_output_lamp();
register_node_type_sh_output_material();
+ register_node_type_sh_output_metallic();
+ register_node_type_sh_output_specular();
register_node_type_sh_output_world();
register_node_type_sh_output_linestyle();
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 01849678366..6572abde728 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -490,20 +490,8 @@ static void EEVEE_cache_init(void *vedata)
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL;
psl->material_pass = DRW_pass_create("Material Shader Pass", state);
-
- /* NOTE : this shading grp does not contain any geom, it's just here to setup uniforms & textures. */
- stl->g_data->material_lit_grp = DRW_shgroup_create(e_data.default_lit, psl->material_pass);
- DRW_shgroup_uniform_block(stl->g_data->material_lit_grp, "light_block", stl->light_ubo, 0);
- DRW_shgroup_uniform_block(stl->g_data->material_lit_grp, "shadow_block", stl->shadow_ubo, 1);
- DRW_shgroup_uniform_int(stl->g_data->material_lit_grp, "light_count", &stl->lamps->num_light, 1);
- DRW_shgroup_uniform_float(stl->g_data->material_lit_grp, "lodMax", &stl->probes->lodmax, 1);
- DRW_shgroup_uniform_vec3(stl->g_data->material_lit_grp, "shCoefs[0]", (float *)stl->probes->shcoefs, 9);
- DRW_shgroup_uniform_vec3(stl->g_data->material_lit_grp, "cameraPos", e_data.camera_pos, 1);
- DRW_shgroup_uniform_texture(stl->g_data->material_lit_grp, "ltcMat", e_data.ltc_mat, 0);
- DRW_shgroup_uniform_texture(stl->g_data->material_lit_grp, "brdfLut", e_data.brdf_lut, 1);
- DRW_shgroup_uniform_texture(stl->g_data->material_lit_grp, "probeFiltered", txl->probe_pool, 2);
- /* NOTE : Adding Shadow Map textures uniform in EEVEE_cache_finish */
}
+
{
/* Final pass : Map HDR color to LDR color.
* Write result to the default color buffer */
@@ -522,6 +510,7 @@ static void EEVEE_cache_init(void *vedata)
static void EEVEE_cache_populate(void *vedata, Object *ob)
{
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ EEVEE_TextureList *txl = ((EEVEE_Data *)vedata)->txl;
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
struct Batch *geom = DRW_cache_object_surface_get(ob);
@@ -558,6 +547,16 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
if (shgrp) {
DRW_shgroup_call_add(shgrp, mat_geom[i], ob->obmat);
+
+ DRW_shgroup_uniform_block(shgrp, "light_block", stl->light_ubo, 0);
+ DRW_shgroup_uniform_block(shgrp, "shadow_block", stl->shadow_ubo, 1);
+ DRW_shgroup_uniform_int(shgrp, "light_count", &stl->lamps->num_light, 1);
+ DRW_shgroup_uniform_float(shgrp, "lodMax", &stl->probes->lodmax, 1);
+ DRW_shgroup_uniform_vec3(shgrp, "shCoefs[0]", (float *)stl->probes->shcoefs, 9);
+ DRW_shgroup_uniform_vec3(shgrp, "cameraPos", e_data.camera_pos, 1);
+ DRW_shgroup_uniform_texture(shgrp, "ltcMat", e_data.ltc_mat, 0);
+ DRW_shgroup_uniform_texture(shgrp, "brdfLut", e_data.brdf_lut, 1);
+ DRW_shgroup_uniform_texture(shgrp, "probeFiltered", txl->probe_pool, 2);
}
else {
/* Shader failed : pink color */
@@ -599,8 +598,23 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
}
}
+typedef struct eevee_bind_shadow_data {
+ struct GPUTexture *shadow_depth_map_pool;
+ struct GPUTexture *shadow_depth_cube_pool;
+ struct GPUTexture *shadow_depth_cascade_pool;
+} eevee_bind_shadow_data;
+
+static void eevee_bind_shadow(void *data, DRWShadingGroup *shgrp)
+{
+ eevee_bind_shadow_data *shdw_data = data;
+ DRW_shgroup_uniform_texture(shgrp, "shadowMaps", shdw_data->shadow_depth_map_pool, 3);
+ DRW_shgroup_uniform_texture(shgrp, "shadowCubes", shdw_data->shadow_depth_cube_pool, 4);
+ DRW_shgroup_uniform_texture(shgrp, "shadowCascades", shdw_data->shadow_depth_cascade_pool, 5);
+}
+
static void EEVEE_cache_finish(void *vedata)
{
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
EEVEE_TextureList *txl = ((EEVEE_Data *)vedata)->txl;
EEVEE_FramebufferList *fbl = ((EEVEE_Data *)vedata)->fbl;
@@ -608,13 +622,14 @@ static void EEVEE_cache_finish(void *vedata)
EEVEE_lights_cache_finish(stl, txl, fbl);
/* Shadows binding */
- DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "shadowMaps", txl->shadow_depth_map_pool, 4);
- DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "shadowCubes", txl->shadow_depth_cube_pool, 5);
- DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "shadowCascades", txl->shadow_depth_cascade_pool, 6);
+ eevee_bind_shadow_data data;
+
+ data.shadow_depth_map_pool = txl->shadow_depth_map_pool;
+ data.shadow_depth_cube_pool = txl->shadow_depth_cube_pool;
+ data.shadow_depth_cascade_pool = txl->shadow_depth_cascade_pool;
- DRW_shgroup_uniform_texture(stl->g_data->material_lit_grp, "shadowMaps", txl->shadow_depth_map_pool, 4);
- DRW_shgroup_uniform_texture(stl->g_data->material_lit_grp, "shadowCubes", txl->shadow_depth_cube_pool, 5);
- DRW_shgroup_uniform_texture(stl->g_data->material_lit_grp, "shadowCascades", txl->shadow_depth_cascade_pool, 6);
+ DRW_pass_foreach_shgroup(psl->default_pass, eevee_bind_shadow, &data);
+ DRW_pass_foreach_shgroup(psl->material_pass, eevee_bind_shadow, &data);
}
static void EEVEE_draw_scene(void *vedata)
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index ee8e8598725..3876ab44d95 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -175,7 +175,6 @@ typedef struct EEVEE_LampEngineData {
typedef struct EEVEE_PrivateData {
struct DRWShadingGroup *default_lit_grp;
- struct DRWShadingGroup *material_lit_grp;
struct DRWShadingGroup *shadow_shgrp;
struct DRWShadingGroup *depth_shgrp;
struct DRWShadingGroup *depth_shgrp_cull;
diff --git a/source/blender/draw/engines/eevee/shaders/default_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_frag.glsl
index 8d4a1e6d523..57622aa716b 100644
--- a/source/blender/draw/engines/eevee/shaders/default_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/default_frag.glsl
@@ -9,5 +9,5 @@ void main()
{
float roughness = 1.0 - float(hardness) / 511.0;
roughness *= roughness;
- FragColor = vec4(eevee_surface_lit(worldNormal, diffuse_col, specular_col, roughness), 1.0);
+ FragColor = vec4(eevee_surface_lit(worldNormal, diffuse_col, specular_col, roughness, 1.0), 1.0);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 9b8963ef798..0d96b7768dc 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -231,7 +231,7 @@ float light_common(inout LightData ld, inout ShadingData sd)
return vis;
}
-vec3 eevee_surface_lit(vec3 world_normal, vec3 albedo, vec3 f0, float roughness)
+vec3 eevee_surface_lit(vec3 world_normal, vec3 albedo, vec3 f0, float roughness, float ao)
{
ShadingData sd;
sd.N = normalize(world_normal);
@@ -243,6 +243,7 @@ vec3 eevee_surface_lit(vec3 world_normal, vec3 albedo, vec3 f0, float roughness)
sd.spec_dominant_dir = get_specular_dominant_dir(sd.N, sd.R, roughness);
vec3 radiance = vec3(0.0);
+ vec3 indirect_radiance = vec3(0.0);
/* Analitic Lights */
for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
@@ -264,9 +265,9 @@ vec3 eevee_surface_lit(vec3 world_normal, vec3 albedo, vec3 f0, float roughness)
vec2 uv = ltc_coords(dot(sd.N, sd.V), sqrt(roughness));
vec2 brdf_lut = texture(brdfLut, uv).rg;
vec3 Li = textureLod(probeFiltered, sd.spec_dominant_dir, roughness * lodMax).rgb;
- radiance += Li * brdf_lut.y + f0 * Li * brdf_lut.x;
+ indirect_radiance += Li * brdf_lut.y + f0 * Li * brdf_lut.x;
- radiance += spherical_harmonics(sd.N, shCoefs) * albedo;
+ indirect_radiance += spherical_harmonics(sd.N, shCoefs) * albedo;
- return radiance;
+ return radiance + indirect_radiance * ao;
}
\ No newline at end of file
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 8bfbd07bce8..1da213b4103 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -3828,6 +3828,37 @@ void node_output_world(vec4 surface, vec4 volume, out vec4 result)
result
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list