GLSL: specular transparency support for Blender internal materials
Reviewed By: brecht Differential Revision: https://developer.blender.org/D781
This commit is contained in:
parent
aac2db33df
commit
8c712eaa29
Notes:
blender-bot
2023-02-14 09:50:40 +01:00
Referenced by issue #42555, install_deps.sh gives slight misinformation [patch attached]
|
@ -159,6 +159,7 @@ typedef struct GPUShadeInput {
|
|||
|
||||
GPUNodeLink *rgb, *specrgb, *vn, *view, *vcol, *ref;
|
||||
GPUNodeLink *alpha, *refl, *spec, *emit, *har, *amb;
|
||||
GPUNodeLink *spectra;
|
||||
} GPUShadeInput;
|
||||
|
||||
typedef struct GPUShadeResult {
|
||||
|
|
|
@ -1426,6 +1426,7 @@ void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
|
|||
GPU_link(mat, "set_value", GPU_uniform(&ma->emit), &shi->emit);
|
||||
GPU_link(mat, "set_value", GPU_uniform(&hard), &shi->har);
|
||||
GPU_link(mat, "set_value", GPU_uniform(&ma->amb), &shi->amb);
|
||||
GPU_link(mat, "set_value", GPU_uniform(&ma->spectra), &shi->spectra);
|
||||
GPU_link(mat, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view);
|
||||
GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol);
|
||||
if (GPU_material_do_color_management(mat))
|
||||
|
@ -1497,6 +1498,12 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
|
|||
}
|
||||
}
|
||||
|
||||
if (ma->mode & MA_TRANSP && (ma->mode & (MA_ZTRANSP|MA_RAYTRANSP))) {
|
||||
if (GPU_link_changed(shi->spectra) || ma->spectra != 0.0f)
|
||||
GPU_link(mat, "alpha_spec_correction", shr->spec, shi->spectra,
|
||||
shi->alpha, &shr->alpha);
|
||||
}
|
||||
|
||||
if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
|
||||
if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec);
|
||||
|
||||
|
|
|
@ -1935,6 +1935,17 @@ void shade_add_spec(float t, vec3 lampcol, vec3 speccol, out vec3 outcol)
|
|||
outcol = t*lampcol*speccol;
|
||||
}
|
||||
|
||||
void alpha_spec_correction(vec3 spec, float spectra, float alpha, out float outalpha)
|
||||
{
|
||||
if (spectra > 0.0) {
|
||||
float t = clamp(max(max(spec.r, spec.g), spec.b) * spectra, 0.0, 1.0);
|
||||
outalpha = (1.0 - t) * alpha + t;
|
||||
}
|
||||
else {
|
||||
outalpha = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void shade_add(vec4 col1, vec4 col2, out vec4 outcol)
|
||||
{
|
||||
outcol = col1 + col2;
|
||||
|
|
|
@ -267,6 +267,8 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
|
|||
shi.amb = gpu_get_input_link(&in[MAT_IN_AMB]);
|
||||
if (hasinput[MAT_IN_EMIT])
|
||||
shi.emit = gpu_get_input_link(&in[MAT_IN_EMIT]);
|
||||
if (hasinput[MAT_IN_SPECTRA])
|
||||
shi.spectra = gpu_get_input_link(&in[MAT_IN_SPECTRA]);
|
||||
if (hasinput[MAT_IN_ALPHA])
|
||||
shi.alpha = gpu_get_input_link(&in[MAT_IN_ALPHA]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue