HDR: Properly handle AC3D transparent materials
This commit is contained in:
parent
765a7d88f5
commit
7ff31e9004
11 changed files with 488 additions and 7 deletions
|
@ -68,6 +68,15 @@
|
||||||
<lightmap-color type="vec3d" n="2"> 1.0 1.0 1.0 </lightmap-color>
|
<lightmap-color type="vec3d" n="2"> 1.0 1.0 1.0 </lightmap-color>
|
||||||
<lightmap-factor type="float" n="3">1.0</lightmap-factor>
|
<lightmap-factor type="float" n="3">1.0</lightmap-factor>
|
||||||
<lightmap-color type="vec3d" n="3"> 1.0 1.0 1.0 </lightmap-color>
|
<lightmap-color type="vec3d" n="3"> 1.0 1.0 1.0 </lightmap-color>
|
||||||
|
<texture n="8">
|
||||||
|
<image>Textures/PBR/dfg_lut.dds</image>
|
||||||
|
<type>2d</type>
|
||||||
|
<filter>linear</filter>
|
||||||
|
<mag-filter>linear</mag-filter>
|
||||||
|
<wrap-s>clamp-to-edge</wrap-s>
|
||||||
|
<wrap-t>clamp-to-edge</wrap-t>
|
||||||
|
<internal-format>normalized</internal-format>
|
||||||
|
</texture>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<technique n="4">
|
<technique n="4">
|
||||||
|
@ -519,9 +528,93 @@
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
</technique>
|
</technique>
|
||||||
<!-- TODO: Actually implement a glass shader instead of just hiding it -->
|
|
||||||
<technique n="2">
|
<technique n="2">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
|
<pass>
|
||||||
|
<!-- Reverse floating point depth buffer -->
|
||||||
|
<depth>
|
||||||
|
<function>gequal</function>
|
||||||
|
<near>1.0</near>
|
||||||
|
<far>0.0</far>
|
||||||
|
</depth>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>0</unit>
|
||||||
|
<type><use>texture[0]/type</use></type>
|
||||||
|
<image><use>texture[0]/image</use></image>
|
||||||
|
<filter><use>texture[0]/filter</use></filter>
|
||||||
|
<mag-filter><use>texture[0]/mag-filter</use></mag-filter>
|
||||||
|
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||||
|
</texture-unit>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>8</unit>
|
||||||
|
<image><use>texture[8]/image</use></image>
|
||||||
|
<type><use>texture[8]/type</use></type>
|
||||||
|
<filter><use>texture[8]/filter</use></filter>
|
||||||
|
<mag-filter><use>texture[8]/mag-filter</use></mag-filter>
|
||||||
|
<wrap-s><use>texture[8]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[8]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format><use>texture[8]/internal-format</use></internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<blend>1</blend>
|
||||||
|
<rendering-hint>transparent</rendering-hint>
|
||||||
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/HDR/geometry-transparent.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/geometry-transparent.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/lighting-include.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/aerial-perspective-include.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
<uniform>
|
||||||
|
<name>color_tex</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>color_mode</name>
|
||||||
|
<type>int</type>
|
||||||
|
<value><use>material/color-mode</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>material_diffuse</name>
|
||||||
|
<type>float-vec4</type>
|
||||||
|
<value><use>material/diffuse</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>minimum_alpha</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value>0.1</value>
|
||||||
|
</uniform>
|
||||||
|
<!-- Lighting include -->
|
||||||
|
<uniform>
|
||||||
|
<name>dfg_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">8</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>prefiltered_envmap</name>
|
||||||
|
<type>sampler-cube</type>
|
||||||
|
<value type="int">9</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>shadow_tex</name>
|
||||||
|
<type>sampler-2d-shadow</type>
|
||||||
|
<value type="int">10</value>
|
||||||
|
</uniform>
|
||||||
|
<!-- Aerial perspective include -->
|
||||||
|
<uniform>
|
||||||
|
<name>aerial_perspective_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">11</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>transmittance_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">12</value>
|
||||||
|
</uniform>
|
||||||
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
</PropertyList>
|
</PropertyList>
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,102 @@ and fallback to plain transparency when the model shader is disabled.
|
||||||
<PropertyList>
|
<PropertyList>
|
||||||
<name>Effects/model-combined-transparent</name>
|
<name>Effects/model-combined-transparent</name>
|
||||||
<inherits-from>Effects/model-combined</inherits-from>
|
<inherits-from>Effects/model-combined</inherits-from>
|
||||||
|
<parameters>
|
||||||
|
<texture n="8">
|
||||||
|
<image>Textures/PBR/dfg_lut.dds</image>
|
||||||
|
<type>2d</type>
|
||||||
|
<filter>linear</filter>
|
||||||
|
<mag-filter>linear</mag-filter>
|
||||||
|
<wrap-s>clamp-to-edge</wrap-s>
|
||||||
|
<wrap-t>clamp-to-edge</wrap-t>
|
||||||
|
<internal-format>normalized</internal-format>
|
||||||
|
</texture>
|
||||||
|
</parameters>
|
||||||
|
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
</technique>
|
</technique>
|
||||||
|
|
||||||
<technique n="2">
|
<technique n="2">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
|
<pass>
|
||||||
|
<!-- Reverse floating point depth buffer -->
|
||||||
|
<depth>
|
||||||
|
<function>gequal</function>
|
||||||
|
<near>1.0</near>
|
||||||
|
<far>0.0</far>
|
||||||
|
</depth>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>0</unit>
|
||||||
|
<type><use>texture[0]/type</use></type>
|
||||||
|
<image><use>texture[0]/image</use></image>
|
||||||
|
<filter><use>texture[0]/filter</use></filter>
|
||||||
|
<mag-filter><use>texture[0]/mag-filter</use></mag-filter>
|
||||||
|
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||||
|
</texture-unit>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>8</unit>
|
||||||
|
<image><use>texture[8]/image</use></image>
|
||||||
|
<type><use>texture[8]/type</use></type>
|
||||||
|
<filter><use>texture[8]/filter</use></filter>
|
||||||
|
<mag-filter><use>texture[8]/mag-filter</use></mag-filter>
|
||||||
|
<wrap-s><use>texture[8]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[8]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format><use>texture[8]/internal-format</use></internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<blend>1</blend>
|
||||||
|
<rendering-hint>transparent</rendering-hint>
|
||||||
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/HDR/geometry-transparent.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/geometry-transparent.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/lighting-include.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/aerial-perspective-include.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
<uniform>
|
||||||
|
<name>color_tex</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>color_mode</name>
|
||||||
|
<type>int</type>
|
||||||
|
<value><use>material/color-mode</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>material_diffuse</name>
|
||||||
|
<type>float-vec4</type>
|
||||||
|
<value><use>material/diffuse</use></value>
|
||||||
|
</uniform>
|
||||||
|
<!-- Lighting include -->
|
||||||
|
<uniform>
|
||||||
|
<name>dfg_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">8</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>prefiltered_envmap</name>
|
||||||
|
<type>sampler-cube</type>
|
||||||
|
<value type="int">9</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>shadow_tex</name>
|
||||||
|
<type>sampler-2d-shadow</type>
|
||||||
|
<value type="int">10</value>
|
||||||
|
</uniform>
|
||||||
|
<!-- Aerial perspective include -->
|
||||||
|
<uniform>
|
||||||
|
<name>aerial_perspective_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">11</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>transmittance_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">12</value>
|
||||||
|
</uniform>
|
||||||
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
</PropertyList>
|
</PropertyList>
|
||||||
|
|
|
@ -1340,6 +1340,11 @@ please see Docs/README.model-combined.eff for documentation
|
||||||
<type>int</type>
|
<type>int</type>
|
||||||
<value><use>normalmap-enabled</use></value>
|
<value><use>normalmap-enabled</use></value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>normalmap_dds</name>
|
||||||
|
<type>int</type>
|
||||||
|
<value><use>normalmap-dds</use></value>
|
||||||
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>normalmap_tiling</name>
|
<name>normalmap_tiling</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
|
|
@ -651,4 +651,47 @@
|
||||||
</pass>
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
|
|
||||||
|
<technique n="109">
|
||||||
|
<scheme>hdr-geometry</scheme>
|
||||||
|
<pass>
|
||||||
|
<!-- Reverse floating point depth buffer -->
|
||||||
|
<depth>
|
||||||
|
<function>gequal</function>
|
||||||
|
<near>1.0</near>
|
||||||
|
<far>0.0</far>
|
||||||
|
</depth>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>0</unit>
|
||||||
|
<type><use>texture[0]/type</use></type>
|
||||||
|
<image><use>texture[0]/image</use></image>
|
||||||
|
<filter><use>texture[0]/filter</use></filter>
|
||||||
|
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||||
|
</texture-unit>
|
||||||
|
<blend>0</blend>
|
||||||
|
<rendering-hint>opaque</rendering-hint>
|
||||||
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/HDR/geometry.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/geometry.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
<uniform>
|
||||||
|
<name>color_tex</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>color_mode</name>
|
||||||
|
<type>int</type>
|
||||||
|
<value><use>material/color-mode</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>material_diffuse</name>
|
||||||
|
<type>float-vec4</type>
|
||||||
|
<value><use>material/diffuse</use></value>
|
||||||
|
</uniform>
|
||||||
|
</pass>
|
||||||
|
</technique>
|
||||||
|
|
||||||
</PropertyList>
|
</PropertyList>
|
||||||
|
|
|
@ -31,6 +31,15 @@
|
||||||
<use>/sim/rendering/shaders/skydome</use>
|
<use>/sim/rendering/shaders/skydome</use>
|
||||||
</fogtype>
|
</fogtype>
|
||||||
<!-- END fog include -->
|
<!-- END fog include -->
|
||||||
|
<texture n="8">
|
||||||
|
<image>Textures/PBR/dfg_lut.dds</image>
|
||||||
|
<type>2d</type>
|
||||||
|
<filter>linear</filter>
|
||||||
|
<mag-filter>linear</mag-filter>
|
||||||
|
<wrap-s>clamp-to-edge</wrap-s>
|
||||||
|
<wrap-t>clamp-to-edge</wrap-t>
|
||||||
|
<internal-format>normalized</internal-format>
|
||||||
|
</texture>
|
||||||
</parameters>
|
</parameters>
|
||||||
<technique n="11">
|
<technique n="11">
|
||||||
<pass>
|
<pass>
|
||||||
|
@ -123,6 +132,84 @@
|
||||||
</technique>
|
</technique>
|
||||||
<technique n="129">
|
<technique n="129">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
|
<pass>
|
||||||
|
<!-- Reverse floating point depth buffer -->
|
||||||
|
<depth>
|
||||||
|
<function>gequal</function>
|
||||||
|
<near>1.0</near>
|
||||||
|
<far>0.0</far>
|
||||||
|
</depth>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>0</unit>
|
||||||
|
<type><use>texture[0]/type</use></type>
|
||||||
|
<image><use>texture[0]/image</use></image>
|
||||||
|
<filter><use>texture[0]/filter</use></filter>
|
||||||
|
<mag-filter><use>texture[0]/mag-filter</use></mag-filter>
|
||||||
|
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||||
|
</texture-unit>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>8</unit>
|
||||||
|
<image><use>texture[8]/image</use></image>
|
||||||
|
<type><use>texture[8]/type</use></type>
|
||||||
|
<filter><use>texture[8]/filter</use></filter>
|
||||||
|
<mag-filter><use>texture[8]/mag-filter</use></mag-filter>
|
||||||
|
<wrap-s><use>texture[8]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[8]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format><use>texture[8]/internal-format</use></internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<blend>1</blend>
|
||||||
|
<rendering-hint>transparent</rendering-hint>
|
||||||
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/HDR/geometry-transparent.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/geometry-transparent.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/lighting-include.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/aerial-perspective-include.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
<uniform>
|
||||||
|
<name>color_tex</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>color_mode</name>
|
||||||
|
<type>int</type>
|
||||||
|
<value><use>material/color-mode</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>material_diffuse</name>
|
||||||
|
<type>float-vec4</type>
|
||||||
|
<value><use>material/diffuse</use></value>
|
||||||
|
</uniform>
|
||||||
|
<!-- Lighting include -->
|
||||||
|
<uniform>
|
||||||
|
<name>dfg_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">8</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>prefiltered_envmap</name>
|
||||||
|
<type>sampler-cube</type>
|
||||||
|
<value type="int">9</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>shadow_tex</name>
|
||||||
|
<type>sampler-2d-shadow</type>
|
||||||
|
<value type="int">10</value>
|
||||||
|
</uniform>
|
||||||
|
<!-- Aerial perspective include -->
|
||||||
|
<uniform>
|
||||||
|
<name>aerial_perspective_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">11</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>transmittance_lut</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">12</value>
|
||||||
|
</uniform>
|
||||||
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
|
|
||||||
</PropertyList>
|
</PropertyList>
|
||||||
|
|
|
@ -10,6 +10,7 @@ in mat3 TBN;
|
||||||
uniform sampler2D color_tex;
|
uniform sampler2D color_tex;
|
||||||
uniform sampler2D normal_tex;
|
uniform sampler2D normal_tex;
|
||||||
uniform int normalmap_enabled;
|
uniform int normalmap_enabled;
|
||||||
|
uniform int normalmap_dds;
|
||||||
uniform float normalmap_tiling;
|
uniform float normalmap_tiling;
|
||||||
|
|
||||||
const float DEFAULT_COMBINED_METALNESS = 0.0;
|
const float DEFAULT_COMBINED_METALNESS = 0.0;
|
||||||
|
@ -26,6 +27,9 @@ void main()
|
||||||
vec3 normal = vec3(0.5, 0.5, 1.0);
|
vec3 normal = vec3(0.5, 0.5, 1.0);
|
||||||
if (normalmap_enabled > 0) {
|
if (normalmap_enabled > 0) {
|
||||||
normal = texture(normal_tex, texCoord * normalmap_tiling).rgb * 2.0 - 1.0;
|
normal = texture(normal_tex, texCoord * normalmap_tiling).rgb * 2.0 - 1.0;
|
||||||
|
// DDS has flipped normals
|
||||||
|
if (normalmap_dds > 0)
|
||||||
|
normal = -normal;
|
||||||
}
|
}
|
||||||
normal = normalize(TBN * normal);
|
normal = normalize(TBN * normal);
|
||||||
gbuffer1 = encodeNormal(normal);
|
gbuffer1 = encodeNormal(normal);
|
||||||
|
|
94
Shaders/HDR/geometry-transparent.frag
Normal file
94
Shaders/HDR/geometry-transparent.frag
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
in vec3 normalVS;
|
||||||
|
in vec2 texCoord;
|
||||||
|
in vec4 materialColor;
|
||||||
|
in vec3 ecPos;
|
||||||
|
|
||||||
|
uniform sampler2D color_tex;
|
||||||
|
uniform float minimum_alpha = 0.0;
|
||||||
|
|
||||||
|
uniform mat4 osg_ViewMatrixInverse;
|
||||||
|
uniform vec4 fg_Viewport;
|
||||||
|
uniform vec3 fg_SunDirection;
|
||||||
|
|
||||||
|
const float DEFAULT_TRANSPARENT_ROUGHNESS = 0.1;
|
||||||
|
|
||||||
|
vec3 decodeSRGB(vec3 screenRGB);
|
||||||
|
vec3 getF0Reflectance(vec3 baseColor, float metallic);
|
||||||
|
float getShadowing(vec3 p, vec3 n, float NdotL);
|
||||||
|
vec3 evaluateLight(
|
||||||
|
vec3 baseColor,
|
||||||
|
float metallic,
|
||||||
|
float roughness,
|
||||||
|
float clearcoat,
|
||||||
|
float clearcoatRoughness,
|
||||||
|
vec3 f0,
|
||||||
|
vec3 intensity,
|
||||||
|
float occlusion,
|
||||||
|
vec3 n,
|
||||||
|
vec3 l,
|
||||||
|
vec3 v,
|
||||||
|
float NdotL,
|
||||||
|
float NdotV);
|
||||||
|
vec3 evaluateIBL(
|
||||||
|
vec3 baseColor,
|
||||||
|
float metallic,
|
||||||
|
float roughness,
|
||||||
|
vec3 f0,
|
||||||
|
float occlusion,
|
||||||
|
vec3 nWorldSpace,
|
||||||
|
float NdotV,
|
||||||
|
vec3 reflected);
|
||||||
|
vec3 addAerialPerspective(vec3 color, vec2 coord, float depth);
|
||||||
|
vec3 getSunIntensity();
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 baseColorTexel = texture(color_tex, texCoord);
|
||||||
|
vec3 baseColor = decodeSRGB(baseColorTexel.rgb) * materialColor.rgb;
|
||||||
|
// HACK: Force a minimum value to stay compatible with glass.eff
|
||||||
|
float alpha = max(materialColor.a * baseColorTexel.a, minimum_alpha);
|
||||||
|
|
||||||
|
vec3 n = normalize(normalVS);
|
||||||
|
vec3 v = normalize(-ecPos);
|
||||||
|
vec3 l = fg_SunDirection;
|
||||||
|
|
||||||
|
float NdotL = dot(n, l);
|
||||||
|
float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
|
||||||
|
|
||||||
|
vec3 f0 = getF0Reflectance(baseColor.rgb, 0.0);
|
||||||
|
|
||||||
|
vec3 sunIlluminance = getSunIntensity() * clamp(NdotL, 0.0, 1.0);
|
||||||
|
float shadowFactor = getShadowing(ecPos, n, NdotL);
|
||||||
|
|
||||||
|
vec3 color = evaluateLight(baseColor,
|
||||||
|
0.0,
|
||||||
|
DEFAULT_TRANSPARENT_ROUGHNESS,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
f0,
|
||||||
|
sunIlluminance,
|
||||||
|
shadowFactor,
|
||||||
|
n, l, v,
|
||||||
|
NdotL, NdotV);
|
||||||
|
|
||||||
|
vec3 worldNormal = (osg_ViewMatrixInverse * vec4(n, 0.0)).xyz;
|
||||||
|
vec3 worldReflected = (osg_ViewMatrixInverse * vec4(reflect(-v, n), 0.0)).xyz;
|
||||||
|
|
||||||
|
color += evaluateIBL(baseColor,
|
||||||
|
0.0,
|
||||||
|
DEFAULT_TRANSPARENT_ROUGHNESS,
|
||||||
|
f0,
|
||||||
|
1.0,
|
||||||
|
worldNormal,
|
||||||
|
NdotV,
|
||||||
|
worldReflected);
|
||||||
|
|
||||||
|
vec2 coord = (gl_FragCoord.xy - fg_Viewport.xy) / fg_Viewport.zw;
|
||||||
|
color = addAerialPerspective(color, coord, length(ecPos));
|
||||||
|
|
||||||
|
fragColor = vec4(color, alpha);
|
||||||
|
}
|
44
Shaders/HDR/geometry-transparent.vert
Normal file
44
Shaders/HDR/geometry-transparent.vert
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
#define MODE_OFF 0
|
||||||
|
#define MODE_DIFFUSE 1
|
||||||
|
#define MODE_AMBIENT_AND_DIFFUSE 2
|
||||||
|
|
||||||
|
layout(location = 0) in vec4 pos;
|
||||||
|
layout(location = 1) in vec3 normal;
|
||||||
|
layout(location = 2) in vec4 vertexColor;
|
||||||
|
layout(location = 3) in vec4 multiTexCoord0;
|
||||||
|
|
||||||
|
out vec3 normalVS;
|
||||||
|
out vec2 texCoord;
|
||||||
|
out vec4 materialColor;
|
||||||
|
out vec3 ecPos;
|
||||||
|
|
||||||
|
uniform int color_mode;
|
||||||
|
uniform vec4 material_diffuse;
|
||||||
|
|
||||||
|
uniform mat4 osg_ModelViewMatrix;
|
||||||
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
|
uniform mat3 osg_NormalMatrix;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
normalVS = normalize(osg_NormalMatrix * normal);
|
||||||
|
texCoord = multiTexCoord0.st;
|
||||||
|
ecPos = (osg_ModelViewMatrix * pos).xyz;
|
||||||
|
|
||||||
|
// Legacy material handling
|
||||||
|
if (color_mode == MODE_DIFFUSE)
|
||||||
|
materialColor = vertexColor;
|
||||||
|
else if (color_mode == MODE_AMBIENT_AND_DIFFUSE)
|
||||||
|
materialColor = vertexColor;
|
||||||
|
else
|
||||||
|
materialColor = material_diffuse;
|
||||||
|
// Super hack: if diffuse material alpha is less than 1, assume a
|
||||||
|
// transparency animation is at work
|
||||||
|
if (material_diffuse.a < 1.0)
|
||||||
|
materialColor.a = material_diffuse.a;
|
||||||
|
else
|
||||||
|
materialColor.a = vertexColor.a;
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ layout(location = 2) out vec4 gbuffer2;
|
||||||
|
|
||||||
in vec3 normalVS;
|
in vec3 normalVS;
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
|
in vec4 materialColor;
|
||||||
|
|
||||||
uniform sampler2D color_tex;
|
uniform sampler2D color_tex;
|
||||||
|
|
||||||
|
@ -17,7 +18,9 @@ vec3 decodeSRGB(vec3 screenRGB);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gbuffer0.rgb = decodeSRGB(texture(color_tex, texCoord).rgb);
|
vec3 texel = texture(color_tex, texCoord).rgb;
|
||||||
|
vec3 color = decodeSRGB(texel) * materialColor.rgb; // Ignore transparency
|
||||||
|
gbuffer0.rgb = color;
|
||||||
gbuffer0.a = 1.0;
|
gbuffer0.a = 1.0;
|
||||||
gbuffer1 = encodeNormal(normalVS);
|
gbuffer1 = encodeNormal(normalVS);
|
||||||
gbuffer2 = vec4(DEFAULT_METALNESS,
|
gbuffer2 = vec4(DEFAULT_METALNESS,
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
|
#define MODE_OFF 0
|
||||||
|
#define MODE_DIFFUSE 1
|
||||||
|
#define MODE_AMBIENT_AND_DIFFUSE 2
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
layout(location = 0) in vec4 pos;
|
||||||
layout(location = 1) in vec3 normal;
|
layout(location = 1) in vec3 normal;
|
||||||
|
layout(location = 2) in vec4 vertexColor;
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
layout(location = 3) in vec4 multiTexCoord0;
|
||||||
|
|
||||||
out vec3 normalVS;
|
out vec3 normalVS;
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
|
out vec4 materialColor;
|
||||||
|
|
||||||
|
uniform int color_mode;
|
||||||
|
uniform vec4 material_diffuse;
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
|
@ -15,4 +24,12 @@ void main()
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
normalVS = normalize(osg_NormalMatrix * normal);
|
normalVS = normalize(osg_NormalMatrix * normal);
|
||||||
texCoord = multiTexCoord0.st;
|
texCoord = multiTexCoord0.st;
|
||||||
|
|
||||||
|
// Legacy material handling
|
||||||
|
if (color_mode == MODE_DIFFUSE)
|
||||||
|
materialColor = vertexColor;
|
||||||
|
else if (color_mode == MODE_AMBIENT_AND_DIFFUSE)
|
||||||
|
materialColor = vertexColor;
|
||||||
|
else
|
||||||
|
materialColor = material_diffuse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,9 +149,9 @@ float getShadowing(vec3 p, vec3 n, float NdotL)
|
||||||
|
|
||||||
vec4 lightSpacePos[4];
|
vec4 lightSpacePos[4];
|
||||||
lightSpacePos[0] = getLightSpacePosition(p, n, NdotL, 0.05, fg_LightMatrix_csm0);
|
lightSpacePos[0] = getLightSpacePosition(p, n, NdotL, 0.05, fg_LightMatrix_csm0);
|
||||||
lightSpacePos[1] = getLightSpacePosition(p, n, NdotL, 0.2, fg_LightMatrix_csm1);
|
lightSpacePos[1] = getLightSpacePosition(p, n, NdotL, 0.1, fg_LightMatrix_csm1);
|
||||||
lightSpacePos[2] = getLightSpacePosition(p, n, NdotL, 1.0, fg_LightMatrix_csm2);
|
lightSpacePos[2] = getLightSpacePosition(p, n, NdotL, 0.5, fg_LightMatrix_csm2);
|
||||||
lightSpacePos[3] = getLightSpacePosition(p, n, NdotL, 5.0, fg_LightMatrix_csm3);
|
lightSpacePos[3] = getLightSpacePosition(p, n, NdotL, 1.0, fg_LightMatrix_csm3);
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
// Map-based cascade selection
|
// Map-based cascade selection
|
||||||
|
|
Loading…
Reference in a new issue