diff --git a/Effects/model-pbr.eff b/Effects/model-pbr.eff index d97e806e4..842bb1970 100644 --- a/Effects/model-pbr.eff +++ b/Effects/model-pbr.eff @@ -10,32 +10,33 @@ 1.0 1.0 1.0 1.0 - Aircraft/Generic/Effects/null_bumpspec.png - 2d - linear-mipmap-linear - repeat - repeat - normalized + null-normalmap - + white 1.0 - + 1.0 + white - 1.0 - + white - - - white - 0.0 0.0 0.0 + + + false + + opaque + -1.0 + + back + + false @@ -51,56 +52,49 @@ texture[0]/type texture[0]/image texture[0]/filter + texture[0]/mag-filter texture[0]/wrap-s texture[0]/wrap-t - texture[0]/internal-format 1 texture[1]/type texture[1]/image texture[1]/filter + texture[1]/mag-filter texture[1]/wrap-s texture[1]/wrap-t - texture[1]/internal-format 2 texture[2]/type texture[2]/image texture[2]/filter + texture[2]/mag-filter texture[2]/wrap-s texture[2]/wrap-t - texture[2]/internal-format 3 texture[3]/type texture[3]/image texture[3]/filter + texture[3]/mag-filter texture[3]/wrap-s texture[3]/wrap-t - texture[3]/internal-format 4 texture[4]/type texture[4]/image texture[4]/filter + texture[0]/mag-filter texture[4]/wrap-s texture[4]/wrap-t - texture[4]/internal-format - - 5 - texture[5]/type - texture[5]/image - texture[5]/filter - texture[5]/wrap-s - texture[5]/wrap-t - texture[5]/internal-format - - back + blend/active + rendering-hint + cull-face Shaders/HDR/geometry-pbr.vert Shaders/HDR/geometry-pbr.frag @@ -125,24 +119,19 @@ 1 - metallic_tex + metallic_roughness_tex sampler-2d 2 - roughness_tex + occlusion_tex sampler-2d 3 - - occlusion_tex - sampler-2d - 4 - emissive_tex sampler-2d - 5 + 4 base_color_factor @@ -164,6 +153,16 @@ float-vec3 emissive-factor + + alpha_cutoff + float + alpha-cutoff + + + flip_vertically + bool + flip-vertically + diff --git a/Shaders/HDR/geometry-pbr.frag b/Shaders/HDR/geometry-pbr.frag index c00d4a589..ce486ab5e 100644 --- a/Shaders/HDR/geometry-pbr.frag +++ b/Shaders/HDR/geometry-pbr.frag @@ -9,22 +9,27 @@ in mat3 TBN; uniform sampler2D base_color_tex; uniform sampler2D normal_tex; -uniform sampler2D metallic_tex; -uniform sampler2D roughness_tex; +uniform sampler2D metallic_roughness_tex; uniform sampler2D occlusion_tex; uniform sampler2D emissive_tex; uniform vec4 base_color_factor; uniform float metallic_factor; uniform float roughness_factor; uniform vec3 emissive_factor; +uniform float alpha_cutoff; vec2 encodeNormal(vec3 n); vec3 decodeSRGB(vec3 screenRGB); void main() { - vec4 base_color_texel = texture(base_color_tex, texCoord); - gbuffer0.rgb = decodeSRGB(base_color_texel.rgb); // Ignore alpha + vec4 baseColorTexel = texture(base_color_tex, texCoord); + vec4 baseColor = vec4(decodeSRGB(baseColorTexel.rgb), baseColorTexel.a) + * base_color_factor; + if (baseColor.a < alpha_cutoff) + discard; + gbuffer0.rgb = baseColor.rgb; + float occlusion = texture(occlusion_tex, texCoord).r; gbuffer0.a = occlusion; @@ -32,8 +37,9 @@ void main() normal = normalize(TBN * normal); gbuffer1 = encodeNormal(normal); - float metallic = texture(metallic_tex, texCoord).r * metallic_factor; - float roughness = texture(roughness_tex, texCoord).r * roughness_factor; + vec4 metallicRoughness = texture(metallic_roughness_tex, texCoord); + float metallic = metallicRoughness.r * metallic_factor; + float roughness = metallicRoughness.g * roughness_factor; gbuffer2 = vec4(metallic, roughness, 0.0, 0.0); vec3 emissive = texture(emissive_tex, texCoord).rgb * emissive_factor; diff --git a/Shaders/HDR/geometry-pbr.vert b/Shaders/HDR/geometry-pbr.vert index f1ad780f5..bbd2f50ed 100644 --- a/Shaders/HDR/geometry-pbr.vert +++ b/Shaders/HDR/geometry-pbr.vert @@ -12,10 +12,14 @@ out mat3 TBN; uniform mat4 osg_ModelViewProjectionMatrix; uniform mat3 osg_NormalMatrix; +uniform bool flip_vertically; + void main() { gl_Position = osg_ModelViewProjectionMatrix * pos; texCoord = multiTexCoord0.st; + if (flip_vertically) + texCoord.y = 1.0 - texCoord.y; vec3 T = normalize(osg_NormalMatrix * tangent); vec3 B = normalize(osg_NormalMatrix * binormal);