From efe52f4bf9d7b5d15fae0590b5605c44cc7b4bcc Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Sun, 9 Sep 2012 13:37:53 +0300 Subject: [PATCH 1/5] 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)); From 835ba95ddb1e9cce39e466904e08bbe2e65ec4f2 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Sun, 9 Sep 2012 14:19:18 +0300 Subject: [PATCH 2/5] adapt effect template to previous changes Signed-off-by: Emilian Huminiuc --- .../model-combined-transparent.eff | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/Docs/model-combined.eff/model-combined-transparent.eff b/Docs/model-combined.eff/model-combined-transparent.eff index 2ac5b553d..cc17ceca7 100644 --- a/Docs/model-combined.eff/model-combined-transparent.eff +++ b/Docs/model-combined.eff/model-combined-transparent.eff @@ -83,5 +83,49 @@ WARNING: do not remove the Transparency include at the end--> ### END TRANSPARENCY INCLUDE ### ############################# --> - + + + + + + 6 + 7 + + + + + + + tangent + 6 + + + binormal + 7 + + + + + + + + + + tangent + 6 + + + binormal + 7 + + + + + \ No newline at end of file From 023c6bc97a31c096cd6a27a90191f3ef9d446b55 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Sun, 9 Sep 2012 14:34:26 +0300 Subject: [PATCH 3/5] c172p: adapt local effects to the change in model-combined and model-combined-deferred Signed-off-by: Emilian Huminiuc --- Aircraft/c172p/Models/Effects/bumpspec.eff | 2 +- Aircraft/c172p/Models/Effects/glass.eff | 103 +-------------------- 2 files changed, 2 insertions(+), 103 deletions(-) diff --git a/Aircraft/c172p/Models/Effects/bumpspec.eff b/Aircraft/c172p/Models/Effects/bumpspec.eff index f3200f59b..613e4aeac 100644 --- a/Aircraft/c172p/Models/Effects/bumpspec.eff +++ b/Aircraft/c172p/Models/Effects/bumpspec.eff @@ -43,7 +43,7 @@ 7 - + diff --git a/Aircraft/c172p/Models/Effects/glass.eff b/Aircraft/c172p/Models/Effects/glass.eff index 034932b3a..2e161d6ef 100644 --- a/Aircraft/c172p/Models/Effects/glass.eff +++ b/Aircraft/c172p/Models/Effects/glass.eff @@ -27,109 +27,8 @@ transparent true - 111 + 10 DepthSortedBin - - - - /sim/rendering/rembrandt/enabled - - - 2.0 - - - - GL_ARB_shader_objects - GL_ARB_shading_language_100 - GL_ARB_vertex_shader - GL_ARB_fragment_shader - - - GL_EXT_gpu_shader4 - GL_ARB_texture_rg - - - - true - - false - - - - 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 - - - 111 - DepthSortedBin - - - - texture[0]/active - - 0 - - texture[0]/image - - - texture[0]/filter - - - texture[0]/wrap-s - - - texture[0]/wrap-t - - - - modulate - - - - - From cebf6f4d9c92fb05256b67f75480227f52fd00a4 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Sun, 9 Sep 2012 14:59:17 +0300 Subject: [PATCH 4/5] buildings.eff: adapt technique numbering to previous effect changes Signed-off-by: Emilian Huminiuc --- Effects/building.eff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Effects/building.eff b/Effects/building.eff index 9edc822b2..4025a9913 100644 --- a/Effects/building.eff +++ b/Effects/building.eff @@ -252,7 +252,7 @@ - + 4 From 2c058f9c1f189437d5af7a1a58ac2bdb454c4d49 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Sun, 9 Sep 2012 22:23:35 +0300 Subject: [PATCH 5/5] New effect: Effects/model-combined-transparent Switch c172p and concorde glass effects to the new effect. Docs/model-combined.eff/: Updated transparent effect template. From now on Effects/model-combined should not be inherited from directly. Use either Effects/model-combined-deferred or Effects/model-combined-transparent Signed-off-by: Emilian Huminiuc --- Aircraft/c172p/Models/Effects/glass.eff | 2 +- .../README.model-combined.eff | 2 +- .../model-combined-transparent.eff | 4 +- Effects/model-combined-transparent.eff | 113 ++++++++++++++++++ 4 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 Effects/model-combined-transparent.eff diff --git a/Aircraft/c172p/Models/Effects/glass.eff b/Aircraft/c172p/Models/Effects/glass.eff index 2e161d6ef..cbbff718d 100644 --- a/Aircraft/c172p/Models/Effects/glass.eff +++ b/Aircraft/c172p/Models/Effects/glass.eff @@ -1,7 +1,7 @@ Aircraft/c172p/Models/Effects/glass - Effects/model-combined + Effects/model-combined-transparent 0 0 diff --git a/Docs/model-combined.eff/README.model-combined.eff b/Docs/model-combined.eff/README.model-combined.eff index 414d2a8d8..8156eeacf 100644 --- a/Docs/model-combined.eff/README.model-combined.eff +++ b/Docs/model-combined.eff/README.model-combined.eff @@ -14,7 +14,7 @@ To use this on your aircraft model, you are advised to create a local effect tha 2. for automatic Rembrandt support on transparent objects (glass) use this: my-aircraft-glass-effect - Effects/model-combined + Effects/model-combined-transparent 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-transparent.eff b/Docs/model-combined.eff/model-combined-transparent.eff index cc17ceca7..71a807357 100644 --- a/Docs/model-combined.eff/model-combined-transparent.eff +++ b/Docs/model-combined.eff/model-combined-transparent.eff @@ -7,8 +7,8 @@ Remove unnedeed settings. WARNING: do not remove the Transparency include at the end--> - - Effects/model-combined + + Effects/model-combined-transparent 0 diff --git a/Effects/model-combined-transparent.eff b/Effects/model-combined-transparent.eff new file mode 100644 index 000000000..61fbb1b41 --- /dev/null +++ b/Effects/model-combined-transparent.eff @@ -0,0 +1,113 @@ + + + + Effects/model-combined-transparent + Effects/model-combined + + + + + + /sim/rendering/shaders/model + 0 + + /sim/rendering/rembrandt/enabled + + + 2.0 + + + + GL_ARB_shader_objects + GL_ARB_shading_language_100 + GL_ARB_vertex_shader + GL_ARB_fragment_shader + + + + + + true + + false + + + + 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 + + + 111 + DepthSortedBin + + + + texture[0]/active + + 0 + + texture[0]/image + + + texture[0]/filter + + + texture[0]/wrap-s + + + texture[0]/wrap-t + + + + modulate + + + + + + \ No newline at end of file