diff options
Diffstat (limited to 'source/blender/gpu')
4 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index aea96dac2e3..8d2355ff5ac 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -313,6 +313,7 @@ data_to_c_simple(shaders/material/gpu_shader_material_vector_curves.glsl SRC) data_to_c_simple(shaders/material/gpu_shader_material_vector_displacement.glsl SRC) data_to_c_simple(shaders/material/gpu_shader_material_vector_math.glsl SRC) data_to_c_simple(shaders/material/gpu_shader_material_velvet.glsl SRC) +data_to_c_simple(shaders/material/gpu_shader_material_vertex_color.glsl SRC) data_to_c_simple(shaders/material/gpu_shader_material_volume_absorption.glsl SRC) data_to_c_simple(shaders/material/gpu_shader_material_volume_info.glsl SRC) data_to_c_simple(shaders/material/gpu_shader_material_volume_principled.glsl SRC) diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 8b68bcd5889..242b0ed2e31 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -1080,6 +1080,15 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u "\treturn mix(c1, c2, step(vec3(0.04045), c));\n" "}\n\n"); + BLI_dynstr_append(ds, + "vec4 srgba_to_linear_attr(vec4 c) {\n" + "\tc = max(c, vec4(0.0));\n" + "\tvec4 c1 = c * (1.0 / 12.92);\n" + "\tvec4 c2 = pow((c + 0.055) * (1.0 / 1.055), vec4(2.4));\n" + "\tvec4 final = mix(c1, c2, step(vec4(0.04045), c));" + "\treturn vec4(final.xyz, c.a);\n" + "}\n\n"); + /* Prototype because defined later. */ BLI_dynstr_append(ds, "vec2 hair_get_customdata_vec2(const samplerBuffer);\n" @@ -1184,7 +1193,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u } else if (input->attr_type == CD_MCOL) { BLI_dynstr_appendf(ds, - "\tvar%d%s = srgb_to_linear_attr(att%d);\n", + "\tvar%d%s = srgba_to_linear_attr(att%d);\n", input->attr_id, use_geom ? "g" : "", input->attr_id); diff --git a/source/blender/gpu/intern/gpu_material_library.h b/source/blender/gpu/intern/gpu_material_library.h index 06544d27af9..3a38eb5c600 100644 --- a/source/blender/gpu/intern/gpu_material_library.h +++ b/source/blender/gpu/intern/gpu_material_library.h @@ -114,6 +114,7 @@ extern char datatoc_gpu_shader_material_vector_curves_glsl[]; extern char datatoc_gpu_shader_material_vector_displacement_glsl[]; extern char datatoc_gpu_shader_material_vector_math_glsl[]; extern char datatoc_gpu_shader_material_velvet_glsl[]; +extern char datatoc_gpu_shader_material_vertex_color_glsl[]; extern char datatoc_gpu_shader_material_volume_absorption_glsl[]; extern char datatoc_gpu_shader_material_volume_info_glsl[]; extern char datatoc_gpu_shader_material_volume_principled_glsl[]; @@ -527,6 +528,11 @@ static GPUMaterialLibrary gpu_shader_material_velvet_library = { .dependencies = {&gpu_shader_material_diffuse_library, NULL}, }; +static GPUMaterialLibrary gpu_shader_material_vertex_color_library = { + .code = datatoc_gpu_shader_material_vertex_color_glsl, + .dependencies = {NULL}, +}; + static GPUMaterialLibrary gpu_shader_material_volume_absorption_library = { .code = datatoc_gpu_shader_material_volume_absorption_glsl, .dependencies = {NULL}, @@ -638,6 +644,7 @@ static GPUMaterialLibrary *gpu_material_libraries[] = { &gpu_shader_material_vector_displacement_library, &gpu_shader_material_vector_math_library, &gpu_shader_material_velvet_library, + &gpu_shader_material_vertex_color_library, &gpu_shader_material_volume_absorption_library, &gpu_shader_material_volume_info_library, &gpu_shader_material_volume_principled_library, diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_vertex_color.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_vertex_color.glsl new file mode 100644 index 00000000000..551b838daf8 --- /dev/null +++ b/source/blender/gpu/shaders/material/gpu_shader_material_vertex_color.glsl @@ -0,0 +1,5 @@ +void node_vertex_color(vec4 vertexColor, out vec4 outColor, out float outAlpha) +{ + outColor = vertexColor; + outAlpha = vertexColor.a; +} |