SL-10566 part the first
Tie using deferred rendering in water reflection/distortion map generation to debug var again (claw back some performance lost to doing post-deferred in water map generation). Edit softenLightF for class1/class2 to make them comparable again.meow-7.2.2
parent
982b8cdef2
commit
6f820163ce
|
|
@ -76,7 +76,16 @@ vec3 linear_to_srgb(vec3 c);
|
|||
vec2 encode_normal (vec3 n);
|
||||
vec3 scaleSoftClipFrag(vec3 l);
|
||||
vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten);
|
||||
|
||||
#if defined(VERT_ATMOSPHERICS)
|
||||
vec3 getSunlitColor();
|
||||
vec3 getAmblitColor();
|
||||
vec3 getAdditiveColor();
|
||||
vec3 getAtmosAttenuation();
|
||||
void calcAtmospherics(vec3 inPositionEye, float ambFactor);
|
||||
#else
|
||||
void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive);
|
||||
#endif
|
||||
|
||||
float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
|
||||
|
||||
|
|
@ -174,7 +183,15 @@ void main()
|
|||
vec3 amblit;
|
||||
vec3 additive;
|
||||
vec3 atten;
|
||||
|
||||
#if VERT_ATMOSPHERICS
|
||||
sunlit = getSunlitColor();
|
||||
amblit = getAmblitColor();
|
||||
additive = getAdditiveColor();
|
||||
atten = getAtmosAttenuation();
|
||||
#else
|
||||
calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten);
|
||||
#endif
|
||||
|
||||
vec2 abnormal = encode_normal(norm.xyz);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,14 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
|
|||
vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
|
||||
vec3 scaleSoftClipFrag(vec3 l);
|
||||
|
||||
#if defined(VERT_ATMOSPHERICS)
|
||||
vec3 getSunlitColor();
|
||||
vec3 getAmblitColor();
|
||||
vec3 getAdditiveColor();
|
||||
vec3 getAtmosAttenuation();
|
||||
#else
|
||||
void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);
|
||||
#endif
|
||||
|
||||
vec3 srgb_to_linear(vec3 cs);
|
||||
vec3 linear_to_srgb(vec3 cs);
|
||||
|
|
@ -278,8 +285,15 @@ void main()
|
|||
vec3 additive;
|
||||
vec3 atten;
|
||||
|
||||
#if VERT_ATMOSPHERICS
|
||||
sunlit = getSunlitColor();
|
||||
amblit = getAmblitColor();
|
||||
additive = getAdditiveColor();
|
||||
atten = getAtmosAttenuation();
|
||||
#else
|
||||
calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten);
|
||||
|
||||
#endif
|
||||
|
||||
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
|
||||
|
||||
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ uniform mat3 ssao_effect_mat;
|
|||
|
||||
uniform vec3 sun_dir;
|
||||
uniform vec3 moon_dir;
|
||||
uniform int sun_up_factor;
|
||||
VARYING vec2 vary_fragcoord;
|
||||
|
||||
uniform mat4 inv_proj;
|
||||
|
|
@ -69,7 +70,16 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
|
|||
vec3 getNorm(vec2 pos_screen);
|
||||
vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
|
||||
vec3 fullbrightAtmosTransportFrag(vec3 l, vec3 additive, vec3 atten);
|
||||
|
||||
#if defined(VERT_ATMOSPHERICS)
|
||||
vec3 getPositionEye();
|
||||
vec3 getSunlitColor();
|
||||
vec3 getAmblitColor();
|
||||
vec3 getAdditiveColor();
|
||||
vec3 getAtmosAttenuation();
|
||||
#else
|
||||
void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);
|
||||
#endif
|
||||
|
||||
vec3 scaleSoftClip(vec3 l);
|
||||
vec3 fullbrightScaleSoftClip(vec3 l);
|
||||
|
|
@ -84,13 +94,14 @@ void main()
|
|||
vec4 norm = texture2DRect(normalMap, tc);
|
||||
float envIntensity = norm.z;
|
||||
norm.xyz = getNorm(tc);
|
||||
|
||||
float da_sun = dot(norm.xyz, normalize(sun_dir.xyz));
|
||||
float da_moon = dot(norm.xyz, normalize(moon_dir.xyz));
|
||||
float da = max(da_sun, da_moon);
|
||||
|
||||
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
|
||||
|
||||
float da = dot(normalize(norm.xyz), light_dir.xyz);
|
||||
da = clamp(da, 0.0, 1.0);
|
||||
|
||||
float final_da = clamp(da, 0.0, 1.0);
|
||||
final_da = pow(final_da, global_gamma + 0.3);
|
||||
float light_gamma = 1.0/1.3;
|
||||
da = pow(da, light_gamma);
|
||||
|
||||
vec4 diffuse = texture2DRect(diffuseRect, tc);
|
||||
|
||||
|
|
@ -102,25 +113,33 @@ void main()
|
|||
vec3 amblit;
|
||||
vec3 additive;
|
||||
vec3 atten;
|
||||
|
||||
#if defined(VERT_ATMOSPHERICS)
|
||||
sunlit = getSunlitColor();
|
||||
amblit = getAmblitColor();
|
||||
additive = getAdditiveColor();
|
||||
atten = getAtmosAttenuation();
|
||||
#else
|
||||
calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten);
|
||||
|
||||
float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0);
|
||||
#endif
|
||||
|
||||
float ambient = min(abs(da), 1.0);
|
||||
ambient *= 0.5;
|
||||
ambient *= ambient;
|
||||
ambient = (1.0 - ambient);
|
||||
ambient = 1.0 - ambient;
|
||||
|
||||
vec3 sun_contrib = da * sunlit;
|
||||
|
||||
col.rgb = amblit;
|
||||
col.rgb *= ambient;
|
||||
col.rgb += sun_contrib;
|
||||
col.rgb *= diffuse.rgb;
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -131,12 +150,12 @@ void main()
|
|||
}
|
||||
|
||||
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);
|
||||
col = mix(col.rgb, refcol, envIntensity);
|
||||
}
|
||||
|
||||
if (norm.w < 0.5)
|
||||
|
|
@ -155,4 +174,3 @@ void main()
|
|||
frag_color.rgb = col.rgb;
|
||||
frag_color.a = bloom;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,17 +101,16 @@ void main()
|
|||
da = clamp(da, 0.0, 1.0);
|
||||
|
||||
float light_gamma = 1.0/1.3;
|
||||
da = pow(da, light_gamma);
|
||||
da = pow(da, light_gamma);
|
||||
|
||||
vec4 diffuse = texture2DRect(diffuseRect, tc);
|
||||
|
||||
scol = max(scol_ambocc.r, diffuse.a);
|
||||
|
||||
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
|
||||
vec3 col;
|
||||
float bloom = 0.0;
|
||||
{
|
||||
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
|
||||
|
||||
float ambocc = scol_ambocc.g;
|
||||
|
||||
vec3 sunlit;
|
||||
|
|
@ -147,7 +146,7 @@ void main()
|
|||
col += spec_contrib;
|
||||
}
|
||||
|
||||
col = mix(col, diffuse.rgb, diffuse.a);
|
||||
col = mix(col.rgb, diffuse.rgb, diffuse.a);
|
||||
|
||||
if (envIntensity > 0.0)
|
||||
{ //add environmentmap
|
||||
|
|
@ -155,7 +154,7 @@ void main()
|
|||
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);
|
||||
|
|
@ -168,6 +167,7 @@ void main()
|
|||
bloom = fogged.a;
|
||||
#endif
|
||||
}
|
||||
frag_color.rgb = col;
|
||||
|
||||
frag_color.rgb = col.rgb;
|
||||
frag_color.a = bloom;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9413,6 +9413,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
|
|||
stop_glerror();
|
||||
LLPlane plane;
|
||||
|
||||
S32 detail = RenderReflectionDetail;
|
||||
|
||||
bool materials_in_water = LLPipeline::sRenderDeferred && gSavedSettings.getS32("RenderWaterMaterials");
|
||||
|
||||
F32 water_height = gAgent.getRegion()->getWaterHeight();
|
||||
F32 camera_height = camera_in.getOrigin().mV[2];
|
||||
F32 distance_to_water = (water_height < camera_height) ? (camera_height - water_height) : (water_height - camera_height);
|
||||
|
|
@ -9504,7 +9508,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
|
|||
stateSort(camera, sky_and_clouds);
|
||||
gPipeline.grabReferences(sky_and_clouds);
|
||||
|
||||
if (LLPipeline::sRenderDeferred)
|
||||
if (materials_in_water)
|
||||
{
|
||||
gPipeline.mWaterDeferredDepth.bindTarget();
|
||||
gPipeline.mWaterDeferredDepth.clear();
|
||||
|
|
@ -9532,7 +9536,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
|
|||
LLPipeline::RENDER_TYPE_CLOUDS,
|
||||
LLPipeline::END_RENDER_TYPES);
|
||||
|
||||
S32 detail = RenderReflectionDetail;
|
||||
if (detail > 0)
|
||||
{ //mask out selected geometry based on reflection detail
|
||||
if (detail < 4)
|
||||
|
|
@ -9564,11 +9567,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
|
|||
|
||||
gPipeline.grabReferences(reflected_objects);
|
||||
|
||||
if (LLPipeline::sRenderDeferred)
|
||||
if (materials_in_water)
|
||||
{
|
||||
renderGeomDeferred(camera);
|
||||
renderGeomPostDeferred(camera);
|
||||
|
||||
gPipeline.mWaterDeferredScreen.flush();
|
||||
gPipeline.mWaterDeferredDepth.flush();
|
||||
mWaterRef.copyContents(gPipeline.mWaterDeferredScreen, 0, 0, gPipeline.mWaterDeferredScreen.getWidth(), gPipeline.mWaterDeferredScreen.getHeight(),
|
||||
|
|
@ -9648,13 +9650,13 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
|
|||
mWaterDis.clear();
|
||||
gGL.setColorMask(true, false);
|
||||
|
||||
// ignore clip plane if we're underwater and viewing distortion map of objects above waterline
|
||||
if (camera_is_underwater)
|
||||
// ignore clip plane if we're underwater and viewing distortion map of objects above waterline
|
||||
if (camera_is_underwater && materials_in_water)
|
||||
{
|
||||
clip_plane.disable();
|
||||
}
|
||||
|
||||
if (LLPipeline::sRenderDeferred)
|
||||
if (materials_in_water)
|
||||
{
|
||||
mWaterDis.flush();
|
||||
gGL.setColorMask(true, true);
|
||||
|
|
@ -9665,7 +9667,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
|
|||
gPipeline.mWaterDeferredScreen.clear();
|
||||
gPipeline.grabReferences(refracted_objects);
|
||||
gGL.setColorMask(true, false);
|
||||
|
||||
renderGeomDeferred(camera);
|
||||
renderGeomPostDeferred(camera);
|
||||
}
|
||||
|
|
@ -9686,7 +9687,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
|
|||
}
|
||||
}
|
||||
|
||||
if (LLPipeline::sRenderDeferred)
|
||||
if (materials_in_water)
|
||||
{
|
||||
gPipeline.mWaterDeferredScreen.flush();
|
||||
gPipeline.mWaterDeferredDepth.flush();
|
||||
|
|
|
|||
Loading…
Reference in New Issue