From 7f183e011712a7e7cc2a83f1d1684748bb2520c6 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Wed, 15 Jan 2014 23:26:26 +0100 Subject: [PATCH] Remove intermediate quality settings from the ubershader. Fix a texture. --- Aircraft/Generic/Effects/Gradients.png | Bin 1289 -> 1271 bytes Effects/model-combined-deferred.eff | 56 ++++++-------- Effects/model-combined-transparent.eff | 46 +++++------- Effects/model-combined.eff | 100 ++++++++++--------------- Shaders/building-ubershader.vert | 25 ++++--- Shaders/ubershader-gbuffer.frag | 8 +- Shaders/ubershader-lightfield.frag | 9 +-- Shaders/ubershader.frag | 9 +-- Shaders/ubershader.vert | 30 ++++---- gui/dialogs/shaders.xml | 4 +- 10 files changed, 128 insertions(+), 159 deletions(-) diff --git a/Aircraft/Generic/Effects/Gradients.png b/Aircraft/Generic/Effects/Gradients.png index 5406b14b2e26bb75d6d215bfa4c347e64ade927d..93eab52fc01a4f38e8109fbb21b452e934fac78b 100644 GIT binary patch delta 1219 zcmV;!1U&nR3ik<+7YYan0ssI2nKZWOks&dE3k?nlC4#NaN$jQln z35Ub4U%yUEOG`{lbT}MduQwPBc6D{hvfR_tqpIrK+L|oOEiEng?%f+69+9>2lamz{6;)MLH*em&ef##{;9yBf$*o(r`uh5Q{P@w|-w$AZe!joI z-|2J$*xcNdW%T5xuNY%rzI=J{;sxh?d3kwYVBpxXW0X=wQO3r`0)aqLQPHVWr?RrLGBPsK)6+d3 zPiAIjZf>s6=PNEQE-fvst*vcsZM}QPriTu{`~oKMNy*BsHSN{Lqm4EeQ|N|*|TTc+uLv7zD-I>`ug>2BoYBIJ3HIk z+pDVT$jFGt^u&Ye4#nwq-1 zyE{HUURYR|mX@Zf>g43)#fuj`9*@OhQ55C<`}YL}1*xg2gpie$m64H=GiT1YTrNQn z6h#>w9ldbjg4gRka^#4nX|gPbLLtB3pPikZoSaMu`T6tb$B!Qafj~ijL4n)tb~qdW zW@cuptE+>-px^J$$;olKTnPyYx~@-8PuJGgmX?-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V_X%gh(X9uV24^3aF~e@bECIsxm)6kE*IHEG#fTKaZwqEG#UbX&RcQF*-Vm zrfEc@Q8Y~>7K`!w_itjc7}02ySS(gVJRWC!e4KbZPCOnbkw}n8BuFNcMY_1SNHUo$ zkV>Tp1OlW|DU!(~x~`K-rC3~CMA!9#pVxFcjjrqe=+e>>>2w-@(FX?qV~Gt&CV5*n zu>p#ycA&)6yswz#_X@Lt$OmLIshGB6X>7AJ$T!?bi3Nv6H<{`H!}N_!Yj&;#R_&0n z!5T^Hyz^vn}^om5X~8^5&beW>52t zA}6h32qZ%w8zAREHUx?RiUBrb{d3za^HXA(r;VT3>N^T`Mqy;u=F>pNKr)fZAu#@# z texture[0]/image - - texture[0]/type - + + texture[0]/type + texture[0]/filter @@ -120,9 +120,9 @@ the objects that use it, and replaces it with the default shader. texture[2]/image - - texture[2]/type - + + texture[2]/type + texture[2]/filter @@ -142,9 +142,9 @@ the objects that use it, and replaces it with the default shader. texture[3]/image - - texture[3]/type - + + texture[3]/type + texture[3]/filter @@ -164,9 +164,9 @@ the objects that use it, and replaces it with the default shader. texture[4]/image - - texture[4]/type - + + texture[4]/type + texture[4]/filter @@ -201,9 +201,9 @@ the objects that use it, and replaces it with the default shader. texture[6]/image - - texture[6]/type - + + texture[6]/type + texture[6]/filter @@ -218,7 +218,7 @@ the objects that use it, and replaces it with the default shader. - + --> @@ -285,7 +285,7 @@ the objects that use it, and replaces it with the default shader. 5 - - - - ReflGradientsTex - sampler-2d - 6 + --> + + + ReflGradientsTex + sampler-2d + 6 @@ -546,14 +546,6 @@ the objects that use it, and replaces it with the default shader. ambient-correction - - - shader_qual - int - - shader-quality - - hdg diff --git a/Effects/model-combined-transparent.eff b/Effects/model-combined-transparent.eff index fceb6a10f..3d1c68d27 100644 --- a/Effects/model-combined-transparent.eff +++ b/Effects/model-combined-transparent.eff @@ -79,13 +79,13 @@ and fallback to plain transparency when the model shader is disabled. DepthSortedBin - 0 + 0 texture[0]/active - - texture[0]/type - + + texture[0]/type + texture[0]/image @@ -198,9 +198,9 @@ and fallback to plain transparency when the model shader is disabled. texture[0]/image - - texture[0]/type - + + texture[0]/type + texture[0]/filter @@ -225,9 +225,9 @@ and fallback to plain transparency when the model shader is disabled. texture[2]/image - - texture[2]/type - + + texture[2]/type + texture[2]/filter @@ -247,9 +247,9 @@ and fallback to plain transparency when the model shader is disabled. texture[3]/image - - texture[3]/type - + + texture[3]/type + texture[3]/filter @@ -269,9 +269,9 @@ and fallback to plain transparency when the model shader is disabled. texture[4]/image - - texture[4]/type - + + texture[4]/type + texture[4]/filter @@ -308,9 +308,9 @@ and fallback to plain transparency when the model shader is disabled. texture[6]/image - - texture[6]/type - + + texture[6]/type + texture[6]/filter @@ -629,14 +629,6 @@ and fallback to plain transparency when the model shader is disabled. ambient-correction - - - shader_qual - int - - shader-quality - - hdg diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff index ddc36214f..dd21306cc 100644 --- a/Effects/model-combined.eff +++ b/Effects/model-combined.eff @@ -8,16 +8,16 @@ please see Docs/README.model-combined.eff for documentation - + --> 0 0 1.0 Aircraft/Generic/Effects/null_bumpspec.png - 2d + 2d linear-mipmap-linear clamp clamp @@ -36,7 +36,7 @@ please see Docs/README.model-combined.eff for documentation 1.0 1.0 1.0 Aircraft/Generic/Effects/greymap.png - 2d + 2d linear-mipmap-linear clamp clamp @@ -49,7 +49,7 @@ please see Docs/README.model-combined.eff for documentation 0 Aircraft/Generic/Effects/ReflectMaps/reflectmap.png - 2d + 2d linear-mipmap-linear clamp clamp @@ -76,7 +76,7 @@ please see Docs/README.model-combined.eff for documentation 0.1 Aircraft/Generic/Effects/Gradients.png - 2d + 2d linear-mipmap-linear repeat repeat @@ -91,7 +91,7 @@ please see Docs/README.model-combined.eff for documentation 10 Textures/Terrain/void.png - 2d + 2d linear-mipmap-linear repeat repeat @@ -109,10 +109,6 @@ please see Docs/README.model-combined.eff for documentation 0.0 0.05 - - - /sim/rendering/shaders/model - opaque false @@ -245,9 +241,9 @@ please see Docs/README.model-combined.eff for documentation texture[0]/image - - texture[0]/type - + + texture[0]/type + texture[0]/filter @@ -272,9 +268,9 @@ please see Docs/README.model-combined.eff for documentation texture[2]/image - - texture[2]/type - + + texture[2]/type + texture[2]/filter @@ -294,9 +290,9 @@ please see Docs/README.model-combined.eff for documentation texture[3]/image - - texture[3]/type - + + texture[3]/type + texture[3]/filter @@ -316,9 +312,9 @@ please see Docs/README.model-combined.eff for documentation texture[4]/image - - texture[4]/type - + + texture[4]/type + texture[4]/filter @@ -355,9 +351,9 @@ please see Docs/README.model-combined.eff for documentation texture[6]/image - - texture[6]/type - + + texture[6]/type + texture[6]/filter @@ -377,9 +373,9 @@ please see Docs/README.model-combined.eff for documentation texture[7]/image - - texture[7]/type - + + texture[7]/type + texture[7]/filter @@ -712,14 +708,6 @@ please see Docs/README.model-combined.eff for documentation ambient-correction - - - shader_qual - int - - shader-quality - - hdg @@ -922,9 +910,9 @@ please see Docs/README.model-combined.eff for documentation texture[0]/image - - texture[0]/type - + + texture[0]/type + texture[0]/filter @@ -949,9 +937,9 @@ please see Docs/README.model-combined.eff for documentation texture[2]/image - - texture[2]/type - + + texture[2]/type + texture[2]/filter @@ -971,9 +959,9 @@ please see Docs/README.model-combined.eff for documentation texture[3]/image - - texture[3]/type - + + texture[3]/type + texture[3]/filter @@ -993,9 +981,9 @@ please see Docs/README.model-combined.eff for documentation texture[4]/image - - texture[4]/type - + + texture[4]/type + texture[4]/filter @@ -1032,9 +1020,9 @@ please see Docs/README.model-combined.eff for documentation texture[6]/image - - texture[6]/type - + + texture[6]/type + texture[6]/filter @@ -1353,14 +1341,6 @@ please see Docs/README.model-combined.eff for documentation ambient-correction - - - shader_qual - int - - shader-quality - - hdg diff --git a/Shaders/building-ubershader.vert b/Shaders/building-ubershader.vert index d0d8cee8c..7a6d8a06b 100644 --- a/Shaders/building-ubershader.vert +++ b/Shaders/building-ubershader.vert @@ -64,17 +64,20 @@ void main(void) normal.xy = vec2(dot(normal.xy, vec2(cr, sr)), dot(normal.xy, vec2(-sr, cr))); //normal = gl_NormalMatrix * normal; - VNormal = normalize(gl_NormalMatrix * normal); - if (nmap_enabled > 0 && shader_qual > 2){ - VTangent = normalize(gl_NormalMatrix * tangent); - VBinormal = normalize(gl_NormalMatrix * binormal); - } else { - VTangent = vec3(0.0); - VBinormal = vec3 (0.0); - } - vec3 n = normalize(normal); - vec3 t = cross(n, vec3(1.0,0.0,0.0)); - vec3 b = cross(n,t); + VNormal = normalize(gl_NormalMatrix * normal); + vec3 n = normalize(normal); + vec3 tempTangent = cross(n, vec3(1.0,0.0,0.0)); + vec3 tempBinormal = cross(n, tempTangent); + + if (nmap_enabled > 0){ + tempTangent = tangent; + tempBinormal = binormal; + } + + VTangent = normalize(gl_NormalMatrix * tempTangent); + VBinormal = normalize(gl_NormalMatrix * tempBinormal); + vec3 t = tempTangent; + vec3 b = tempBinormal; // Super hack: if diffuse material alpha is less than 1, assume a // transparency animation is at work diff --git a/Shaders/ubershader-gbuffer.frag b/Shaders/ubershader-gbuffer.frag index 12732ae51..043b1c551 100644 --- a/Shaders/ubershader-gbuffer.frag +++ b/Shaders/ubershader-gbuffer.frag @@ -3,6 +3,7 @@ // Authors: Frederic Bouvier and Gijs de Rooy // with major additions and revisions by // Emilian Huminiuc and Vivian Meazza 2011 +#version 120 varying vec3 rawpos; varying vec3 VNormal; @@ -27,7 +28,6 @@ uniform int refl_enabled; uniform int refl_map; uniform int lightmap_enabled; uniform int lightmap_multi; -uniform int shader_qual; uniform int dirt_enabled; uniform int dirt_multi; @@ -80,7 +80,7 @@ void main (void) float pf; ///BEGIN bump - if (nmap_enabled > 0 && shader_qual > 2){ + if (nmap_enabled > 0){ N = nmap.rgb * 2.0 - 1.0; N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal); if (nmap_dds > 0) @@ -100,7 +100,7 @@ void main (void) //////////////////////////////////////////////////////////////////// //BEGIN reflect //////////////////////////////////////////////////////////////////// - if (refl_enabled > 0 && shader_qual > 1){ + if (refl_enabled > 0){ float reflFactor; float transparency_offset = clamp(refl_correction, -1.0, 1.0);// set the user shininess offset if(refl_map > 0){ @@ -163,7 +163,7 @@ void main (void) vec3 lightmapcolor; vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor, lightmap_b_factor, lightmap_a_factor); lightmapFactor = lightmapFactor * lightmapTexel; - if (lightmap_multi >0 ){ + if (lightmap_multi > 0 ){ lightmapcolor = lightmap_r_color * lightmapFactor.r + lightmap_g_color * lightmapFactor.g + lightmap_b_color * lightmapFactor.b + diff --git a/Shaders/ubershader-lightfield.frag b/Shaders/ubershader-lightfield.frag index 6caf3838c..50b179f7f 100644 --- a/Shaders/ubershader-lightfield.frag +++ b/Shaders/ubershader-lightfield.frag @@ -36,7 +36,6 @@ uniform int nmap_dds; uniform int nmap_enabled; uniform int refl_enabled; uniform int refl_map; -uniform int shader_qual; uniform int grain_texture_enabled; uniform float amb_correction; @@ -218,7 +217,7 @@ void main (void) /// END grain overlay ///BEGIN bump - if (nmap_enabled > 0 && shader_qual > 2){ + if (nmap_enabled > 0){ N = nmap.rgb * 2.0 - 1.0; N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal); if (nmap_dds > 0) @@ -258,7 +257,7 @@ void main (void) //////////////////////////////////////////////////////////////////// //BEGIN reflect //////////////////////////////////////////////////////////////////// - if (refl_enabled > 0 && shader_qual > 1){ + if (refl_enabled > 0){ float reflFactor = 0.0; float transparency_offset = clamp(refl_correction, -1.0, 1.0);// set the user shininess offset @@ -266,7 +265,7 @@ void main (void) // map the shininess of the object with user input //float pam = (map.a * -2) + 1; //reverse map reflFactor = reflmap.a + transparency_offset; - } else if (nmap_enabled > 0 && shader_qual > 2) { + } else if (nmap_enabled > 0) { // set the reflectivity proportional to shininess with user input reflFactor = gl_FrontMaterial.shininess * 0.0078125 * nmap.a + transparency_offset; } else { @@ -331,7 +330,7 @@ void main (void) vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor, lightmap_b_factor, lightmap_a_factor); lightmapFactor = lightmapFactor * lightmapTexel; - if (lightmap_multi >0 ){ + if (lightmap_multi > 0 ){ lightmapcolor = lightmap_r_color * lightmapFactor.r + lightmap_g_color * lightmapFactor.g + lightmap_b_color * lightmapFactor.b + diff --git a/Shaders/ubershader.frag b/Shaders/ubershader.frag index 3e28e5bc3..d2f5f96d8 100644 --- a/Shaders/ubershader.frag +++ b/Shaders/ubershader.frag @@ -30,7 +30,6 @@ uniform int nmap_dds; uniform int nmap_enabled; uniform int refl_enabled; uniform int refl_map; -uniform int shader_qual; uniform float amb_correction; uniform float dirt_b_factor; @@ -73,7 +72,7 @@ void main (void) float pf = 0.0; ///BEGIN bump - if (nmap_enabled > 0 && shader_qual > 2){ + if (nmap_enabled > 0 ){ N = nmap.rgb * 2.0 - 1.0; N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal); if (nmap_dds > 0) @@ -111,7 +110,7 @@ void main (void) //////////////////////////////////////////////////////////////////// //BEGIN reflect //////////////////////////////////////////////////////////////////// - if (refl_enabled > 0 && shader_qual > 1){ + if (refl_enabled > 0 ){ float reflFactor = 0.0; float transparency_offset = clamp(refl_correction, -1.0, 1.0);// set the user shininess offset @@ -119,7 +118,7 @@ void main (void) // map the shininess of the object with user input //float pam = (map.a * -2) + 1; //reverse map reflFactor = reflmap.a + transparency_offset; - } else if (nmap_enabled > 0 && shader_qual > 2) { + } else if (nmap_enabled > 0) { // set the reflectivity proportional to shininess with user input reflFactor = gl_FrontMaterial.shininess * 0.0078125 * nmap.a + transparency_offset; } else { @@ -182,7 +181,7 @@ void main (void) vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor, lightmap_b_factor, lightmap_a_factor); lightmapFactor = lightmapFactor * lightmapTexel; - if (lightmap_multi >0 ){ + if (lightmap_multi > 0 ){ lightmapcolor = lightmap_r_color * lightmapFactor.r + lightmap_g_color * lightmapFactor.g + lightmap_b_color * lightmapFactor.b + diff --git a/Shaders/ubershader.vert b/Shaders/ubershader.vert index 2b4b516ed..23687cb1b 100644 --- a/Shaders/ubershader.vert +++ b/Shaders/ubershader.vert @@ -52,19 +52,23 @@ void main(void) //fog_Func(fogType); VNormal = normalize(gl_NormalMatrix * gl_Normal); - if (nmap_enabled > 0 && shader_qual > 2){ - VTangent = normalize(gl_NormalMatrix * tangent); - VBinormal = normalize(gl_NormalMatrix * binormal); - } else { - VTangent = vec3(0.0); - VBinormal = vec3 (0.0); - } - vec3 n = normalize(gl_Normal); - vec3 t = cross(n, vec3(1.0,0.0,0.0)); - vec3 b = cross(n,t); - // Super hack: if diffuse material alpha is less than 1, assume a - // transparency animation is at work + vec3 n = normalize(gl_Normal); + vec3 tempTangent = cross(n, vec3(1.0,0.0,0.0)); + vec3 tempBinormal = cross(n, tempTangent); + + if (nmap_enabled > 0){ + tempTangent = tangent; + tempBinormal = binormal; + } + + VTangent = normalize(gl_NormalMatrix * tempTangent); + VBinormal = normalize(gl_NormalMatrix * tempBinormal); + vec3 t = tempTangent; + vec3 b = tempBinormal; + + // Super hack: if diffuse material alpha is less than 1, assume a + // transparency animation is at work if (gl_FrontMaterial.diffuse.a < 1.0) alpha = gl_FrontMaterial.diffuse.a; else @@ -76,7 +80,7 @@ void main(void) vViewVec.y = dot(b, vertVec); vViewVec.z = dot(n, vertVec); - // calculate the reflection vector + // calculate the reflection vector vec4 reflect_eye = vec4(reflect(vertVec, VNormal), 0.0); vec3 reflVec_stat = normalize(gl_ModelViewMatrixInverse * reflect_eye).xyz; if (refl_dynamic > 0){ diff --git a/gui/dialogs/shaders.xml b/gui/dialogs/shaders.xml index 212f4b772..4bdfc82f7 100644 --- a/gui/dialogs/shaders.xml +++ b/gui/dialogs/shaders.xml @@ -230,9 +230,9 @@ model 0.0 - 3.0 + 1.0 1.0 - 0.25 + 0.5 true /sim/rendering/shaders/model