HDR: Add support for osgText
This commit is contained in:
parent
e8c75e7599
commit
7fc735b1de
3 changed files with 182 additions and 0 deletions
|
@ -20,4 +20,111 @@
|
|||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
|
||||
<technique n="129">
|
||||
<scheme>hdr-forward</scheme>
|
||||
<pass>
|
||||
<!-- Reverse floating point depth buffer -->
|
||||
<depth>
|
||||
<function>gequal</function>
|
||||
<near>1.0</near>
|
||||
<far>0.0</far>
|
||||
<write-mask>false</write-mask>
|
||||
</depth>
|
||||
<blend>1</blend>
|
||||
<rendering-hint>transparent</rendering-hint>
|
||||
<cull-face>back</cull-face>
|
||||
<program>
|
||||
<vertex-shader>Shaders/HDR/text.vert</vertex-shader>
|
||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||
<fragment-shader>Shaders/HDR/text.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/shadows.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/sun.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/atmos_spectral.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/clustered.glsl</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>glyph_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">0</value>
|
||||
</uniform>
|
||||
<!-- shadows.glsl -->
|
||||
<uniform>
|
||||
<name>shadow_tex</name>
|
||||
<type>sampler-2d-shadow</type>
|
||||
<value type="int">10</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>debug_shadow_cascades</name>
|
||||
<type>bool</type>
|
||||
<value><use>show-shadow-cascades</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>normal_bias</name>
|
||||
<type>float</type>
|
||||
<value><use>normal-bias</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>sss_enabled</name>
|
||||
<type>bool</type>
|
||||
<value><use>sss-enabled</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>sss_step_count</name>
|
||||
<type>int</type>
|
||||
<value><use>sss-step-count</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>sss_max_distance</name>
|
||||
<type>float</type>
|
||||
<value><use>sss-max-distance</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>sss_depth_bias</name>
|
||||
<type>float</type>
|
||||
<value><use>sss-depth-bias</use></value>
|
||||
</uniform>
|
||||
<!-- ibl.glsl -->
|
||||
<uniform>
|
||||
<name>dfg_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">8</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>prefiltered_envmap_tex</name>
|
||||
<type>sampler-cube</type>
|
||||
<value type="int">9</value>
|
||||
</uniform>
|
||||
<!-- aerial_perspective.glsl -->
|
||||
<uniform>
|
||||
<name>aerial_perspective_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">11</value>
|
||||
</uniform>
|
||||
<!-- sun.glsl -->
|
||||
<uniform>
|
||||
<name>transmittance_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">12</value>
|
||||
</uniform>
|
||||
<!-- exposure.glsl -->
|
||||
<uniform>
|
||||
<name>lum_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">14</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>exposure_compensation</name>
|
||||
<type>float</type>
|
||||
<value><use>exposure-compensation</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
||||
|
|
44
Shaders/HDR/text.frag
Normal file
44
Shaders/HDR/text.frag
Normal file
|
@ -0,0 +1,44 @@
|
|||
#version 330 core
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
in VS_OUT {
|
||||
vec2 texcoord;
|
||||
vec3 vertex_normal;
|
||||
vec3 view_vector;
|
||||
vec4 ap_color;
|
||||
} fs_in;
|
||||
|
||||
uniform sampler2D glyph_tex;
|
||||
|
||||
uniform mat4 osg_ViewMatrixInverse;
|
||||
uniform vec4 fg_Viewport;
|
||||
|
||||
// XXX: We should be able to modify these through material animations
|
||||
const vec3 TEXT_BASE_COLOR = vec3(1.0);
|
||||
const float TEXT_METALLIC = 0.0;
|
||||
const float TEXT_ROUGHNESS = 1.0;
|
||||
const vec3 TEXT_EMISSION = vec3(1.0);
|
||||
|
||||
// color.glsl
|
||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||
// shading_transparent.glsl
|
||||
vec3 eval_lights_transparent(
|
||||
vec3 base_color, float metallic, float roughness, float occlusion,
|
||||
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
|
||||
mat4 view_matrix_inverse);
|
||||
|
||||
void main()
|
||||
{
|
||||
float alpha = texture(glyph_tex, fs_in.texcoord).a;
|
||||
|
||||
vec3 N = normalize(fs_in.vertex_normal);
|
||||
vec3 V = normalize(-fs_in.view_vector);
|
||||
vec2 uv = (gl_FragCoord.xy - fg_Viewport.xy) / fg_Viewport.zw;
|
||||
|
||||
vec3 color = eval_lights_transparent(
|
||||
TEXT_BASE_COLOR, TEXT_METALLIC, TEXT_ROUGHNESS, 1.0, TEXT_EMISSION,
|
||||
fs_in.view_vector, N, V, uv, fs_in.ap_color, osg_ViewMatrixInverse);
|
||||
|
||||
fragColor = vec4(color, alpha);
|
||||
}
|
31
Shaders/HDR/text.vert
Normal file
31
Shaders/HDR/text.vert
Normal file
|
@ -0,0 +1,31 @@
|
|||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec4 pos;
|
||||
layout(location = 1) in vec3 normal;
|
||||
layout(location = 3) in vec4 multitexcoord0;
|
||||
|
||||
out VS_OUT {
|
||||
vec2 texcoord;
|
||||
vec3 vertex_normal;
|
||||
vec3 view_vector;
|
||||
vec4 ap_color;
|
||||
} vs_out;
|
||||
|
||||
uniform mat4 osg_ModelViewMatrix;
|
||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||
uniform mat3 osg_NormalMatrix;
|
||||
uniform mat4 fg_TextureMatrix;
|
||||
|
||||
// aerial_perspective.glsl
|
||||
vec4 get_aerial_perspective(vec2 coord, float depth);
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
||||
|
||||
vec2 coord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
|
||||
vs_out.ap_color = get_aerial_perspective(coord, length(vs_out.view_vector));
|
||||
}
|
Loading…
Add table
Reference in a new issue