mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
* Add load parameter support to RSIs. Currently only supports turning sRGB off. RSIs with custom load parameters are not thrown into the meta-atlas. As part of this, TextureLoadParameters and TextureSampleParameters has been made to support equality. * Add UV2 channel to vertices. This is a bad hack to make displacement maps work in Robust. The UV2 channel goes from 0 -> 1 across the draw and can therefore be used by displacement maps to map a separate displacement map layer on top of the regular meta-atlas RSI texture. This creates float inaccuracy issues but they weren't bad enough to completely void the feature. I'm thinking I learn from this experience and completely re-do how UVs work with the renderer rewrite, so that hopefully won't happen anymore. This required dumping the optimized PadVerticesV2 because the changed struct size made it impractical. RIP. I don't like this approach at all but the renderer is slated for a rewrite anyways, and all shaders will need to be rewritten regardless. * Add CopyToShaderParameters for sprite layers. This effectively allows copying the parameters of a sprite layer into another layer's shader parameters. The use case is to copy texture coordinates for displacement maps, as the exact map used changes depending on orientation. It also enables animations to be used though I didn't use that personally.
44 lines
1.1 KiB
GLSL
44 lines
1.1 KiB
GLSL
// Vertex position.
|
|
/*layout (location = 0)*/ attribute vec2 aPos;
|
|
// Texture coordinates.
|
|
/*layout (location = 1)*/ attribute vec2 tCoord;
|
|
/*layout (location = 2)*/ attribute vec2 tCoord2;
|
|
// Colour modulation.
|
|
/*layout (location = 3)*/ attribute vec4 modulate;
|
|
|
|
varying vec2 UV;
|
|
varying vec2 UV2;
|
|
varying vec2 Pos;
|
|
varying vec4 VtxModulate;
|
|
|
|
// Maybe we should merge these CPU side.
|
|
// idk yet.
|
|
uniform mat3 modelMatrix;
|
|
|
|
// Allows us to do texture atlassing with texture coordinates 0->1
|
|
// Input texture coordinates get mapped to this range.
|
|
uniform vec4 modifyUV;
|
|
|
|
// [SHADER_HEADER_CODE]
|
|
|
|
void main()
|
|
{
|
|
vec3 transformed = projectionMatrix * viewMatrix * modelMatrix * vec3(aPos, 1.0);
|
|
vec2 VERTEX = transformed.xy;
|
|
|
|
// [SHADER_CODE]
|
|
|
|
// Pixel snapping to avoid sampling issues on nvidia.
|
|
VERTEX += 1.0;
|
|
VERTEX /= SCREEN_PIXEL_SIZE*2.0;
|
|
VERTEX = floor(VERTEX + 0.5);
|
|
VERTEX *= SCREEN_PIXEL_SIZE*2.0;
|
|
VERTEX -= 1.0;
|
|
|
|
gl_Position = vec4(VERTEX, 0.0, 1.0);
|
|
Pos = (VERTEX + 1.0) / 2.0;
|
|
UV = mix(modifyUV.xy, modifyUV.zw, tCoord);
|
|
UV2 = tCoord2;
|
|
VtxModulate = zFromSrgb(modulate);
|
|
}
|