diff options
| author | Graham Linden <graham@lindenlab.com> | 2018-11-14 19:23:16 -0800 | 
|---|---|---|
| committer | Graham Linden <graham@lindenlab.com> | 2018-11-14 19:23:16 -0800 | 
| commit | c4630a4b15c6297ae669a2030b8fbc4a1490cee4 (patch) | |
| tree | 3e4c5dc94983b3ffa96f77958497e18859660335 /indra/newview/app_settings/shaders/class1 | |
| parent | aa0115053aaa28de1c472410931c57b3e43b72a7 (diff) | |
Work around broken deps on atmospheric vars in the frag-based deferred lighting pipe.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
3 files changed, 93 insertions, 97 deletions
| diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index b810bb4fd1..43f0034874 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -86,6 +86,8 @@ vec4 getPosition(vec2 pos_screen)  	return pos;  } +#if USE_DEFERRED_SHADER_API +  vec4 getPositionWithDepth(vec2 pos_screen, float depth)  {  	vec2 sc = getScreenCoordinate(pos_screen); @@ -285,3 +287,5 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen)  	return min(ret, 1.0);  } +#endif + diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 18259ed9ed..5813dd84ee 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -41,7 +41,7 @@ uniform sampler2DRect normalMap;  uniform sampler2DRect lightMap;  uniform sampler2DRect depthMap;  uniform samplerCube environmentMap; -uniform sampler2D	  lightFunc; +uniform sampler2D     lightFunc;  uniform float blur_size;  uniform float blur_fidelity; @@ -78,114 +78,106 @@ vec3 fullbrightScaleSoftClip(vec3 l);  vec4 getPosition_d(vec2 pos_screen, float depth)  { -	vec2 sc = pos_screen.xy*2.0; -	sc /= screen_res; -	sc -= vec2(1.0,1.0); -	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); -	vec4 pos = inv_proj * ndc; -	pos /= pos.w; -	pos.w = 1.0; -	return pos; +    vec2 sc = pos_screen.xy*2.0; +    sc /= screen_res; +    sc -= vec2(1.0,1.0); +    vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); +    vec4 pos = inv_proj * ndc; +    pos /= pos.w; +    pos.w = 1.0; +    return pos;  }  vec4 getPosition(vec2 pos_screen)  { //get position in screen space (world units) given window coordinate and depth map -	float depth = texture2DRect(depthMap, pos_screen.xy).a; -	return getPosition_d(pos_screen, depth); +    float depth = texture2DRect(depthMap, pos_screen.xy).a; +    return getPosition_d(pos_screen, depth);  }  void main()   { -	vec2 tc = vary_fragcoord.xy; -	float depth = texture2DRect(depthMap, tc.xy).r; -	vec3 pos = getPosition_d(tc, depth).xyz; -	vec4 norm = texture2DRect(normalMap, tc); -	float envIntensity = norm.z; -	norm.xyz = decode_normal(norm.xy); // unpack norm -		 -	float da = dot(norm.xyz, sun_dir.xyz); - -	float final_da = max(0.0,da); -              final_da = min(final_da, 1.0f); - -// why an ad hoc gamma boost here? srgb_to_linear instead? -	      final_da = pow(final_da, 1.0/1.3); - -	vec4 diffuse = texture2DRect(diffuseRect, tc); - -	//convert to gamma space -	diffuse.rgb = linear_to_srgb(diffuse.rgb); - -	vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); -	vec3 col; -	float bloom = 0.0; -	{ +    vec2 tc = vary_fragcoord.xy; +    float depth = texture2DRect(depthMap, tc.xy).r; +    vec3 pos = getPosition_d(tc, depth).xyz; +    vec4 norm = texture2DRect(normalMap, tc); +    float envIntensity = norm.z; +    norm.xyz = decode_normal(norm.xy); // unpack norm +         +    float da = dot(norm.xyz, sun_dir.xyz); + +    float final_da = clamp(da, 0.0, 1.0); +          final_da = pow(final_da, 1.0/1.3); + +    vec4 diffuse = texture2DRect(diffuseRect, tc); + +    //convert to gamma space +    diffuse.rgb = linear_to_srgb(diffuse.rgb); + +    vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); +    vec3 col; +    float bloom = 0.0; +    {          vec3 sunlit;          vec3 amblit;          vec3 additive;          vec3 atten; -		calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); -	 -		float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); -		ambient *= 0.5; -		ambient *= ambient; -		ambient = (1.0 - ambient); - -		col = amblit; +        calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); +     +        float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); +        ambient *= 0.5; +        ambient *= ambient; +        ambient = (1.0 - ambient); + +        col = amblit;          col *= ambient; -		col += (final_da * sunlit);         -		col *= diffuse.rgb; -	 -		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - -		if (spec.a > 0.0) // specular reflection -		{ -			// the old infinite-sky shiny reflection -			// -			 -			float sa = dot(refnormpersp, sun_dir.xyz); -			vec3 dumbshiny = sunlit*(texture2D(lightFunc, vec2(sa, spec.a)).r); -			 -			// add the two types of shiny together -			vec3 spec_contrib = dumbshiny * spec.rgb; -			bloom = dot(spec_contrib, spec_contrib) / 6; -			col += spec_contrib; -		} -		 -		 -		col = mix(col.rgb, diffuse.rgb, diffuse.a); -				 -		if (envIntensity > 0.0) -		{ //add environmentmap -			vec3 env_vec = env_mat * refnormpersp; -			 -			 -			vec3 refcol = textureCube(environmentMap, env_vec).rgb; - -			col = mix(col.rgb, refcol,  -				envIntensity);   -		} -				 -		if (norm.w < 0.5) -		{ -			col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); -			col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); -		} - -		#ifdef WATER_FOG -			vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom)); -			col = fogged.rgb; -			bloom = fogged.a; -		#endif - -		col = srgb_to_linear(col); - -		//col = vec3(1,0,1); -		//col.g = envIntensity; -	} - -	frag_color.rgb = col.rgb; -	frag_color.a = bloom; +        col += (final_da * sunlit);         +        col *= diffuse.rgb; +     +        vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + +        if (spec.a > 0.0) // specular reflection +        { +            // the old infinite-sky shiny reflection +            // +             +            float sa = dot(refnormpersp, sun_dir.xyz); +            vec3 dumbshiny = sunlit*(texture2D(lightFunc, vec2(sa, spec.a)).r); +             +            // add the two types of shiny together +            vec3 spec_contrib = dumbshiny * spec.rgb; +            bloom = dot(spec_contrib, spec_contrib) / 6; +            col += spec_contrib; +        } +         +        col = mix(col.rgb, diffuse.rgb, diffuse.a); +                 +        if (envIntensity > 0.0) +        { //add environmentmap +            vec3 env_vec = env_mat * refnormpersp; +            vec3 refcol = textureCube(environmentMap, env_vec).rgb; +            col = mix(col.rgb, refcol, envIntensity);   +        } +                 +        if (norm.w < 0.5) +        { +            col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); +            col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); +        } + +        #ifdef WATER_FOG +            vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom)); +            col = fogged.rgb; +            bloom = fogged.a; +        #endif + +        col = srgb_to_linear(col); + +        //col = vec3(1,0,1); +        //col.g = envIntensity; +    } + +    frag_color.rgb = col.rgb; +    frag_color.a = bloom;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl index b59fcbe017..e992776cb4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl @@ -1,5 +1,5 @@  /**  - * @file softenLightF.glsl + * @file softenLightV.glsl   *   * $LicenseInfo:firstyear=2007&license=viewerlgpl$   * Second Life Viewer Source Code | 
