From efe52f4bf9d7b5d15fae0590b5605c44cc7b4bcc Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Sun, 9 Sep 2012 13:37:53 +0300 Subject: [PATCH] ubershader: fix reflection under Rembrandt model-combined & model-combined-deferred effects: improve Rembrandt behaviour, and provide better effects for transparent surfaces under Rembrandt. This change breaks current effects using normalmaps when inheriting from model-combined-deferred under Rembrandt. Aircraft developers please change the technique numbers in the "normalmap include" part of your effects file from to (again, only if inheriting from model-combined-deferred, and using normalmaps) Effects inheriting from model-combined do not neeed any adaptation. Sorry for the nuisance caused by this change. Signed-off-by: Emilian Huminiuc --- .../README.model-combined.eff | 5 + .../model-combined-bump.eff | 4 +- Effects/model-combined-deferred.eff | 603 +++++++++++++++++- Effects/model-combined.eff | 11 +- Shaders/ubershader-gbuffer.frag | 2 +- 5 files changed, 592 insertions(+), 33 deletions(-) diff --git a/Docs/model-combined.eff/README.model-combined.eff b/Docs/model-combined.eff/README.model-combined.eff index 01444ee9f..414d2a8d8 100644 --- a/Docs/model-combined.eff/README.model-combined.eff +++ b/Docs/model-combined.eff/README.model-combined.eff @@ -8,7 +8,12 @@ The model-combined effect uses the ubershader to provide any or all of diffuse, To use this on your aircraft model, you are advised to create a local effect that has the following lines: +1. for automatic Rembrandt support on opaque objects use this: my-aircraft-effect + Effects/model-combined-deferred + +2. for automatic Rembrandt support on transparent objects (glass) use this: + my-aircraft-glass-effect Effects/model-combined The only modeller-adjustable settings are those found in the parameters section and listed here. There are other entries in the parameters section, but those are for internal use only, please don't mess with them. diff --git a/Docs/model-combined.eff/model-combined-bump.eff b/Docs/model-combined.eff/model-combined-bump.eff index af989740e..7c99249eb 100644 --- a/Docs/model-combined.eff/model-combined-bump.eff +++ b/Docs/model-combined.eff/model-combined-bump.eff @@ -7,7 +7,7 @@ WARNING: do not remove the Normalmap include at the end--> - Effects/model-combined + Effects/model-combined-deferred 1 @@ -77,7 +77,7 @@ 7 - + diff --git a/Effects/model-combined-deferred.eff b/Effects/model-combined-deferred.eff index 43fa258a7..d098cb9ba 100644 --- a/Effects/model-combined-deferred.eff +++ b/Effects/model-combined-deferred.eff @@ -9,9 +9,10 @@ the objects that use it, and replaces it with the default shader. Effects/model-combined-deferred Effects/model-combined - + + /sim/rendering/shaders/model /sim/rendering/rembrandt/enabled @@ -27,33 +28,587 @@ the objects that use it, and replaces it with the default shader. - - false - - - material/ambient - - - material/diffuse - - - material/specular - - - material/emissive - - - material/shininess - - ambient-and-diffuse - - back + + true + + + material/active + + + material/ambient + + + material/diffuse + + + material/specular + + + material/emissive + + + material/shininess + + + material/color-mode + + + + + blend/active + + + blend/source + + + blend/destination + + + + shade-model + + + cull-face + + + rendering-hint + + + transparent + + + transparent + + + + render-bin/bin-number + + + render-bin/bin-name + + + + + 0 + + texture[0]/image + + + texture[0]/filter + + + texture[0]/wrap-s + + + texture[0]/wrap-t + + + texture[0]/internal-format + + + + + 1 + noise + + + + 2 + + texture[2]/image + + + texture[2]/filter + + + texture[2]/wrap-s + + + texture[2]/wrap-t + + + texture[2]/internal-format + + + + + 3 + + texture[3]/image + + + texture[3]/filter + + + texture[3]/wrap-s + + + texture[3]/wrap-t + + + texture[3]/internal-format + + + + + 4 + + texture[4]/image + + + texture[4]/filter + + + texture[4]/wrap-s + + + texture[4]/wrap-t + + + texture[4]/internal-format + + + + + 5 + + texture[5]/type + + + + + + + texture[5]/images + + + + + + 6 + + texture[6]/image + + + texture[6]/filter + + + texture[6]/wrap-s + + + texture[6]/wrap-t + + + texture[6]/internal-format + + + + + 7 + + texture[7]/image + + + texture[7]/filter + + + texture[7]/wrap-s + + + texture[7]/wrap-t + + + texture[7]/internal-format + + + + + + vertex-program-two-side + + Shaders/ubershader.vert Shaders/ubershader-gbuffer.frag Shaders/gbuffer-functions.frag Shaders/gbuffer-encode.frag - - + + + BaseTex + sampler-2d + 0 + + + + ReflNoiseTex + sampler-3d + 1 + + + + NormalTex + sampler-2d + 2 + + + + LightMapTex + sampler-2d + 3 + + + + ReflMapTex + sampler-2d + 4 + + + + Environment + sampler-cube + 5 + + + + ReflFresnelTex + sampler-2d + 6 + + + + ReflRainbowTex + sampler-2d + 7 + + + + + + nmap_enabled + int + + normalmap-enabled + + + + + + nmap_dds + int + + normalmap-dds + + + + + nmap_tile + int + + normalmap-tiling + + + + + + + lightmap_enabled + int + + lightmap-enabled + + + + + lightmap_multi + int + + lightmap-multi + + + + + lightmap_r_factor + float + + lightmap-factor[0] + + + + + lightmap_r_color + float-vec3 + + lightmap-color[0] + + + + + lightmap_g_factor + float + + lightmap-factor[1] + + + + + lightmap_g_color + float-vec3 + + lightmap-color[1] + + + + + lightmap_b_factor + float + + lightmap-factor[2] + + + + + lightmap_b_color + float-vec3 + + lightmap-color[2] + + + + + lightmap_a_factor + float + + lightmap-factor[3] + + + + + lightmap_a_color + float-vec3 + + lightmap-color[3] + + + + + + refl_enabled + int + + reflection-enabled + + + + + refl_correction + float + + reflection-correction + + + + + + refl_map + int + + reflect-map-enabled + + + + + refl_dynamic + int + + reflection-dynamic + + + + + + refl_rainbow + float + + reflection-rainbow + + + + + + refl_fresnel + float + + reflection-fresnel + + + + + + refl_noise + float + + reflection-noise + + + + + + dirt_enabled + int + + dirt-enabled + + + + + dirt_multi + int + + dirt-multi + + + + + dirt_r_color + float-vec3 + + dirt-color[0] + + + + + dirt_r_factor + float + + dirt-factor[0] + + + + + dirt_g_color + float-vec3 + + dirt-color[1] + + + + + dirt_g_factor + float + + dirt-factor[1] + + + + + dirt_b_color + float-vec3 + + dirt-color[2] + + + + + dirt_b_factor + float + + dirt-factor[2] + + + + + + amb_correction + float + + ambient-correction + + + + + shader_qual + int + + shader-quality + + + + + hdg + float + + model-hdg + + + + + pitch + float + + model-pitch + + + + + roll + float + + model-roll + + + + + + visibility + float + + visibility + + + + avisibility + float + + avisibility + + + + hazeLayerAltitude + float + + lthickness + + + + scattering + float + + scattering + + + + terminator + float + + terminator + + + + fogType + int + + fogtype + + + + + rembrandt_enabled + int + + rembrandt + + + + \ No newline at end of file diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff index 339e33e7c..5d82d862a 100644 --- a/Effects/model-combined.eff +++ b/Effects/model-combined.eff @@ -173,6 +173,9 @@ please see Docs/README.model-combined.eff for documentation true + + false + material/active @@ -223,12 +226,8 @@ please see Docs/README.model-combined.eff for documentation transparent - - render-bin/bin-number - - - render-bin/bin-name - + 111 + DepthSortedBin diff --git a/Shaders/ubershader-gbuffer.frag b/Shaders/ubershader-gbuffer.frag index e1db2e0d8..f8566e2eb 100644 --- a/Shaders/ubershader-gbuffer.frag +++ b/Shaders/ubershader-gbuffer.frag @@ -90,7 +90,7 @@ void main (void) N = normalize(VNormal); } ///END bump - vec4 reflection = textureCube(Environment, reflVec * N); + vec4 reflection = textureCube(Environment, reflVec * dot(N,VNormal)); vec3 viewVec = normalize(vViewVec); float v = abs(dot(viewVec, normalize(VNormal)));// Map a rainbowish color vec4 fresnel = texture2D(ReflFresnelTex, vec2(v, 0.0));