Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_material.c
| Show First 20 Lines • Show All 843 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| else { | else { | ||||
| GPU_link(mat, "shade_add_spec", t, lcol, shi->specrgb, &outcol); | GPU_link(mat, "shade_add_spec", t, lcol, shi->specrgb, &outcol); | ||||
| GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec); | GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| add_user_list(&mat->lamps, lamp); | add_user_list(&mat->lamps, lamp); | ||||
| add_user_list(&lamp->materials, shi->gpumat->ma); | add_user_list(&lamp->materials, shi->gpumat->ma); | ||||
brecht: You can optimize this so that the `alpha_spec_correction` function call is only generated when… | |||||
Not Done Inline ActionsThis code is not in the right place, now it will be executed for every lamp, but it should be only executed once afterwards, same as in shadeoutput.c. /* ambient color */
if (world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) {
if (GPU_link_changed(shi->amb) || ma->amb != 0.0f)
GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb),
GPU_uniform(&world->ambr), &shr->combined);
}
}
// >>> do it here <<<
if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec);brecht: This code is not in the right place, now it will be executed for every lamp, but it should be… | |||||
| } | } | ||||
| static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr) | static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr) | ||||
| { | { | ||||
| Base *base; | Base *base; | ||||
| Object *ob; | Object *ob; | ||||
| Scene *sce_iter; | Scene *sce_iter; | ||||
| GPULamp *lamp; | GPULamp *lamp; | ||||
| ▲ Show 20 Lines • Show All 559 Lines • ▼ Show 20 Lines | void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi) | ||||
| else | else | ||||
| GPU_link(mat, "set_value", GPU_uniform(&one), &shi->alpha); | GPU_link(mat, "set_value", GPU_uniform(&one), &shi->alpha); | ||||
| GPU_link(mat, "set_value", GPU_uniform(&ma->ref), &shi->refl); | GPU_link(mat, "set_value", GPU_uniform(&ma->ref), &shi->refl); | ||||
| GPU_link(mat, "set_value", GPU_uniform(&ma->spec), &shi->spec); | GPU_link(mat, "set_value", GPU_uniform(&ma->spec), &shi->spec); | ||||
| GPU_link(mat, "set_value", GPU_uniform(&ma->emit), &shi->emit); | 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(&hard), &shi->har); | ||||
| GPU_link(mat, "set_value", GPU_uniform(&ma->amb), &shi->amb); | 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, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view); | ||||
| GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol); | GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol); | ||||
| if (GPU_material_do_color_management(mat)) | if (GPU_material_do_color_management(mat)) | ||||
| GPU_link(mat, "srgb_to_linearrgb", shi->vcol, &shi->vcol); | GPU_link(mat, "srgb_to_linearrgb", shi->vcol, &shi->vcol); | ||||
| GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref); | GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref); | ||||
| } | } | ||||
| void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) | void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (world) { | ||||
| /* ambient color */ | /* ambient color */ | ||||
| if (world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) { | if (world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) { | ||||
| if (GPU_link_changed(shi->amb) || ma->amb != 0.0f) | if (GPU_link_changed(shi->amb) || ma->amb != 0.0f) | ||||
| GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb), | GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb), | ||||
| GPU_uniform(&world->ambr), &shr->combined); | GPU_uniform(&world->ambr), &shr->combined); | ||||
| } | } | ||||
| } | } | ||||
| 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_COL) ramp_diffuse_result(shi, &shr->combined); | ||||
| if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec); | if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec); | ||||
| if (GPU_link_changed(shi->spec) || ma->spec != 0.0f) | if (GPU_link_changed(shi->spec) || ma->spec != 0.0f) | ||||
| GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined); | GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined); | ||||
| } | } | ||||
| GPU_link(mat, "mtex_alpha_to_col", shr->combined, shr->alpha, &shr->combined); | GPU_link(mat, "mtex_alpha_to_col", shr->combined, shr->alpha, &shr->combined); | ||||
| ▲ Show 20 Lines • Show All 731 Lines • Show Last 20 Lines | |||||
You can optimize this so that the alpha_spec_correction function call is only generated when needed, like e.g. this code.
if (GPU_link_changed(shi->spec) || ma->spec != 0.0f) GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined);