Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-06-07 19:43:43 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-06-07 19:43:43 +0300
commit0859492c758eaa6b8f35e77b95778266ce0f24cb (patch)
tree46802509945c5b21c6353f2d47dba6a57b1aa142 /source/blender
parenta3773dcc4fa0ab5dd268382019f5614948a623b9 (diff)
Fix crash cause by SSS referencing Material Nodetree data.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/gpu/GPU_material.h2
-rw-r--r--source/blender/gpu/intern/gpu_material.c26
2 files changed, 15 insertions, 13 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index f780eda62fe..cddcb3a546e 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -238,7 +238,7 @@ GPUNodeLink *GPU_uniformbuffer_link_out(
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link);
GPUBuiltin GPU_get_material_builtins(GPUMaterial *material);
-void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short *falloff_type, float *sharpness);
+void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness);
struct GPUUniformBuffer *GPU_material_sss_profile_get(
GPUMaterial *material, int sample_ct, struct GPUTexture **tex_profile);
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 96c321f9107..0404425ac3f 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -127,10 +127,11 @@ struct GPUMaterial {
/* Eevee SSS */
GPUUniformBuffer *sss_profile; /* UBO containing SSS profile. */
GPUTexture *sss_tex_profile; /* Texture containing SSS profile. */
- float *sss_radii; /* UBO containing SSS profile. */
+ float sss_enabled;
+ float sss_radii[3];
int sss_samples;
- short int *sss_falloff;
- float *sss_sharpness;
+ short int sss_falloff;
+ float sss_sharpness;
bool sss_dirty;
};
@@ -328,7 +329,7 @@ static float eval_integral(float x0, float x1, short falloff_type, float sharpne
#undef INTEGRAL_RESOLUTION
static void compute_sss_kernel(
- GPUSssKernelData *kd, float *radii, int sample_ct, int falloff_type, float sharpness)
+ GPUSssKernelData *kd, float radii[3], int sample_ct, int falloff_type, float sharpness)
{
float rad[3];
/* Minimum radius */
@@ -483,12 +484,13 @@ static void compute_sss_translucence_kernel(
}
#undef INTEGRAL_RESOLUTION
-void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short *falloff_type, float *sharpness)
+void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness)
{
- material->sss_radii = radii;
- material->sss_falloff = falloff_type;
- material->sss_sharpness = sharpness;
+ copy_v3_v3(material->sss_radii, radii);
+ material->sss_falloff = (falloff_type) ? *falloff_type : 0.0;
+ material->sss_sharpness = (sharpness) ? *sharpness : 0.0;
material->sss_dirty = true;
+ material->sss_enabled = true;
/* Update / Create UBO */
if (material->sss_profile == NULL) {
@@ -498,25 +500,25 @@ void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short
struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_ct, GPUTexture **tex_profile)
{
- if (material->sss_radii == NULL)
+ if (!material->sss_enabled)
return NULL;
if (material->sss_dirty || (material->sss_samples != sample_ct)) {
GPUSssKernelData kd;
- float sharpness = (material->sss_sharpness != NULL) ? *material->sss_sharpness : 0.0f;
+ float sharpness = material->sss_sharpness;
/* XXX Black magic but it seems to fit. Maybe because we integrate -1..1 */
sharpness *= 0.5f;
- compute_sss_kernel(&kd, material->sss_radii, sample_ct, *material->sss_falloff, sharpness);
+ compute_sss_kernel(&kd, material->sss_radii, sample_ct, material->sss_falloff, sharpness);
/* Update / Create UBO */
GPU_uniformbuffer_update(material->sss_profile, &kd);
/* Update / Create Tex */
float *translucence_profile;
- compute_sss_translucence_kernel(&kd, 64, *material->sss_falloff, sharpness, &translucence_profile);
+ compute_sss_translucence_kernel(&kd, 64, material->sss_falloff, sharpness, &translucence_profile);
if (material->sss_tex_profile != NULL) {
GPU_texture_free(material->sss_tex_profile);