1
0
Fork 0

HDR pipeline: add placeholder shaders for WS 3.0

This commit is contained in:
Fernando García Liñán 2021-07-24 13:35:53 +02:00
parent 784c89dd61
commit 1215f1eba2
3 changed files with 188 additions and 0 deletions

View file

@ -671,4 +671,103 @@
</pass>
</technique>
<technique n="109">
<scheme>hdr-geometry</scheme>
<pass>
<blend><use>transparent</use></blend>
<alpha-test><use>transparent</use></alpha-test>
<shade-model>smooth</shade-model>
<cull-face>back</cull-face>
<render-bin>
<bin-number><use>render-bin/bin-number</use></bin-number>
<bin-name><use>render-bin/bin-name</use></bin-name>
</render-bin>
<!-- texture unit 0 direct from VPBBuilder.cxx -->
<texture-unit>
<unit>1</unit>
<image><use>texture[1]/image</use></image>
<filter>nearest-mipmap-nearest</filter>
<mag-filter>nearest-mipmap-nearest</mag-filter>
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
<internal-format><use>texture[0]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>2</unit>
<image><use>texture[2]/image</use></image>
<filter><use>texture[2]/filter</use></filter>
<wrap-s><use>texture[2]/wrap-s</use></wrap-s>
<wrap-t><use>texture[2]/wrap-t</use></wrap-t>
<internal-format><use>texture[2]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>3</unit>
<image><use>texture[3]/image</use></image>
<filter><use>texture[3]/filter</use></filter>
<wrap-s><use>texture[3]/wrap-s</use></wrap-s>
<wrap-t><use>texture[3]/wrap-t</use></wrap-t>
<internal-format><use>texture[3]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>4</unit>
<image><use>texture[4]/image</use></image>
<filter><use>texture[4]/filter</use></filter>
<wrap-s><use>texture[4]/wrap-s</use></wrap-s>
<wrap-t><use>texture[4]/wrap-t</use></wrap-t>
<internal-format><use>texture[4]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>6</unit>
<image><use>texture[6]/image</use></image>
<filter><use>texture[6]/filter</use></filter>
<wrap-s><use>texture[6]/wrap-s</use></wrap-s>
<wrap-t><use>texture[6]/wrap-t</use></wrap-t>
<internal-format><use>texture[6]/internal-format</use></internal-format>
</texture-unit>
<program>
<vertex-shader>Shaders/HDR/geometry.vert</vertex-shader>
<fragment-shader>Shaders/HDR/ws30.frag</fragment-shader>
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
</program>
<uniform>
<name>landclass</name>
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>atlas</name>
<type>sampler-2d</type>
<value type="int">1</value>
</uniform>
<uniform>
<name>dimensionsArray</name>
<type>sampler-1d</type>
<value type="int">2</value>
</uniform>
<uniform>
<name>diffuseArray</name>
<type>sampler-1d</type>
<value type="int">3</value>
</uniform>
<uniform>
<name>specularArray</name>
<type>sampler-1d</type>
<value type="int">4</value>
</uniform>
<uniform>
<name>perlin</name>
<type>sampler-2d</type>
<value type="int">6</value>
</uniform>
</pass>
</technique>
</PropertyList>

View file

@ -114,4 +114,39 @@
</texture-unit>
</pass>
</technique>
<technique n="109">
<scheme>hdr-geometry</scheme>
<pass>
<blend><use>transparent</use></blend>
<alpha-test><use>transparent</use></alpha-test>
<shade-model>smooth</shade-model>
<cull-face>back</cull-face>
<render-bin>
<bin-number><use>render-bin/bin-number</use></bin-number>
<bin-name><use>render-bin/bin-name</use></bin-name>
</render-bin>
<texture-unit>
<unit>0</unit>
<type>2d</type>
<image>Textures/Terrain/water.png</image>
<filter>linear-mipmap-linear</filter>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
<environment>
<mode>modulate</mode>
</environment>
</texture-unit>
<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>
</pass>
</technique>
</PropertyList>

54
Shaders/HDR/ws30.frag Normal file
View file

@ -0,0 +1,54 @@
#version 330 core
layout(location = 0) out vec4 gbuffer0;
layout(location = 1) out vec2 gbuffer1;
layout(location = 2) out vec4 gbuffer2;
in vec3 normalVS;
in vec2 texCoord;
uniform sampler2D landclass;
uniform sampler2DArray atlas;
uniform sampler1D dimensionsArray;
uniform sampler1D diffuseArray;
uniform sampler1D specularArray;
uniform sampler2D perlin;
// Passed from VPBTechnique, not the Effect
uniform float tile_width;
uniform float tile_height;
vec2 encodeNormal(vec3 n);
void main()
{
// The Landclass for this particular fragment. This can be used to
// index into the atlas textures.
int lc = int(texture(landclass, texCoord).g * 255.0 + 0.5);
// Different textures have different have different dimensions.
// Dimensions array is scaled to fit in [0...1.0] in the texture1D, so has to be scaled back up here.
vec4 color = texture(diffuseArray, float(lc)/512.0);
vec4 specular = texture(specularArray, float(lc)/512.0);
vec2 atlas_dimensions = 10000.0 * texture(dimensionsArray, float(lc)/512.0).st;
vec2 atlas_scale = vec2(tile_width / atlas_dimensions.s, tile_height / atlas_dimensions.t );
vec2 st = atlas_scale * texCoord;
// Rotate texture using the perlin texture as a mask to reduce tiling
if (step(0.5, texture(perlin, atlas_scale * texCoord / 8.0).r) == 1.0) {
st = vec2(atlas_scale.s * texCoord.t, atlas_scale.t * texCoord.s);
}
if (step(0.5, texture(perlin, - atlas_scale * texCoord / 16.0).r) == 1.0) {
st = -st;
}
vec3 texel = texture(atlas, vec3(st, lc)).rgb;
gbuffer0.rgb = pow(texel, vec3(2.2)); // Gamma correction
gbuffer0.a = 1.0;
gbuffer1 = encodeNormal(normalVS);
gbuffer2 = vec4(0.0, 0.9, 0.0, 0.0);
}