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
path: root/source
diff options
context:
space:
mode:
authorClément Fukhaut <turjuque@gmail.com>2016-06-05 20:45:50 +0300
committerClément Fukhaut <turjuque@gmail.com>2016-06-05 20:45:50 +0300
commit554952d1141018430d3e37b0d0c121110ce9834d (patch)
tree6f7a954a8c112b81e9b87b3736e52ef5bded665e /source
parentd85b6b86cfb6ae124ca92f13661ce4e412fc1e09 (diff)
Remove SSR distance
Fixed Vertex shader not compiling for world nodetree
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/intern/gpu_material.c7
-rw-r--r--source/blender/gpu/intern/gpu_pbr.c1
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material_bsdf_glossy.glsl11
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material_utils.glsl8
-rw-r--r--source/blender/gpu/shaders/gpu_shader_vertex_world.glsl62
-rw-r--r--source/blender/makesdna/DNA_gpu_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_space.c5
7 files changed, 70 insertions, 26 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 8ac4769a920..29e31676ab8 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -699,10 +699,9 @@ void GPU_material_bind_uniforms_pbr(GPUMaterial *material, GPUProbe *probe, GPUP
* w : thickness : pixel thickness */
float ssrparams[3];
ssrparams[0] = (float)pbr_settings->ssr->steps;
- ssrparams[1] = pbr_settings->ssr->distance_max / (float)pbr_settings->ssr->steps;
- ssrparams[2] = pbr_settings->ssr->attenuation;
- ssrparams[3] = pbr_settings->ssr->thickness;
- GPU_shader_uniform_vector(shader, material->ssrparamsloc, 4, 1, ssrparams);
+ ssrparams[1] = pbr_settings->ssr->attenuation;
+ ssrparams[2] = pbr_settings->ssr->thickness;
+ GPU_shader_uniform_vector(shader, material->ssrparamsloc, 3, 1, ssrparams);
}
if (pbr_settings->pbr_flag & GPU_PBR_FLAG_SSAO) {
diff --git a/source/blender/gpu/intern/gpu_pbr.c b/source/blender/gpu/intern/gpu_pbr.c
index 8e79e4d6b46..30c25a4bb38 100644
--- a/source/blender/gpu/intern/gpu_pbr.c
+++ b/source/blender/gpu/intern/gpu_pbr.c
@@ -284,7 +284,6 @@ void GPU_pbr_free(GPUPBR *pbr)
static void gpu_pbr_init_ssr_settings(GPUSSRSettings *ssr_settings)
{
- ssr_settings->distance_max = 10.0f;
ssr_settings->attenuation = 6.0f;
ssr_settings->thickness = 0.2f;
ssr_settings->steps = 32;
diff --git a/source/blender/gpu/shaders/gpu_shader_material_bsdf_glossy.glsl b/source/blender/gpu/shaders/gpu_shader_material_bsdf_glossy.glsl
index c1c10c38d5c..7a941d2387c 100644
--- a/source/blender/gpu/shaders/gpu_shader_material_bsdf_glossy.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material_bsdf_glossy.glsl
@@ -559,24 +559,15 @@ void env_sampling_glossy_sharp(
#ifdef USE_SSR
/* SSR */
- //ivec2 c = ivec2(gl_FragCoord.xy);
- //float jitter = float((c.x+c.y)&1) * 0.5; // Number between 0 and 1 for how far to bump the ray in stride units to conceal banding artifacts
- //setup_noise(gl_FragCoord.xy); /* Noise to dither the samples */
- //float jitter = jitternoise.y * 1.0;
- float jitter = 0.0;
-
vec2 hitpixel; vec3 hitco; float hitstep;
- bool hit = raycast(viewpos, vL, jitter, hitstep, hitpixel, hitco);
+ bool hit = raycast(viewpos, vL, hitstep, hitpixel, hitco);
float contrib = ssr_contribution(viewpos, hitstep, hit, hitco);
- //vec4 sample_ssr = texture2DLod(unfscenebuf, hitco.xy, 0);
vec4 sample_ssr = texelFetch(unfscenebuf, ivec2(hitpixel.xy), 0);
srgb_to_linearrgb(sample_ssr, sample_ssr);
result = mix(sample_probe.rgb, sample_ssr.rgb, contrib);
- //result = mix(vec3(0.0), sample_ssr.rgb, contrib);
- //result = vec3(texelFetch(unfdepthbuf, ivec2(gl_FragCoord.xy) / int(pow(2,unfssrparam.x-1)), int(unfssrparam.x-1)).r);
#else
result = sample_probe.rgb;
#endif
diff --git a/source/blender/gpu/shaders/gpu_shader_material_utils.glsl b/source/blender/gpu/shaders/gpu_shader_material_utils.glsl
index 3f56d6549d6..f5c8b6f2e08 100644
--- a/source/blender/gpu/shaders/gpu_shader_material_utils.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material_utils.glsl
@@ -40,7 +40,7 @@ uniform vec3 unfsh7;
uniform vec3 unfsh8;
uniform vec3 unfprobepos;
uniform vec3 unfplanarvec;
-uniform vec4 unfssrparam;
+uniform vec3 unfssrparam;
uniform vec4 unfssaoparam;
uniform vec4 unfclip;
uniform mat4 unfprobecorrectionmat;
@@ -853,7 +853,7 @@ void swapIfBigger(inout float a, inout float b)
}
/* 2D raycast : still have some bug that needs to be sorted out before being usable */
-bool raycast(vec3 ray_origin, vec3 ray_dir, float jitter, out float hitstep, out vec2 hitpixel, out vec3 hitco)
+bool raycast(vec3 ray_origin, vec3 ray_dir, out float hitstep, out vec2 hitpixel, out vec3 hitco)
{
/* ssr_parameters */
float nearz = -unfclip.x; /* Near plane distance (Negative number) */
@@ -956,7 +956,7 @@ bool raycast(vec3 ray_origin, vec3 ray_dir, float jitter, out float hitstep, out
#ifdef USE_BACKFACE
float backface = backface_depth(ivec2(hitpixel), 0);
#else
- float backface = frontface - unfssrparam.w;
+ float backface = frontface - unfssrparam.z;
#endif
hit = (zmin > backface);
}
@@ -1031,7 +1031,7 @@ float ssr_contribution(vec3 ray_origin, float hitstep, bool hit, inout vec3 hitc
{
/* ssr_parameters */
float maxstep = unfssrparam.x; /* Maximum number of iteration when raymarching */
- float attenuation = unfssrparam.z; /* Attenuation factor for screen edges and ray step fading */
+ float attenuation = unfssrparam.y; /* Attenuation factor for screen edges and ray step fading */
/* ray step fade */
float stepfade = saturate((1.0 - hitstep / maxstep) * attenuation);
diff --git a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl b/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl
index 9dbcaeb7a32..fe02a883765 100644
--- a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl
@@ -2,6 +2,68 @@
varying vec3 varposition;
varying vec3 varnormal;
+float srgb_to_linearrgb(float c)
+{
+ if (c < 0.04045)
+ return (c < 0.0) ? 0.0 : c * (1.0 / 12.92);
+ else
+ return pow((c + 0.055) * (1.0 / 1.055), 2.4);
+}
+
+void srgb_to_linearrgb(vec3 col_from, out vec3 col_to)
+{
+ col_to.r = srgb_to_linearrgb(col_from.r);
+ col_to.g = srgb_to_linearrgb(col_from.g);
+ col_to.b = srgb_to_linearrgb(col_from.b);
+}
+
+void srgb_to_linearrgb(vec4 col_from, out vec4 col_to)
+{
+ col_to.r = srgb_to_linearrgb(col_from.r);
+ col_to.g = srgb_to_linearrgb(col_from.g);
+ col_to.b = srgb_to_linearrgb(col_from.b);
+ col_to.a = col_from.a;
+}
+
+bool is_srgb(int info)
+{
+#ifdef USE_NEW_SHADING
+ return (info == 1)? true: false;
+#else
+ return false;
+#endif
+}
+
+void set_var_from_attr(float attr, int info, out float var)
+{
+ var = attr;
+}
+
+void set_var_from_attr(vec2 attr, int info, out vec2 var)
+{
+ var = attr;
+}
+
+void set_var_from_attr(vec3 attr, int info, out vec3 var)
+{
+ if (is_srgb(info)) {
+ srgb_to_linearrgb(attr, var);
+ }
+ else {
+ var = attr;
+ }
+}
+
+void set_var_from_attr(vec4 attr, int info, out vec4 var)
+{
+ if (is_srgb(info)) {
+ srgb_to_linearrgb(attr, var);
+ }
+ else {
+ var = attr;
+ }
+}
+
void main()
{
/* position does not need to be transformed, we already have it */
diff --git a/source/blender/makesdna/DNA_gpu_types.h b/source/blender/makesdna/DNA_gpu_types.h
index 5b327b78b40..1e82fdcd10d 100644
--- a/source/blender/makesdna/DNA_gpu_types.h
+++ b/source/blender/makesdna/DNA_gpu_types.h
@@ -73,10 +73,8 @@ typedef enum eGPUFXFlags {
/* Screen space reflection settings */
typedef struct GPUSSRSettings {
- float distance_max;
float attenuation;
float thickness;
- float pad2;
int steps;
int pad;
} GPUSSRSettings;
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index eea5e0384f3..ed5a8c08473 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2354,11 +2354,6 @@ static void rna_def_gpu_pbr_ssr(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "GPU SSR", "Settings for GPU based screen space reflections");
RNA_def_struct_ui_icon(srna, ICON_MATERIAL);
- prop = RNA_def_property(srna, "distance_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Distance", "Max distance traveled by the reflected ray");
- RNA_def_property_range(prop, 0.00001f, 100000.0f);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
prop = RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Attenuation", "Attenuation for distance and screen border fade");
RNA_def_property_range(prop, 1.0f, 20.0f);