From 72c876aec682478256c82da1eb0d06f0b0a2d07c Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Thu, 17 Jan 2013 11:32:00 +0200 Subject: [PATCH] Ubershader fixes Signed-off-by: Emilian Huminiuc --- Effects/building.eff | 4 +- Effects/model-combined-deferred.eff | 2 +- Effects/model-combined-transparent.eff | 613 +++++++++++++++++++++++++ Effects/model-combined.eff | 611 +----------------------- Shaders/ubershader-gbuffer.frag | 4 +- Shaders/ubershader.frag | 48 +- 6 files changed, 643 insertions(+), 639 deletions(-) diff --git a/Effects/building.eff b/Effects/building.eff index 84e0383cf..96a407319 100644 --- a/Effects/building.eff +++ b/Effects/building.eff @@ -289,7 +289,7 @@ - + diff --git a/Effects/model-combined-deferred.eff b/Effects/model-combined-deferred.eff index d098cb9ba..8853d2ceb 100644 --- a/Effects/model-combined-deferred.eff +++ b/Effects/model-combined-deferred.eff @@ -303,7 +303,7 @@ the objects that use it, and replaces it with the default shader. nmap_tile - int + float normalmap-tiling diff --git a/Effects/model-combined-transparent.eff b/Effects/model-combined-transparent.eff index 61fbb1b41..7aebf6372 100644 --- a/Effects/model-combined-transparent.eff +++ b/Effects/model-combined-transparent.eff @@ -110,4 +110,617 @@ and fallback to plain transparency when the model shader is disabled. --> + + + + + + /sim/rendering/shaders/model + /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 + + + rendering-hint + + + transparent + + + transparent + + + 111 + DepthSortedBin + + + + 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/include_fog.frag + Shaders/ubershader.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 + float + + 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 db5ac8fbb..c4337dda4 100644 --- a/Effects/model-combined.eff +++ b/Effects/model-combined.eff @@ -151,617 +151,8 @@ please see Docs/README.model-combined.eff for documentation 7 --> - - - - - /sim/rendering/shaders/model - /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 - - - rendering-hint - - - transparent - - - transparent - - - 111 - DepthSortedBin - - - - 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/include_fog.frag - Shaders/ubershader.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 - - - - - @@ -1069,7 +460,7 @@ please see Docs/README.model-combined.eff for documentation nmap_tile - int + float normalmap-tiling diff --git a/Shaders/ubershader-gbuffer.frag b/Shaders/ubershader-gbuffer.frag index f8566e2eb..c3651bfc0 100644 --- a/Shaders/ubershader-gbuffer.frag +++ b/Shaders/ubershader-gbuffer.frag @@ -24,7 +24,6 @@ uniform sampler3D ReflNoiseTex; uniform int nmap_enabled; uniform int nmap_dds; -uniform int nmap_tile; uniform int refl_enabled; uniform int refl_map; uniform int lightmap_enabled; @@ -37,6 +36,7 @@ uniform float lightmap_r_factor; uniform float lightmap_g_factor; uniform float lightmap_b_factor; uniform float lightmap_a_factor; +uniform float nmap_tile; uniform float refl_correction; uniform float refl_fresnel; uniform float refl_rainbow; @@ -95,7 +95,7 @@ void main (void) float v = abs(dot(viewVec, normalize(VNormal)));// Map a rainbowish color vec4 fresnel = texture2D(ReflFresnelTex, vec2(v, 0.0)); vec4 rainbow = texture2D(ReflRainbowTex, vec2(v, 0.0)); - vec4 color = gl_Color * gl_FrontMaterial.diffuse; + vec4 color = gl_Color;// * gl_FrontMaterial.diffuse; float specular = dot((gl_FrontMaterial.specular * nmap.a).rgb, vec3( 0.3, 0.59, 0.11 )); //////////////////////////////////////////////////////////////////// diff --git a/Shaders/ubershader.frag b/Shaders/ubershader.frag index 51df2d02a..9ff7c9bd6 100644 --- a/Shaders/ubershader.frag +++ b/Shaders/ubershader.frag @@ -5,47 +5,47 @@ // Emilian Huminiuc and Vivian Meazza 2011 #version 120 -varying vec3 rawpos; +varying vec3 VBinormal; varying vec3 VNormal; varying vec3 VTangent; -varying vec3 VBinormal; -varying vec3 vViewVec; +varying vec3 rawpos; varying vec3 reflVec; +varying vec3 vViewVec; varying float alpha; -uniform samplerCube Environment; uniform sampler2D BaseTex; -uniform sampler2D NormalTex; uniform sampler2D LightMapTex; -uniform sampler2D ReflMapTex; +uniform sampler2D NormalTex; uniform sampler2D ReflFresnelTex; +uniform sampler2D ReflMapTex; uniform sampler2D ReflRainbowTex; uniform sampler3D ReflNoiseTex; +uniform samplerCube Environment; -uniform int nmap_enabled; -uniform int nmap_dds; -uniform int nmap_tile; -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; +uniform int lightmap_enabled; +uniform int lightmap_multi; +uniform int nmap_dds; +uniform int nmap_enabled; +uniform int refl_enabled; +uniform int refl_map; +uniform int shader_qual; -uniform float lightmap_r_factor; -uniform float lightmap_g_factor; -uniform float lightmap_b_factor; +uniform float amb_correction; +uniform float dirt_b_factor; +uniform float dirt_g_factor; +uniform float dirt_r_factor; uniform float lightmap_a_factor; +uniform float lightmap_b_factor; +uniform float lightmap_g_factor; +uniform float lightmap_r_factor; +uniform float nmap_tile; uniform float refl_correction; uniform float refl_fresnel; -uniform float refl_rainbow; uniform float refl_noise; -uniform float amb_correction; -uniform float dirt_r_factor; -uniform float dirt_g_factor; -uniform float dirt_b_factor; +uniform float refl_rainbow; uniform vec3 lightmap_r_color; uniform vec3 lightmap_g_color; @@ -104,7 +104,7 @@ void main (void) pf = pow(nDotHV, gl_FrontMaterial.shininess); vec4 Diffuse = gl_LightSource[0].diffuse * nDotVP; - vec4 Specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * pf; + vec4 Specular = gl_FrontMaterial.specular * gl_LightSource[0].diffuse * pf; vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse; color += Specular * gl_FrontMaterial.specular * nmap.a; @@ -136,7 +136,7 @@ void main (void) vec4 noisecolor = mix(reflfrescolor, noisevec, refl_noise); vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0); raincolor += Specular * nmap.a; - + raincolor *= gl_LightSource[0].diffuse; mixedcolor = mix(texel, raincolor, reflFactor).rgb; } else { mixedcolor = texel.rgb;