mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 12:24:56 +00:00
Huge shader refactor
This commit is contained in:
125
Shaders/CAABoxShader.shader
Normal file
125
Shaders/CAABoxShader.shader
Normal file
@@ -0,0 +1,125 @@
|
||||
#shader CAABoxShader
|
||||
#attribute position4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#culling none
|
||||
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
|
||||
UBINDING0 uniform CAABoxUniform
|
||||
{
|
||||
mat4 xf;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
gl_Position = xf * vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
};
|
||||
|
||||
cbuffer CAABoxUniform : register(b0)
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.pos = mul(xf, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
};
|
||||
|
||||
struct CAABoxUniform
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant CAABoxUniform& bu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = bu.color;
|
||||
vtf.pos = bu.xf * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
"struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#shader CAABoxShaderZOnly : CAABoxShader
|
||||
#colorwrite false
|
||||
242
Shaders/CCameraBlurFilter.shader
Normal file
242
Shaders/CCameraBlurFilter.shader
Normal file
@@ -0,0 +1,242 @@
|
||||
#shader CCameraBlurFilter
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform CameraBlurUniform
|
||||
{
|
||||
vec4 uv0;
|
||||
vec4 uv1;
|
||||
vec4 uv2;
|
||||
vec4 uv3;
|
||||
vec4 uv4;
|
||||
vec4 uv5;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 uvReg;
|
||||
vec2 uv0;
|
||||
vec2 uv1;
|
||||
vec2 uv2;
|
||||
vec2 uv3;
|
||||
vec2 uv4;
|
||||
vec2 uv5;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.uvReg = uvIn.xy;
|
||||
vtf.uv0 = uv0.xy + uvIn.xy;
|
||||
vtf.uv1 = uv1.xy + uvIn.xy;
|
||||
vtf.uv2 = uv2.xy + uvIn.xy;
|
||||
vtf.uv3 = uv3.xy + uvIn.xy;
|
||||
vtf.uv4 = uv4.xy + uvIn.xy;
|
||||
vtf.uv5 = uv5.xy + uvIn.xy;
|
||||
vtf.opacity = opacity;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 uvReg;
|
||||
vec2 uv0;
|
||||
vec2 uv1;
|
||||
vec2 uv2;
|
||||
vec2 uv3;
|
||||
vec2 uv4;
|
||||
vec2 uv5;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D sceneTex;
|
||||
void main()
|
||||
{
|
||||
vec4 colorSample = texture(sceneTex, vtf.uvReg) * 0.14285715;
|
||||
colorSample += texture(sceneTex, vtf.uv0) * 0.14285715;
|
||||
colorSample += texture(sceneTex, vtf.uv1) * 0.14285715;
|
||||
colorSample += texture(sceneTex, vtf.uv2) * 0.14285715;
|
||||
colorSample += texture(sceneTex, vtf.uv3) * 0.14285715;
|
||||
colorSample += texture(sceneTex, vtf.uv4) * 0.14285715;
|
||||
colorSample += texture(sceneTex, vtf.uv5) * 0.14285715;
|
||||
colorOut = vec4(colorSample.rgb, vtf.opacity);
|
||||
}
|
||||
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer CameraBlurUniform : register(b0)
|
||||
{
|
||||
float4 uv0;
|
||||
float4 uv1;
|
||||
float4 uv2;
|
||||
float4 uv3;
|
||||
float4 uv4;
|
||||
float4 uv5;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uvReg : UV6;
|
||||
float2 uv0 : UV0;
|
||||
float2 uv1 : UV1;
|
||||
float2 uv2 : UV2;
|
||||
float2 uv3 : UV3;
|
||||
float2 uv4 : UV4;
|
||||
float2 uv5 : UV5;
|
||||
float opacity : OPACITY;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uvReg = v.uvIn.xy;
|
||||
vtf.uvReg.y = 1.0 - vtf.uvReg.y;
|
||||
vtf.uv0 = uv0.xy + v.uvIn.xy;
|
||||
vtf.uv0.y = 1.0 - vtf.uv0.y;
|
||||
vtf.uv1 = uv1.xy + v.uvIn.xy;
|
||||
vtf.uv1.y = 1.0 - vtf.uv1.y;
|
||||
vtf.uv2 = uv2.xy + v.uvIn.xy;
|
||||
vtf.uv2.y = 1.0 - vtf.uv2.y;
|
||||
vtf.uv3 = uv3.xy + v.uvIn.xy;
|
||||
vtf.uv3.y = 1.0 - vtf.uv3.y;
|
||||
vtf.uv4 = uv4.xy + v.uvIn.xy;
|
||||
vtf.uv4.y = 1.0 - vtf.uv4.y;
|
||||
vtf.uv5 = uv5.xy + v.uvIn.xy;
|
||||
vtf.uv5.y = 1.0 - vtf.uv5.y;
|
||||
vtf.opacity = opacity;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
Texture2D sceneTex : register(t0);
|
||||
SamplerState samp : register(s0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uvReg : UV6;
|
||||
float2 uv0 : UV0;
|
||||
float2 uv1 : UV1;
|
||||
float2 uv2 : UV2;
|
||||
float2 uv3 : UV3;
|
||||
float2 uv4 : UV4;
|
||||
float2 uv5 : UV5;
|
||||
float opacity : OPACITY;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float4 colorSample = sceneTex.Sample(samp, vtf.uvReg) * 0.14285715;
|
||||
colorSample += sceneTex.Sample(samp, vtf.uv0) * 0.14285715;
|
||||
colorSample += sceneTex.Sample(samp, vtf.uv1) * 0.14285715;
|
||||
colorSample += sceneTex.Sample(samp, vtf.uv2) * 0.14285715;
|
||||
colorSample += sceneTex.Sample(samp, vtf.uv3) * 0.14285715;
|
||||
colorSample += sceneTex.Sample(samp, vtf.uv4) * 0.14285715;
|
||||
colorSample += sceneTex.Sample(samp, vtf.uv5) * 0.14285715;
|
||||
return float4(colorSample.rgb, vtf.opacity);
|
||||
}
|
||||
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct CameraBlurUniform
|
||||
{
|
||||
float4 uv0;
|
||||
float4 uv1;
|
||||
float4 uv2;
|
||||
float4 uv3;
|
||||
float4 uv4;
|
||||
float4 uv5;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 uvReg;
|
||||
float2 uv0;
|
||||
float2 uv1;
|
||||
float2 uv2;
|
||||
float2 uv3;
|
||||
float2 uv4;
|
||||
float2 uv5;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant CameraBlurUniform& cbu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uvReg = v.uvIn.xy;
|
||||
vtf.uvReg.y = 1.0 - vtf.uvReg.y;
|
||||
vtf.uv0 = cbu.uv0.xy + v.uvIn.xy;
|
||||
vtf.uv0.y = 1.0 - vtf.uv0.y;
|
||||
vtf.uv1 = cbu.uv1.xy + v.uvIn.xy;
|
||||
vtf.uv1.y = 1.0 - vtf.uv1.y;
|
||||
vtf.uv2 = cbu.uv2.xy + v.uvIn.xy;
|
||||
vtf.uv2.y = 1.0 - vtf.uv2.y;
|
||||
vtf.uv3 = cbu.uv3.xy + v.uvIn.xy;
|
||||
vtf.uv3.y = 1.0 - vtf.uv3.y;
|
||||
vtf.uv4 = cbu.uv4.xy + v.uvIn.xy;
|
||||
vtf.uv4.y = 1.0 - vtf.uv4.y;
|
||||
vtf.uv5 = cbu.uv5.xy + v.uvIn.xy;
|
||||
vtf.uv5.y = 1.0 - vtf.uv5.y;
|
||||
vtf.opacity = cbu.opacity;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 uvReg;
|
||||
float2 uv0;
|
||||
float2 uv1;
|
||||
float2 uv2;
|
||||
float2 uv3;
|
||||
float2 uv4;
|
||||
float2 uv5;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]], sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> sceneTex [[ texture(0) ]])
|
||||
{
|
||||
float4 colorSample = sceneTex.sample(samp, vtf.uvReg) * 0.14285715;
|
||||
colorSample += sceneTex.sample(samp, vtf.uv0) * 0.14285715;
|
||||
colorSample += sceneTex.sample(samp, vtf.uv1) * 0.14285715;
|
||||
colorSample += sceneTex.sample(samp, vtf.uv2) * 0.14285715;
|
||||
colorSample += sceneTex.sample(samp, vtf.uv3) * 0.14285715;
|
||||
colorSample += sceneTex.sample(samp, vtf.uv4) * 0.14285715;
|
||||
colorSample += sceneTex.sample(samp, vtf.uv5) * 0.14285715;
|
||||
return float4(colorSample.rgb, vtf.opacity);
|
||||
}
|
||||
130
Shaders/CColoredQuadFilter.shader
Normal file
130
Shaders/CColoredQuadFilter.shader
Normal file
@@ -0,0 +1,130 @@
|
||||
#shader CColoredQuadFilter
|
||||
#attribute position4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
|
||||
UBINDING0 uniform ColoredQuadUniform
|
||||
{
|
||||
mat4 xf;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
gl_Position = xf * vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
};
|
||||
|
||||
cbuffer ColoredQuadUniform : register(b0)
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.position = mul(xf, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
};
|
||||
|
||||
struct ColoredQuadUniform
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ColoredQuadUniform& cqu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = cqu.color;
|
||||
vtf.position = cqu.xf * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#shader CColoredQuadFilterAdd : CColoredQuadFilter
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CColoredQuadFilterMul : CColoredQuadFilter
|
||||
#srcfac zero
|
||||
#dstfac srccolor
|
||||
346
Shaders/CDecalShaders.shader
Normal file
346
Shaders/CDecalShaders.shader
Normal file
@@ -0,0 +1,346 @@
|
||||
#shader CDecalShaderTexZTest
|
||||
#instattribute position4 0
|
||||
#instattribute position4 1
|
||||
#instattribute position4 2
|
||||
#instattribute position4 3
|
||||
#instattribute color
|
||||
#instattribute uv4 0
|
||||
#instattribute uv4 1
|
||||
#instattribute uv4 2
|
||||
#instattribute uv4 3
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
layout(location=4) in vec4 colorIn;
|
||||
layout(location=5) in vec4 uvsIn[4];
|
||||
|
||||
UBINDING0 uniform DecalUniform
|
||||
{
|
||||
mat4 mvp;
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = colorIn * moduColor;
|
||||
vtf.uv = uvsIn[gl_VertexID].xy;
|
||||
gl_Position = mvp * posIn[gl_VertexID];
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
}
|
||||
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 colorIn : COLOR;
|
||||
float4 uvsIn[4] : UV;
|
||||
};
|
||||
|
||||
cbuffer DecalUniform : register(b0)
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.uv = v.uvsIn[vertId].xy;
|
||||
vtf.position = mul(mvp, v.posIn[vertId]);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex0 : register(t0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex0.Sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 colorIn;
|
||||
float4 uvsIn[4];
|
||||
};
|
||||
|
||||
struct DecalUniform
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant DecalUniform& decal [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[instId];
|
||||
vtf.color = v.colorIn * decal.moduColor;
|
||||
vtf.uv = v.uvsIn[vertId].xy;
|
||||
vtf.position = decal.mvp * v.posIn[vertId];
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex0.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
|
||||
#shader CDecalShaderTexAdditiveZTest : CDecalShaderTexZTest
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CDecalShaderTexRedToAlphaZTest : CDecalShaderTexZTest
|
||||
#srcfac one
|
||||
#dstfac one
|
||||
#alphawrite true
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
colorOut.a = texture(tex, vtf.uv).r;
|
||||
}
|
||||
|
||||
|
||||
#fragment hlsl
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex0 : register(t0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return float4(vtf.color.rgb, tex0.Sample(samp, vtf.uv).r);
|
||||
}
|
||||
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]])
|
||||
{
|
||||
return float4(vtf.color.rgb, tex0.sample(samp, vtf.uv).r);
|
||||
}
|
||||
|
||||
|
||||
#shader CDecalShaderNoTexZTest
|
||||
#instattribute position4 0
|
||||
#instattribute position4 1
|
||||
#instattribute position4 2
|
||||
#instattribute position4 3
|
||||
#instattribute color
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
layout(location=4) in vec4 colorIn;
|
||||
|
||||
UBINDING0 uniform DecalUniform
|
||||
{
|
||||
mat4 mvp;
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = colorIn * moduColor;
|
||||
gl_Position = mvp * posIn[gl_VertexID];
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 colorIn : COLOR;
|
||||
};
|
||||
|
||||
cbuffer DecalUniform : register(b0)
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.position = mul(mvp, v.posIn[vertId]);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 colorIn;
|
||||
};
|
||||
|
||||
struct DecalUniform
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant DecalUniform& decal [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[instId];
|
||||
vtf.color = v.colorIn * decal.moduColor;
|
||||
vtf.position = decal.mvp * v.posIn[vertId];
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#shader CDecalShaderNoTexAdditiveZTest : CDecalShaderNoTexZTest
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
687
Shaders/CElementGenShaders.shader
Normal file
687
Shaders/CElementGenShaders.shader
Normal file
@@ -0,0 +1,687 @@
|
||||
#shader CElementGenShaderTexZTestZWrite
|
||||
#instattribute position4 0
|
||||
#instattribute position4 1
|
||||
#instattribute position4 2
|
||||
#instattribute position4 3
|
||||
#instattribute color
|
||||
#instattribute uv4 0
|
||||
#instattribute uv4 1
|
||||
#instattribute uv4 2
|
||||
#instattribute uv4 3
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
layout(location=4) in vec4 colorIn;
|
||||
layout(location=5) in vec4 uvsIn[4];
|
||||
|
||||
UBINDING0 uniform ParticleUniform
|
||||
{
|
||||
mat4 mvp;
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vec4 pos = posIn[gl_VertexID];
|
||||
vtf.color = colorIn * moduColor;
|
||||
vtf.uv = uvsIn[gl_VertexID].xy;
|
||||
gl_Position = mvp * pos;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 colorIn : COLOR;
|
||||
float4 uvsIn[4] : UV;
|
||||
};
|
||||
|
||||
cbuffer ParticleUniform : register(b0)
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.uv = v.uvsIn[vertId].xy;
|
||||
vtf.position = mul(mvp, v.posIn[vertId]);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex0 : register(t0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex0.Sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 colorIn;
|
||||
float4 uvsIn[4];
|
||||
};
|
||||
|
||||
struct ParticleUniform
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant ParticleUniform& particle [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[instId];
|
||||
vtf.color = v.colorIn * particle.moduColor;
|
||||
vtf.uv = v.uvsIn[vertId].xy;
|
||||
vtf.position = particle.mvp * v.posIn[vertId];
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex0.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#shader CElementGenShaderTexNoZTestZWrite : CElementGenShaderTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
|
||||
#shader CElementGenShaderTexZTestNoZWrite : CElementGenShaderTexZTestZWrite
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderTexNoZTestNoZWrite : CElementGenShaderTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderTexAdditiveZTest : CElementGenShaderTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderTexAdditiveNoZTest : CElementGenShaderTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderTexZTestNoZWriteSub : CElementGenShaderTexZTestZWrite
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderTexNoZTestNoZWriteSub : CElementGenShaderTexZTestZWrite
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaZTest : CElementGenShaderTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
colorOut.a = texture(tex, vtf.uv).r;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex0 : register(t0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return float4(vtf.color.rgb, tex0.Sample(samp, vtf.uv).r);
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]])
|
||||
{
|
||||
return float4(vtf.color.rgb, tex0.sample(samp, vtf.uv).r);
|
||||
}
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaNoZTest : CElementGenShaderTexRedToAlphaZTest
|
||||
#depthtest none
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaZTestSub : CElementGenShaderTexRedToAlphaZTest
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest lequal
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaNoZTestSub : CElementGenShaderTexRedToAlphaZTest
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest none
|
||||
|
||||
#shader CElementGenShaderIndTexZWrite
|
||||
#instattribute position4 0
|
||||
#instattribute position4 1
|
||||
#instattribute position4 2
|
||||
#instattribute position4 3
|
||||
#instattribute color
|
||||
#instattribute uv4 0
|
||||
#instattribute uv4 1
|
||||
#instattribute uv4 2
|
||||
#instattribute uv4 3
|
||||
#instattribute uv4 4
|
||||
#instattribute uv4 5
|
||||
#instattribute uv4 6
|
||||
#instattribute uv4 7
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
layout(location=4) in vec4 colorIn;
|
||||
layout(location=5) in vec4 uvsInTexrTind[4];
|
||||
layout(location=9) in vec4 uvsInScene;
|
||||
|
||||
UBINDING0 uniform ParticleUniform
|
||||
{
|
||||
mat4 mvp;
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec4 uvScene;
|
||||
vec2 uvTexr;
|
||||
vec2 uvTind;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vec4 pos = posIn[gl_VertexID];
|
||||
vtf.color = colorIn * moduColor;
|
||||
vtf.uvScene = uvsInScene;
|
||||
vtf.uvTexr = uvsInTexrTind[gl_VertexID].xy;
|
||||
vtf.uvTind = uvsInTexrTind[gl_VertexID].zw;
|
||||
gl_Position = mvp * pos;
|
||||
gl_Position = FLIPFROMGL(gl_Position);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec4 uvScene;
|
||||
vec2 uvTexr;
|
||||
vec2 uvTind;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D texrMap;
|
||||
TBINDING1 uniform sampler2D sceneMap;
|
||||
TBINDING2 uniform sampler2D tindMap;
|
||||
void main()
|
||||
{
|
||||
vec2 tindTexel = texture(tindMap, vtf.uvTind).zw;
|
||||
vec4 sceneTexel = texture(sceneMap, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));
|
||||
vec4 texrTexel = texture(texrMap, vtf.uvTexr);
|
||||
colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) + texrTexel;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 colorIn : COLOR;
|
||||
float4 uvsInTexrTind[4] : UV0;
|
||||
float4 uvsInScene : UV4;
|
||||
};
|
||||
|
||||
cbuffer ParticleUniform : register(b0)
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float4 uvScene : UV0;
|
||||
float2 uvTexr : UV1;
|
||||
float2 uvTind : UV2;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.uvScene = v.uvsInScene;
|
||||
vtf.uvScene.y = 1.0 - vtf.uvScene.y;
|
||||
vtf.uvScene.w = 1.0 - vtf.uvScene.w;
|
||||
vtf.uvTexr = v.uvsInTexrTind[vertId].xy;
|
||||
vtf.uvTind = v.uvsInTexrTind[vertId].zw;
|
||||
vtf.position = mul(mvp, v.posIn[vertId]);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex0 : register(t0);
|
||||
Texture2D tex1 : register(t1);
|
||||
Texture2D tex2 : register(t2);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float4 uvScene : UV0;
|
||||
float2 uvTexr : UV1;
|
||||
float2 uvTind : UV2;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float2 tindTexel = tex2.Sample(samp, vtf.uvTind).zw;
|
||||
float4 sceneTexel = tex1.Sample(samp, lerp(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));
|
||||
float4 texrTexel = tex0.Sample(samp, vtf.uvTexr);
|
||||
float4 colorOut = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;
|
||||
colorOut.a = vtf.color.a * texrTexel.a;
|
||||
return colorOut;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 colorIn;
|
||||
float4 uvsInTexrTind[4];
|
||||
float4 uvsInScene;
|
||||
};
|
||||
|
||||
struct ParticleUniform
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float4 uvScene;
|
||||
float2 uvTexr;
|
||||
float2 uvTind;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant ParticleUniform& particle [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[instId];
|
||||
vtf.color = v.colorIn * particle.moduColor;
|
||||
vtf.uvScene = v.uvsInScene;
|
||||
vtf.uvScene.y = 1.0 - vtf.uvScene.y;
|
||||
vtf.uvScene.w = 1.0 - vtf.uvScene.w;
|
||||
vtf.uvTexr = v.uvsInTexrTind[vertId].xy;
|
||||
vtf.uvTind = v.uvsInTexrTind[vertId].zw;
|
||||
vtf.position = particle.mvp * v.posIn[vertId];
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float4 uvScene;
|
||||
float2 uvTexr;
|
||||
float2 uvTind;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],"
|
||||
texture2d<float> tex0 [[ texture(0) ]],
|
||||
texture2d<float> tex1 [[ texture(1) ]],
|
||||
texture2d<float> tex2 [[ texture(2) ]])
|
||||
{
|
||||
float2 tindTexel = tex2.sample(samp, vtf.uvTind).ba;
|
||||
float4 sceneTexel = tex1.sample(samp, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));
|
||||
float4 texrTexel = tex0.sample(samp, vtf.uvTexr);
|
||||
float4 colr = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;
|
||||
return float4(colr.rgb, vtf.color.a * texrTexel.a);"
|
||||
}
|
||||
|
||||
#shader CElementGenShaderIndTexNoZWrite : CElementGenShaderIndTexZWrite
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderIndTexAdditive : CElementGenShaderIndTexZWrite
|
||||
#depthwrite true
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CElementGenShaderCindTexZWrite : CElementGenShaderIndTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec4 uvScene;
|
||||
vec2 uvTexr;
|
||||
vec2 uvTind;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D texrMap;
|
||||
TBINDING1 uniform sampler2D sceneMap;
|
||||
TBINDING2 uniform sampler2D tindMap;
|
||||
void main()
|
||||
{
|
||||
vec2 tindTexel = texture(tindMap, vtf.uvTind).zw;
|
||||
vec4 sceneTexel = texture(sceneMap, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));
|
||||
colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) * texture(texrMap, vtf.uvTexr);
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex0 : register(t0);
|
||||
Texture2D tex1 : register(t1);
|
||||
Texture2D tex2 : register(t2);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float4 uvScene : UV0;
|
||||
float2 uvTexr : UV1;
|
||||
float2 uvTind : UV2;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float2 tindTexel = tex2.Sample(samp, vtf.uvTind).ba;
|
||||
float4 sceneTexel = tex1.Sample(samp, lerp(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));
|
||||
return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.Sample(samp, vtf.uvTexr);
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float4 uvScene;
|
||||
float2 uvTexr;
|
||||
float2 uvTind;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]],
|
||||
texture2d<float> tex1 [[ texture(1) ]],
|
||||
texture2d<float> tex2 [[ texture(2) ]])
|
||||
{
|
||||
float2 tindTexel = tex2.sample(samp, vtf.uvTind).ba;
|
||||
float4 sceneTexel = tex1.sample(samp, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));
|
||||
return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.sample(samp, vtf.uvTexr);
|
||||
}
|
||||
|
||||
#shader CElementGenShaderCindTexNoZWrite : CElementGenShaderCindTexZWrite
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderCindTexAdditive : CElementGenShaderCindTexZWrite
|
||||
#depthwrite true
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CElementGenShaderNoTexZTestZWrite
|
||||
#instattribute position4 0
|
||||
#instattribute position4 1
|
||||
#instattribute position4 2
|
||||
#instattribute position4 3
|
||||
#instattribute color
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
layout(location=4) in vec4 colorIn;
|
||||
|
||||
UBINDING0 uniform ParticleUniform
|
||||
{
|
||||
mat4 mvp;
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vec4 pos = posIn[gl_VertexID];
|
||||
vtf.color = colorIn * moduColor;
|
||||
gl_Position = mvp * pos;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 colorIn : COLOR;
|
||||
};
|
||||
|
||||
cbuffer ParticleUniform : register(b0)
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.position = mul(mvp, v.posIn[vertId]);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 colorIn;
|
||||
};
|
||||
|
||||
struct ParticleUniform
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant ParticleUniform& particle [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[instId];
|
||||
vtf.color = v.colorIn * particle.moduColor;
|
||||
vtf.position = particle.mvp * v.posIn[vertId];
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#shader CElementGenShaderNoTexNoZTestZWrite : CElementGenShaderNoTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
|
||||
#shader CElementGenShaderNoTexZTestNoZWrite : CElementGenShaderNoTexZTestZWrite
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderNoTexNoZTestNoZWrite : CElementGenShaderNoTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderNoTexAdditiveZTest : CElementGenShaderNoTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
|
||||
#shader CElementGenShaderNoTexAdditiveNoZTest : CElementGenShaderNoTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
138
Shaders/CEnergyBarShader.shader
Normal file
138
Shaders/CEnergyBarShader.shader
Normal file
@@ -0,0 +1,138 @@
|
||||
#shader CEnergyBarShader
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform EnergyBarUniform
|
||||
{
|
||||
mat4 xf;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
vtf.uv = uvIn.xy;
|
||||
gl_Position = xf * vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer EnergyBarUniform : register(b0)
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.position = mul(xf, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
Texture2D tex : register(t0);
|
||||
SamplerState samp : register(s0);
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex.Sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct EnergyBarUniform
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant EnergyBarUniform& ebu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = ebu.color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.position = ebu.xf * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
235
Shaders/CFogVolumeFilter.shader
Normal file
235
Shaders/CFogVolumeFilter.shader
Normal file
@@ -0,0 +1,235 @@
|
||||
#shader CFogVolumeFilter1Way
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac dstalpha
|
||||
#dstfac one
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec2 uvIn;
|
||||
|
||||
UBINDING0 uniform FogVolumeFilterUniform
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(posIn.xy, 0.0, 1.0);
|
||||
vtf.color = color;
|
||||
vtf.uv = uvIn;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D zFrontfaceTex;
|
||||
TBINDING1 uniform sampler2D zBackfaceTex;
|
||||
TBINDING2 uniform sampler2D zLinearizer;
|
||||
void main()
|
||||
{
|
||||
float y;
|
||||
const float linScale = 65535.0 / 65536.0 * 256.0;
|
||||
float x = modf(texture(zFrontfaceTex, vtf.uv).r * linScale, y);
|
||||
const float uvBias = 0.5 / 256.0;
|
||||
float alpha = texture(zLinearizer, vec2(x * 255.0 / 256.0 + uvBias, y / 256.0 + uvBias)).r * 10.0;
|
||||
colorOut = vtf.color * alpha;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float2 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer FogVolumeFilterUniform : register(b0)
|
||||
{
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.position = float4(v.posIn.x, -v.posIn.y, 0.0, 1.0);
|
||||
vtf.color = color;
|
||||
vtf.uv = v.uvIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
Texture2D zFrontfaceTex : register(t0);
|
||||
Texture2D zBackfaceTex : register(t1);
|
||||
Texture2D zLinearizer : register(t2);
|
||||
SamplerState samp : register(s0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float y;
|
||||
const float linScale = 65535.0 / 65536.0 * 256.0;
|
||||
float x = modf((1.0 - zFrontfaceTex.Sample(samp, vtf.uv).r) * linScale, y);
|
||||
const float uvBias = 0.5 / 256.0;
|
||||
float alpha = zLinearizer.Sample(samp, float2(x * 255.0 / 256.0 + uvBias, y / 256.0 + uvBias)).r * 10.0;
|
||||
return vtf.color * alpha;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float2 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct FogVolumeFilterUniform
|
||||
{
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]],
|
||||
constant FogVolumeFilterUniform& fu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.pos = float4(v.posIn.x, -v.posIn.y, 0.0, 1.0);
|
||||
vtf.color = fu.color;
|
||||
vtf.uv = v.uvIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> zFrontfaceTex [[ texture(0) ]],
|
||||
texture2d<float> zBackfaceTex [[ texture(1) ]],
|
||||
texture2d<float> zLinearizer [[ texture(2) ]])
|
||||
{
|
||||
float y;
|
||||
const float linScale = 65535.0 / 65536.0 * 256.0;
|
||||
float x = modf((1.0 - zFrontfaceTex.sample(samp, vtf.uv).r) * linScale, y);
|
||||
const float uvBias = 0.5 / 256.0;
|
||||
float alpha = zLinearizer.sample(samp, float2(x * 255.0 / 256.0 + uvBias, y / 256.0 + uvBias)).r * 10.0;
|
||||
return vtf.color * alpha;
|
||||
}
|
||||
|
||||
|
||||
#shader CFogVolumeFilter2Way : CFogVolumeFilter1Way
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D zFrontfaceTex;
|
||||
TBINDING1 uniform sampler2D zBackfaceTex;
|
||||
TBINDING2 uniform sampler2D zLinearizer;
|
||||
void main()
|
||||
{
|
||||
float frontY;
|
||||
float backY;
|
||||
const float linScale = 65535.0 / 65536.0 * 256.0;
|
||||
float frontX = modf(texture(zFrontfaceTex, vtf.uv).r * linScale, frontY);
|
||||
float backX = modf(texture(zBackfaceTex, vtf.uv).r * linScale, backY);
|
||||
const float uvBias = 0.5 / 256.0;
|
||||
float frontLin = texture(zLinearizer, vec2(frontX * 255.0 / 256.0 + uvBias, frontY / 256.0 + uvBias)).r;
|
||||
float backLin = texture(zLinearizer, vec2(backX * 255.0 / 256.0 + uvBias, backY / 256.0 + uvBias)).r;
|
||||
colorOut = vec4(vtf.color.rgb, (frontLin - backLin) * 10.0);
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
Texture2D zFrontfaceTex : register(t0);
|
||||
Texture2D zBackfaceTex : register(t1);
|
||||
Texture2D zLinearizer : register(t2);
|
||||
SamplerState samp : register(s0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float frontY;
|
||||
float backY;
|
||||
const float linScale = 65535.0 / 65536.0 * 256.0;
|
||||
float frontX = modf((1.0 - zFrontfaceTex.Sample(samp, vtf.uv).r) * linScale, frontY);
|
||||
float backX = modf((1.0 - zBackfaceTex.Sample(samp, vtf.uv).r) * linScale, backY);
|
||||
const float uvBias = 0.5 / 256.0;
|
||||
float frontLin = zLinearizer.Sample(samp, float2(frontX * 255.0 / 256.0 + uvBias, frontY / 256.0 + uvBias)).r;
|
||||
float backLin = zLinearizer.Sample(samp, float2(backX * 255.0 / 256.0 + uvBias, backY / 256.0 + uvBias)).r;
|
||||
return float4(vtf.color.rgb, (frontLin - backLin) * 10.0);
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> zFrontfaceTex [[ texture(0) ]],
|
||||
texture2d<float> zBackfaceTex [[ texture(1) ]],
|
||||
texture2d<float> zLinearizer [[ texture(2) ]])
|
||||
{
|
||||
float frontY;
|
||||
float backY;
|
||||
const float linScale = 65535.0 / 65536.0 * 256.0;
|
||||
float frontX = modf((1.0 - zFrontfaceTex.sample(samp, vtf.uv).r) * linScale, frontY);
|
||||
float backX = modf((1.0 - zBackfaceTex.sample(samp, vtf.uv).r) * linScale, backY);
|
||||
const float uvBias = 0.5 / 256.0;
|
||||
float frontLin = zLinearizer.sample(samp, float2(frontX * 255.0 / 256.0 + uvBias, frontY / 256.0 + uvBias)).r;
|
||||
float backLin = zLinearizer.sample(samp, float2(backX * 255.0 / 256.0 + uvBias, backY / 256.0 + uvBias)).r;
|
||||
return float4(vtf.color.rgb, (frontLin - backLin) * 10.0);
|
||||
}
|
||||
87
Shaders/CFogVolumePlaneShader.shader
Normal file
87
Shaders/CFogVolumePlaneShader.shader
Normal file
@@ -0,0 +1,87 @@
|
||||
#shader CFogVolumePlaneShader0
|
||||
#attribute position4
|
||||
#srcfac zero
|
||||
#dstfac zero
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#colorwrite false
|
||||
#culling frontface
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
void main()
|
||||
{
|
||||
gl_Position = posIn;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vec4(1.0);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
};
|
||||
|
||||
float4 main(in VertData v) : SV_Position
|
||||
{
|
||||
return v.posIn;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
float4 main() : SV_Target0
|
||||
{
|
||||
return float4(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.position = v.posIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return float4(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
#shader CFogVolumePlaneShader1 : CFogVolumePlaneShader0
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#colorwrite false
|
||||
#culling frontface
|
||||
|
||||
#shader CFogVolumePlaneShader2 : CFogVolumePlaneShader0
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#colorwrite false
|
||||
#culling backface
|
||||
|
||||
#shader CFogVolumePlaneShader3 : CFogVolumePlaneShader0
|
||||
#depthtest greater
|
||||
#depthwrite false
|
||||
#colorwrite false
|
||||
#culling backface
|
||||
298
Shaders/CLineRendererShaders.shader
Normal file
298
Shaders/CLineRendererShaders.shader
Normal file
@@ -0,0 +1,298 @@
|
||||
#shader CLineRendererShaderTexAlpha
|
||||
#attribute position4
|
||||
#attribute color
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 colorIn;
|
||||
layout(location=2) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform LineUniform
|
||||
{
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = colorIn * moduColor;
|
||||
vtf.uv = uvIn.xy;
|
||||
gl_Position = posIn;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 colorIn : COLOR;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer LineUniform : register(b0)
|
||||
{
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.position = v.posIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex0 : register(t0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex0.Sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn;
|
||||
float4 colorIn;
|
||||
float4 uvIn;
|
||||
};
|
||||
|
||||
struct LineUniform
|
||||
{
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
|
||||
uint vertId [[ vertex_id ]],
|
||||
constant LineUniform& line [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[vertId];
|
||||
vtf.color = v.colorIn * line.moduColor;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.position = v.posIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex0.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#shader CLineRendererShaderTexAdditive : CLineRendererShaderTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
|
||||
#shader CLineRendererShaderTexAlphaZ : CLineRendererShaderTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest lequal
|
||||
|
||||
#shader CLineRendererShaderTexAdditiveZ : CLineRendererShaderTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
|
||||
#shader CLineRendererShaderNoTexAlpha
|
||||
#attribute position4
|
||||
#attribute color
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 colorIn;
|
||||
|
||||
UBINDING0 uniform LineUniform
|
||||
{
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = colorIn * moduColor;
|
||||
gl_Position = posIn;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 colorIn : COLOR;
|
||||
};
|
||||
|
||||
cbuffer LineUniform : register(b0)
|
||||
{
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.position = v.posIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn;
|
||||
float4 colorIn;
|
||||
};
|
||||
|
||||
struct LineUniform
|
||||
{
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
|
||||
uint vertId [[ vertex_id ]],
|
||||
constant LineUniform& line [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[vertId];
|
||||
vtf.color = v.colorIn * line.moduColor;
|
||||
vtf.position = v.posIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#shader CLineRendererShaderNoTexAdditive : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
|
||||
#shader CLineRendererShaderNoTexAlphaZ : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest lequal
|
||||
|
||||
#shader CLineRendererShaderNoTexAdditiveZ : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
|
||||
#shader CLineRendererShaderNoTexAlphaZGEqual : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest gequal
|
||||
35
Shaders/CMakeLists.txt
Normal file
35
Shaders/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
include_directories(../hecl/include
|
||||
../hecl/extern/boo/include
|
||||
../hecl/extern/boo/logvisor/include
|
||||
../hecl/extern/athena/include
|
||||
../specter/zeus/include
|
||||
../Runtime)
|
||||
add_shader(CAABoxShader)
|
||||
add_shader(CCameraBlurFilter)
|
||||
add_shader(CColoredQuadFilter)
|
||||
add_shader(CDecalShaders)
|
||||
add_shader(CElementGenShaders)
|
||||
add_shader(CEnergyBarShader)
|
||||
add_shader(CFogVolumeFilter)
|
||||
add_shader(CFogVolumePlaneShader)
|
||||
add_shader(CLineRendererShaders)
|
||||
add_shader(CMapSurfaceShader)
|
||||
add_shader(CMoviePlayerShader)
|
||||
add_shader(CNESShader)
|
||||
add_shader(CParticleSwooshShaders)
|
||||
add_shader(CPhazonSuitFilter)
|
||||
add_shader(CRadarPaintShader)
|
||||
add_shader(CRandomStaticFilter)
|
||||
add_shader(CScanLinesFilter)
|
||||
add_shader(CSpaceWarpFilter)
|
||||
add_shader(CTextSupportShader)
|
||||
add_shader(CTexturedQuadFilter)
|
||||
add_shader(CThermalColdFilter)
|
||||
add_shader(CThermalHotFilter)
|
||||
add_shader(CWorldShadowShader)
|
||||
add_shader(CXRayBlurFilter)
|
||||
add_special_shader(shader_CFluidPlaneShader
|
||||
shader_CFluidPlaneShader.cpp
|
||||
shader_CFluidPlaneShaderGLSL.cpp
|
||||
shader_CFluidPlaneShaderHLSL.cpp
|
||||
shader_CFluidPlaneShaderMetal.cpp)
|
||||
118
Shaders/CMapSurfaceShader.shader
Normal file
118
Shaders/CMapSurfaceShader.shader
Normal file
@@ -0,0 +1,118 @@
|
||||
#shader CMapSurfaceShader
|
||||
#attribute position4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest gequal
|
||||
#depthwrite false
|
||||
#culling backface
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
|
||||
UBINDING0 uniform MapSurfaceUniform
|
||||
{
|
||||
mat4 xf;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
gl_Position = xf * vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
};
|
||||
|
||||
cbuffer MapSurfaceUniform : register(b0)
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.position = mul(xf, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
};
|
||||
|
||||
struct MapSurfaceUniform
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant MapSurfaceUniform& msu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = msu.color;
|
||||
vtf.position = msu.xf * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
156
Shaders/CMoviePlayerShader.shader
Normal file
156
Shaders/CMoviePlayerShader.shader
Normal file
@@ -0,0 +1,156 @@
|
||||
#shader CMoviePlayerShader
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec3 posIn;
|
||||
layout(location=1) in vec2 uvIn;
|
||||
UBINDING0 uniform ViewBlock
|
||||
{
|
||||
mat4 mv;
|
||||
vec4 mulColor;
|
||||
};
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.uv = uvIn;
|
||||
vtf.color = mulColor;
|
||||
gl_Position = mv * vec4(posIn, 1.0);
|
||||
gl_Position = FLIPFROMGL(gl_Position);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
TBINDING0 uniform sampler2D texY;
|
||||
TBINDING1 uniform sampler2D texU;
|
||||
TBINDING2 uniform sampler2D texV;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
vec3 yuv;
|
||||
yuv.r = texture(texY, vtf.uv).r;
|
||||
yuv.g = texture(texU, vtf.uv).r;
|
||||
yuv.b = texture(texV, vtf.uv).r;
|
||||
yuv.r = 1.1643*(yuv.r-0.0625);
|
||||
yuv.g = yuv.g-0.5;
|
||||
yuv.b = yuv.b-0.5;
|
||||
colorOut = vec4(yuv.r+1.5958*yuv.b,
|
||||
yuv.r-0.39173*yuv.g-0.81290*yuv.b,
|
||||
yuv.r+2.017*yuv.g, 1.0) * vtf.color;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float3 posIn : POSITION;
|
||||
float2 uvIn : UV;
|
||||
};
|
||||
cbuffer ViewBlock : register(b0)
|
||||
{
|
||||
float4x4 mv;
|
||||
float4 mulColor;
|
||||
};
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uv = v.uvIn;
|
||||
vtf.color = mulColor;
|
||||
vtf.position = mul(mv, float4(v.posIn, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
Texture2D texs[3] : register(t0);
|
||||
SamplerState samp : register(s0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float3 yuv;
|
||||
yuv.r = texs[0].Sample(samp, vtf.uv).r;
|
||||
yuv.g = texs[1].Sample(samp, vtf.uv).r;
|
||||
yuv.b = texs[2].Sample(samp, vtf.uv).r;
|
||||
yuv.r = 1.1643*(yuv.r-0.0625);
|
||||
yuv.g = yuv.g-0.5;
|
||||
yuv.b = yuv.b-0.5;
|
||||
return float4(yuv.r+1.5958*yuv.b,
|
||||
yuv.r-0.39173*yuv.g-0.81290*yuv.b,
|
||||
yuv.r+2.017*yuv.g, 1.0) * vtf.color;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float3 posIn [[ attribute(0) ]];
|
||||
float2 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
struct ViewBlock
|
||||
{
|
||||
float4x4 mv;
|
||||
float4 mulColor;
|
||||
};
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ViewBlock& view [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uv = v.uvIn;
|
||||
vtf.color = view.mulColor;
|
||||
vtf.position = view.mv * float4(v.posIn, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]],
|
||||
texture2d<float> tex1 [[ texture(1) ]],
|
||||
texture2d<float> tex2 [[ texture(2) ]])
|
||||
{
|
||||
float3 yuv;
|
||||
yuv.r = tex0.sample(samp, vtf.uv).r;
|
||||
yuv.g = tex1.sample(samp, vtf.uv).r;
|
||||
yuv.b = tex2.sample(samp, vtf.uv).r;
|
||||
yuv.r = 1.1643*(yuv.r-0.0625);
|
||||
yuv.g = yuv.g-0.5;
|
||||
yuv.b = yuv.b-0.5;
|
||||
return float4(yuv.r+1.5958*yuv.b,
|
||||
yuv.r-0.39173*yuv.g-0.81290*yuv.b,
|
||||
yuv.r+2.017*yuv.g, 1.0) * vtf.color;
|
||||
}
|
||||
138
Shaders/CNESShader.shader
Normal file
138
Shaders/CNESShader.shader
Normal file
@@ -0,0 +1,138 @@
|
||||
#shader CNESShader
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform TexuredQuadUniform
|
||||
{
|
||||
mat4 mtx;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
vtf.uv = uvIn.xy;
|
||||
gl_Position = mtx * vec4(posIn.xyz, 1.0);
|
||||
gl_Position = FLIPFROMGL(gl_Position);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer TexuredQuadUniform : register(b0)
|
||||
{
|
||||
float4x4 mat;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
Texture2D tex : register(t0);
|
||||
SamplerState samp : register(s4);
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex.Sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct TexuredQuadUniform
|
||||
{
|
||||
float4x4 mat;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = tqu.color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler clampSamp [[ sampler(4) ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex.sample(clampSamp, vtf.uv);
|
||||
}
|
||||
216
Shaders/CParticleSwooshShaders.shader
Normal file
216
Shaders/CParticleSwooshShaders.shader
Normal file
@@ -0,0 +1,216 @@
|
||||
#shader CParticleSwooshShaderTexZWrite
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#attribute color
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
layout(location=2) in vec4 colorIn;
|
||||
|
||||
UBINDING0 uniform SwooshUniform
|
||||
{
|
||||
mat4 mvp;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = colorIn;
|
||||
vtf.uv = uvIn.xy;
|
||||
gl_Position = mvp * vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
float4 colorIn : COLOR;
|
||||
};
|
||||
|
||||
cbuffer SwooshUniform : register(b0)
|
||||
{
|
||||
float4x4 mvp;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.pos = mul(mvp, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex : register(t0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex.Sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
float4 colorIn [[ attribute(2) ]];
|
||||
};
|
||||
|
||||
struct SwooshUniform
|
||||
{
|
||||
float4x4 mvp;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant SwooshUniform& su [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.pos = su.mvp * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
|
||||
#shader CParticleSwooshShaderTexNoZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthwrite false
|
||||
|
||||
#shader CParticleSwooshShaderTexAdditiveZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite true
|
||||
|
||||
#shader CParticleSwooshShaderTexAdditiveNoZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite false
|
||||
|
||||
#shader CParticleSwooshShaderNoTexZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
|
||||
#shader CParticleSwooshShaderNoTexNoZWrite : CParticleSwooshShaderNoTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthwrite false
|
||||
|
||||
#shader CParticleSwooshShaderNoTexAdditiveZWrite : CParticleSwooshShaderNoTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite true
|
||||
|
||||
#shader CParticleSwooshShaderNoTexAdditiveNoZWrite : CParticleSwooshShaderNoTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite false
|
||||
|
||||
478
Shaders/CPhazonSuitFilter.shader
Normal file
478
Shaders/CPhazonSuitFilter.shader
Normal file
@@ -0,0 +1,478 @@
|
||||
#shader CPhazonSuitFilterInd
|
||||
#attribute position4
|
||||
#attribute uv4 0
|
||||
#attribute uv4 1
|
||||
#attribute uv4 2
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 screenUvIn;
|
||||
layout(location=2) in vec4 indUvIn;
|
||||
layout(location=3) in vec4 maskUvIn;
|
||||
|
||||
UBINDING0 uniform PhazonSuitUniform
|
||||
{
|
||||
vec4 color;
|
||||
vec4 indScaleOff;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec4 indScaleOff;
|
||||
vec2 screenUv;
|
||||
vec2 indUv;
|
||||
vec2 maskUv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
vtf.indScaleOff = indScaleOff;
|
||||
vtf.screenUv = screenUvIn.xy;
|
||||
vtf.indUv = indUvIn.xy;
|
||||
vtf.maskUv = maskUvIn.xy;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec4 indScaleOff;
|
||||
vec2 screenUv;
|
||||
vec2 indUv;
|
||||
vec2 maskUv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D screenTex;
|
||||
TBINDING1 uniform sampler2D indTex;
|
||||
TBINDING2 uniform sampler2D maskTex;
|
||||
TBINDING3 uniform sampler2D maskTexBlur;
|
||||
void main()
|
||||
{
|
||||
vec2 indUv = (texture(indTex, vtf.indUv).ra - vec2(0.5, 0.5)) *
|
||||
vtf.indScaleOff.xy + vtf.indScaleOff.zw;
|
||||
float maskBlurAlpha = clamp(0.0, (texture(maskTexBlur, vtf.maskUv).a - texture(maskTex, vtf.maskUv).a) * 2.0, 1.0);
|
||||
colorOut = vtf.color * texture(screenTex, indUv + vtf.screenUv) * maskBlurAlpha;
|
||||
colorOut.a = vtf.color.a;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData {
|
||||
float4 posIn : POSITION;
|
||||
float4 screenUvIn : UV0;
|
||||
float4 indUvIn : UV1;
|
||||
float4 maskUvIn : UV2;
|
||||
};
|
||||
|
||||
cbuffer PhazonSuitUniform : register(b0)
|
||||
{
|
||||
float4 color;
|
||||
float4 indScaleOff;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float4 indScaleOff : SCALEOFF;
|
||||
float2 screenUv : UV0;
|
||||
float2 indUv : UV1;
|
||||
float2 maskUv : UV2;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.indScaleOff = indScaleOff;
|
||||
vtf.screenUv = v.screenUvIn.xy;
|
||||
vtf.screenUv.y = 1.0 - vtf.screenUv.y;
|
||||
vtf.indUv = v.indUvIn.xy;
|
||||
vtf.maskUv = v.maskUvIn.xy;
|
||||
vtf.maskUv.y = 1.0 - vtf.maskUv.y;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float4 indScaleOff : SCALEOFF;
|
||||
float2 screenUv : UV0;
|
||||
float2 indUv : UV1;
|
||||
float2 maskUv : UV2;
|
||||
};
|
||||
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D screenTex : register(t0);
|
||||
Texture2D indTex : register(t1);
|
||||
Texture2D maskTex : register(t2);
|
||||
Texture2D maskTexBlur : register(t3);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float2 indUv = (indTex.Sample(samp, vtf.indUv).ra - float2(0.5, 0.5)) *
|
||||
vtf.indScaleOff.xy + vtf.indScaleOff.zw;
|
||||
float maskBlurAlpha = saturate((maskTexBlur.Sample(samp, vtf.maskUv).a - maskTex.Sample(samp, vtf.maskUv).a) * 2.0);
|
||||
return float4((vtf.color * screenTex.Sample(samp, indUv + vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 screenUvIn [[ attribute(1) ]];
|
||||
float4 indUvIn [[ attribute(2) ]];
|
||||
float4 maskUvIn [[ attribute(3) ]];
|
||||
};
|
||||
|
||||
struct PhazonSuitUniform
|
||||
{
|
||||
float4 color;
|
||||
float4 indScaleOff;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float4 indScaleOff;
|
||||
float2 screenUv;
|
||||
float2 indUv;
|
||||
float2 maskUv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant PhazonSuitUniform& psu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = psu.color;
|
||||
vtf.indScaleOff = psu.indScaleOff;
|
||||
vtf.screenUv = v.screenUvIn.xy;
|
||||
vtf.screenUv.y = 1.0 - vtf.screenUv.y;
|
||||
vtf.indUv = v.indUvIn.xy;
|
||||
vtf.maskUv = v.maskUvIn.xy;
|
||||
vtf.maskUv.y = 1.0 - vtf.maskUv.y;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float4 indScaleOff;
|
||||
float2 screenUv;
|
||||
float2 indUv;
|
||||
float2 maskUv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> screenTex [[ texture(0) ]],
|
||||
texture2d<float> indTex [[ texture(1) ]],
|
||||
texture2d<float> maskTex [[ texture(2) ]],
|
||||
texture2d<float> maskTexBlur [[ texture(3) ]])
|
||||
{
|
||||
float2 indUv = (indTex.sample(samp, vtf.indUv).ra - float2(0.5, 0.5)) *
|
||||
vtf.indScaleOff.xy + vtf.indScaleOff.zw;
|
||||
float maskBlurAlpha = saturate((maskTexBlur.sample(samp, vtf.maskUv).a - maskTex.sample(samp, vtf.maskUv).a) * 2.0);
|
||||
return float4((vtf.color * screenTex.sample(samp, indUv + vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);
|
||||
}
|
||||
|
||||
|
||||
#shader CPhazonSuitFilterNoInd : CPhazonSuitFilterInd
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec4 indScaleOff;
|
||||
vec2 screenUv;
|
||||
vec2 indUv;
|
||||
vec2 maskUv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D screenTex;
|
||||
TBINDING1 uniform sampler2D maskTex;
|
||||
TBINDING2 uniform sampler2D maskTexBlur;
|
||||
void main()
|
||||
{
|
||||
float maskBlurAlpha = clamp(0.0, (texture(maskTexBlur, vtf.maskUv).a - texture(maskTex, vtf.maskUv).a) * 2.0, 1.0);
|
||||
colorOut = vtf.color * texture(screenTex, vtf.screenUv) * maskBlurAlpha;
|
||||
colorOut.a = vtf.color.a;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float4 indScaleOff : SCALEOFF;
|
||||
float2 screenUv : UV0;
|
||||
float2 indUv : UV1;
|
||||
float2 maskUv : UV2;
|
||||
};
|
||||
|
||||
SamplerState samp : register(s3);
|
||||
Texture2D screenTex : register(t0);
|
||||
Texture2D maskTex : register(t1);
|
||||
Texture2D maskTexBlur : register(t2);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float maskBlurAlpha = saturate((maskTexBlur.Sample(samp, vtf.maskUv).a - maskTex.Sample(samp, vtf.maskUv).a) * 2.0);
|
||||
return float4((vtf.color * screenTex.Sample(samp, vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 color;
|
||||
float4 indScaleOff;
|
||||
float2 screenUv;
|
||||
float2 indUv;
|
||||
float2 maskUv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler clampSamp [[ sampler(3) ]],
|
||||
texture2d<float> screenTex [[ texture(0) ]],
|
||||
texture2d<float> maskTex [[ texture(1) ]],
|
||||
texture2d<float> maskTexBlur [[ texture(2) ]])
|
||||
{
|
||||
float maskBlurAlpha = saturate((maskTexBlur.sample(clampSamp, vtf.maskUv).a - maskTex.sample(clampSamp, vtf.maskUv).a) * 2.0);
|
||||
return float4((vtf.color * screenTex.sample(clampSamp, vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);
|
||||
}
|
||||
|
||||
|
||||
#shader CPhazonSuitFilterBlur
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac one
|
||||
#dstfac zero
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform PhazonSuitBlurUniform
|
||||
{
|
||||
vec4 blurDir;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 uv;
|
||||
vec2 blurDir;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.uv = uvIn.xy;
|
||||
vtf.blurDir = blurDir.xy;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 uv;
|
||||
vec2 blurDir;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D maskTex;
|
||||
void main()
|
||||
{
|
||||
//this will be our alpha sum
|
||||
float sum = 0.0;
|
||||
|
||||
//apply blurring, using a 23-tap filter with predefined gaussian weights
|
||||
sum += texture(maskTex, vtf.uv + -11.0 * vtf.blurDir).a * 0.007249;
|
||||
sum += texture(maskTex, vtf.uv + -10.0 * vtf.blurDir).a * 0.011032;
|
||||
sum += texture(maskTex, vtf.uv + -9.0 * vtf.blurDir).a * 0.016133;
|
||||
sum += texture(maskTex, vtf.uv + -8.0 * vtf.blurDir).a * 0.022665;
|
||||
sum += texture(maskTex, vtf.uv + -7.0 * vtf.blurDir).a * 0.030595;
|
||||
sum += texture(maskTex, vtf.uv + -6.0 * vtf.blurDir).a * 0.039680;
|
||||
sum += texture(maskTex, vtf.uv + -5.0 * vtf.blurDir).a * 0.049444;
|
||||
sum += texture(maskTex, vtf.uv + -4.0 * vtf.blurDir).a * 0.059195;
|
||||
sum += texture(maskTex, vtf.uv + -3.0 * vtf.blurDir).a * 0.068091;
|
||||
sum += texture(maskTex, vtf.uv + -2.0 * vtf.blurDir).a * 0.075252;
|
||||
sum += texture(maskTex, vtf.uv + -1.0 * vtf.blurDir).a * 0.079905;
|
||||
sum += texture(maskTex, vtf.uv + 0.0 * vtf.blurDir).a * 0.081519;
|
||||
sum += texture(maskTex, vtf.uv + 1.0 * vtf.blurDir).a * 0.079905;
|
||||
sum += texture(maskTex, vtf.uv + 2.0 * vtf.blurDir).a * 0.075252;
|
||||
sum += texture(maskTex, vtf.uv + 3.0 * vtf.blurDir).a * 0.068091;
|
||||
sum += texture(maskTex, vtf.uv + 4.0 * vtf.blurDir).a * 0.059195;
|
||||
sum += texture(maskTex, vtf.uv + 5.0 * vtf.blurDir).a * 0.049444;
|
||||
sum += texture(maskTex, vtf.uv + 6.0 * vtf.blurDir).a * 0.039680;
|
||||
sum += texture(maskTex, vtf.uv + 7.0 * vtf.blurDir).a * 0.030595;
|
||||
sum += texture(maskTex, vtf.uv + 8.0 * vtf.blurDir).a * 0.022665;
|
||||
sum += texture(maskTex, vtf.uv + 9.0 * vtf.blurDir).a * 0.016133;
|
||||
sum += texture(maskTex, vtf.uv + 10.0 * vtf.blurDir).a * 0.011032;
|
||||
sum += texture(maskTex, vtf.uv + 11.0 * vtf.blurDir).a * 0.007249;
|
||||
|
||||
colorOut = vec4(1.0, 1.0, 1.0, sum);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData {
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer PhazonSuitBlurUniform : register(b0)
|
||||
{
|
||||
float4 blurDir;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : UV;
|
||||
float2 blurDir : BLURDIR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.uv.y = 1.0 - vtf.uv.y;
|
||||
vtf.blurDir = blurDir.xy;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : UV;
|
||||
float2 blurDir : BLURDIR;
|
||||
};
|
||||
|
||||
SamplerState samp : register(s3);
|
||||
Texture2D maskTex : register(t0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
//this will be our alpha sum
|
||||
float sum = 0.0;
|
||||
|
||||
//apply blurring, using a 23-tap filter with predefined gaussian weights
|
||||
sum += maskTex.Sample(samp, vtf.uv + -11.0 * vtf.blurDir).a * 0.007249;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -10.0 * vtf.blurDir).a * 0.011032;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -9.0 * vtf.blurDir).a * 0.016133;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -8.0 * vtf.blurDir).a * 0.022665;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -7.0 * vtf.blurDir).a * 0.030595;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -6.0 * vtf.blurDir).a * 0.039680;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -5.0 * vtf.blurDir).a * 0.049444;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -4.0 * vtf.blurDir).a * 0.059195;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -3.0 * vtf.blurDir).a * 0.068091;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -2.0 * vtf.blurDir).a * 0.075252;
|
||||
sum += maskTex.Sample(samp, vtf.uv + -1.0 * vtf.blurDir).a * 0.079905;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 0.0 * vtf.blurDir).a * 0.081519;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 1.0 * vtf.blurDir).a * 0.079905;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 2.0 * vtf.blurDir).a * 0.075252;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 3.0 * vtf.blurDir).a * 0.068091;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 4.0 * vtf.blurDir).a * 0.059195;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 5.0 * vtf.blurDir).a * 0.049444;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 6.0 * vtf.blurDir).a * 0.039680;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 7.0 * vtf.blurDir).a * 0.030595;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 8.0 * vtf.blurDir).a * 0.022665;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 9.0 * vtf.blurDir).a * 0.016133;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 10.0 * vtf.blurDir).a * 0.011032;
|
||||
sum += maskTex.Sample(samp, vtf.uv + 11.0 * vtf.blurDir).a * 0.007249;
|
||||
|
||||
return float4(1.0, 1.0, 1.0, sum);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct PhazonSuitBlurUniform
|
||||
{
|
||||
float4 blurDir;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 uv;
|
||||
float2 blurDir;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant PhazonSuitBlurUniform& psu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.uv.y = 1.0 - vtf.uv.y;
|
||||
vtf.blurDir = psu.blurDir.xy;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 uv;
|
||||
float2 blurDir;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler clampSamp [[ sampler(3) ]],
|
||||
texture2d<float> maskTex [[ texture(0) ]])
|
||||
{
|
||||
//this will be our alpha sum
|
||||
float sum = 0.0;
|
||||
|
||||
//apply blurring, using a 23-tap filter with predefined gaussian weights
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -11.0 * vtf.blurDir).a * 0.007249;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -10.0 * vtf.blurDir).a * 0.011032;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -9.0 * vtf.blurDir).a * 0.016133;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -8.0 * vtf.blurDir).a * 0.022665;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -7.0 * vtf.blurDir).a * 0.030595;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -6.0 * vtf.blurDir).a * 0.039680;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -5.0 * vtf.blurDir).a * 0.049444;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -4.0 * vtf.blurDir).a * 0.059195;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -3.0 * vtf.blurDir).a * 0.068091;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -2.0 * vtf.blurDir).a * 0.075252;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + -1.0 * vtf.blurDir).a * 0.079905;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv).a * 0.081519;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 1.0 * vtf.blurDir).a * 0.079905;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 2.0 * vtf.blurDir).a * 0.075252;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 3.0 * vtf.blurDir).a * 0.068091;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 4.0 * vtf.blurDir).a * 0.059195;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 5.0 * vtf.blurDir).a * 0.049444;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 6.0 * vtf.blurDir).a * 0.039680;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 7.0 * vtf.blurDir).a * 0.030595;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 8.0 * vtf.blurDir).a * 0.022665;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 9.0 * vtf.blurDir).a * 0.016133;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 10.0 * vtf.blurDir).a * 0.011032;
|
||||
sum += maskTex.sample(clampSamp, vtf.uv + 11.0 * vtf.blurDir).a * 0.007249;
|
||||
|
||||
return float4(1.0, 1.0, 1.0, sum);
|
||||
}
|
||||
|
||||
|
||||
|
||||
148
Shaders/CRadarPaintShader.shader
Normal file
148
Shaders/CRadarPaintShader.shader
Normal file
@@ -0,0 +1,148 @@
|
||||
#shader CRadarPaintShader
|
||||
#attribute position4 0
|
||||
#attribute position4 1
|
||||
#attribute position4 2
|
||||
#attribute position4 3
|
||||
#attribute uv4 0
|
||||
#attribute uv4 1
|
||||
#attribute uv4 2
|
||||
#attribute uv4 3
|
||||
#attribute color
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
layout(location=4) in vec4 uvIn[4];
|
||||
layout(location=8) in vec4 colorIn;
|
||||
|
||||
UBINDING0 uniform RadarPaintUniform
|
||||
{
|
||||
mat4 xf;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vec3 pos = posIn[gl_VertexID].xyz;
|
||||
vtf.uv = uvIn[gl_VertexID].xy;
|
||||
vtf.color = colorIn;
|
||||
gl_Position = xf * vec4(pos, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 uvIn[4] : UV;
|
||||
float4 colorIn : COLOR;
|
||||
};
|
||||
|
||||
cbuffer RadarPaintUniform : register(b0)
|
||||
{
|
||||
float4x4 xf;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn;
|
||||
vtf.uv = v.uvIn[vertId].xy;
|
||||
vtf.position = mul(xf, float4(v.posIn[vertId].xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
SamplerState samp : register(s0);
|
||||
Texture2D tex : register(t0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex.Sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 uvIn[4];
|
||||
float4 colorIn;
|
||||
};
|
||||
|
||||
struct RadarPaintUniform
|
||||
{
|
||||
float4x4 xf;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant RadarPaintUniform& rpu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[instId];
|
||||
vtf.color = v.colorIn;
|
||||
vtf.uv = v.uvIn[vertId].xy;
|
||||
vtf.position = rpu.xf * float4(v.posIn[vertId].xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
310
Shaders/CRandomStaticFilter.shader
Normal file
310
Shaders/CRandomStaticFilter.shader
Normal file
@@ -0,0 +1,310 @@
|
||||
#shader CRandomStaticFilterAlpha
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform RandomStaticUniform
|
||||
{
|
||||
vec4 color;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
vtf.uv = uvIn.xy;
|
||||
vtf.randOff = randOff;
|
||||
vtf.discardThres = discardThres;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
ivec2 Lookup8BPP(in vec2 uv, in float randOff)
|
||||
{
|
||||
float bx;
|
||||
float rx = modf(uv.x / 8.0, bx) * 8.0;
|
||||
float by;
|
||||
float ry = modf(uv.y / 4.0, by) * 4.0;
|
||||
float bidx = by * 80.0 + bx;
|
||||
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
|
||||
float y;
|
||||
float x = modf(addr / 1024.0, y) * 1024.0;
|
||||
return ivec2(x, y);
|
||||
}
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = texelFetch(tex, Lookup8BPP(vtf.uv, vtf.randOff), 0) * vtf.color;
|
||||
colorOut.a = vtf.color.a;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float2 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer RandomStaticUniform : register(b0)
|
||||
{
|
||||
float4 color;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
float randOff : RANDOFF;
|
||||
float discardThres : DISCARDTHRES;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.randOff = randOff;
|
||||
vtf.discardThres = discardThres;
|
||||
vtf.pos = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
float randOff : RANDOFF;
|
||||
float discardThres : DISCARDTHRES;
|
||||
};
|
||||
|
||||
static int3 Lookup8BPP(float2 uv, float randOff)
|
||||
{
|
||||
float bx;
|
||||
float rx = modf(uv.x / 8.0, bx) * 8.0;
|
||||
float by;
|
||||
float ry = modf(uv.y / 4.0, by) * 4.0;
|
||||
float bidx = by * 80.0 + bx;
|
||||
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
|
||||
float y;
|
||||
float x = modf(addr / 1024.0, y) * 1024.0;
|
||||
return int3(x, y, 0);
|
||||
}
|
||||
|
||||
Texture2D tex : register(t0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float4 colorOut = tex.Load(Lookup8BPP(vtf.uv, vtf.randOff)) * vtf.color;
|
||||
colorOut.a = vtf.color.a;
|
||||
return colorOut;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float2 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct RandomStaticUniform
|
||||
{
|
||||
float4 color;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]],
|
||||
constant RandomStaticUniform& su [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = su.color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.randOff = su.randOff;
|
||||
vtf.discardThres = su.discardThres;
|
||||
vtf.pos = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
static uint2 Lookup8BPP(float2 uv, float randOff)
|
||||
{
|
||||
float bx;
|
||||
float rx = modf(uv.x / 8.0, bx) * 8.0;
|
||||
float by;
|
||||
float ry = modf(uv.y / 4.0, by) * 4.0;
|
||||
float bidx = by * 80.0 + bx;
|
||||
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
|
||||
float y;
|
||||
float x = modf(addr / 1024.0, y) * 1024.0;
|
||||
return uint2(x, y);
|
||||
}
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
float4 colorOut = tex.read(Lookup8BPP(vtf.uv, vtf.randOff)) * vtf.color;
|
||||
colorOut.a = vtf.color.a;
|
||||
return colorOut;
|
||||
}
|
||||
|
||||
#shader CRandomStaticFilterAdd : CRandomStaticFilterAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CRandomStaticFilterMult : CRandomStaticFilterAlpha
|
||||
#srcfac srccolor
|
||||
#dstfac dstcolor
|
||||
|
||||
#shader CRandomStaticFilterCookieCutter : CRandomStaticFilterAlpha
|
||||
#srcfac srccolor
|
||||
#dstfac dstcolor
|
||||
#depthwrite true
|
||||
#depthtest lequal
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
ivec2 Lookup8BPP(in vec2 uv, in float randOff)
|
||||
{
|
||||
float bx;
|
||||
float rx = modf(uv.x / 8.0, bx) * 8.0;
|
||||
float by;
|
||||
float ry = modf(uv.y / 4.0, by) * 4.0;
|
||||
float bidx = by * 80.0 + bx;
|
||||
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
|
||||
float y;
|
||||
float x = modf(addr / 1024.0, y) * 1024.0;
|
||||
return ivec2(x, y);
|
||||
}
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = texelFetch(tex, Lookup8BPP(vtf.uv, vtf.randOff), 0) * vtf.color;
|
||||
if (colorOut.a < vtf.discardThres)
|
||||
discard;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
float randOff : RANDOFF;
|
||||
float discardThres : DISCARDTHRES;
|
||||
};
|
||||
|
||||
static int3 Lookup8BPP(float2 uv, float randOff)
|
||||
{
|
||||
float bx;
|
||||
float rx = modf(uv.x / 8.0, bx) * 8.0;
|
||||
float by;
|
||||
float ry = modf(uv.y / 4.0, by) * 4.0;
|
||||
float bidx = by * 80.0 + bx;
|
||||
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
|
||||
float y;
|
||||
float x = modf(addr / 1024.0, y) * 1024.0;
|
||||
return int3(x, y, 0);
|
||||
}
|
||||
|
||||
Texture2D tex : register(t0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float4 colorOut = tex.Load(Lookup8BPP(vtf.uv, vtf.randOff)) * vtf.color;
|
||||
if (colorOut.a < vtf.discardThres)
|
||||
discard;
|
||||
return colorOut;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
|
||||
static uint2 Lookup8BPP(float2 uv, float randOff)
|
||||
{
|
||||
float bx;
|
||||
float rx = modf(uv.x / 8.0, bx) * 8.0;
|
||||
float by;
|
||||
float ry = modf(uv.y / 4.0, by) * 4.0;
|
||||
float bidx = by * 80.0 + bx;
|
||||
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
|
||||
float y;
|
||||
float x = modf(addr / 1024.0, y) * 1024.0;
|
||||
return uint2(x, y);
|
||||
}
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
float4 colorOut = tex.read(Lookup8BPP(vtf.uv, vtf.randOff)) * vtf.color;
|
||||
if (colorOut.a < vtf.discardThres)
|
||||
discard_fragment();
|
||||
return colorOut;
|
||||
}
|
||||
123
Shaders/CScanLinesFilter.shader
Normal file
123
Shaders/CScanLinesFilter.shader
Normal file
@@ -0,0 +1,123 @@
|
||||
#shader CScanLinesFilterAlpha
|
||||
#attribute position4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
|
||||
UBINDING0 uniform ScanLinesUniform
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
};
|
||||
|
||||
cbuffer ScanLinesUniform : register(b0)
|
||||
{
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
};
|
||||
|
||||
struct ScanLinesUniform
|
||||
{
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ScanLinesUniform& cqu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = cqu.color;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#shader CScanLinesFilterAdd : CScanLinesFilterAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CScanLinesFilterMult : CScanLinesFilterAlpha
|
||||
#srcfac zero
|
||||
#dstfac srccolor
|
||||
156
Shaders/CSpaceWarpFilter.shader
Normal file
156
Shaders/CSpaceWarpFilter.shader
Normal file
@@ -0,0 +1,156 @@
|
||||
#shader CSpaceWarpFilter
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac one
|
||||
#dstfac zero
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform SpaceWarpUniform
|
||||
{
|
||||
mat4 mainMtx;
|
||||
mat4 indMtx;
|
||||
vec4 strength;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 sceneUv;
|
||||
vec2 indUv;
|
||||
vec2 strength;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
gl_Position = mainMtx * vec4(posIn.xy, 0.0, 1.0);
|
||||
vtf.sceneUv = gl_Position.xy * vec2(0.5) + vec2(0.5);
|
||||
vtf.indUv = (mat3(indMtx) * vec3(uvIn.xy, 1.0)).xy;
|
||||
vtf.strength = strength.xy;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 sceneUv;
|
||||
vec2 indUv;
|
||||
vec2 strength;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D sceneTex;
|
||||
TBINDING1 uniform sampler2D indTex;
|
||||
void main()
|
||||
{
|
||||
vec2 indUv = texture(indTex, vtf.indUv).xy * vec2(2.0) - vec2(1.0 - 1.0 / 256.0);
|
||||
colorOut = vec4(texture(sceneTex, vtf.sceneUv + indUv * vtf.strength.xy).rgb, 1.0);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
cbuffer SpaceWarpUniform : register(b0)
|
||||
{
|
||||
float4x4 mainMtx;
|
||||
float4x4 indMtx;
|
||||
float4 strength;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 sceneUv : SCENEUV;
|
||||
float2 indUv : INDV;
|
||||
float2 strength : STRENGTH;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.position = mul(mainMtx, float4(v.posIn.xy, 0.0, 1.0));
|
||||
vtf.sceneUv = vtf.position.xy * float2(0.5, 0.5) + float2(0.5, 0.5);
|
||||
vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;
|
||||
vtf.indUv = mul(float3x3(indMtx[0].xyz, indMtx[1].xyz, indMtx[2].xyz), float3(v.uvIn.xy, 1.0)).xy;
|
||||
vtf.indUv.y = 1.0 - vtf.indUv.y;
|
||||
vtf.strength = strength.xy;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
Texture2D sceneTex : register(t0);
|
||||
Texture2D indTex : register(t1);
|
||||
SamplerState samp : register(s0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 sceneUv : SCENEUV;
|
||||
float2 indUv : INDV;
|
||||
float2 strength : STRENGTH;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float2 indUv = indTex.Sample(samp, vtf.indUv).xy * float2(2.0, 2.0) - float2(1.0 - 1.0 / 256.0, 1.0 - 1.0 / 256.0);
|
||||
return float4(sceneTex.Sample(samp, vtf.sceneUv + indUv * vtf.strength.xy).rgb, 1.0);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
struct SpaceWarpUniform
|
||||
{
|
||||
float4x4 mainMtx;
|
||||
float4x4 indMtx;
|
||||
float4 strength;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 sceneUv;
|
||||
float2 indUv;
|
||||
float2 strength;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant SpaceWarpUniform& swu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.position = swu.mainMtx * float4(v.posIn.xy, 0.0, 1.0);
|
||||
vtf.sceneUv = vtf.position.xy * float2(0.5) + float2(0.5);
|
||||
vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;
|
||||
vtf.indUv = (float3x3(swu.indMtx[0].xyz, swu.indMtx[1].xyz, swu.indMtx[2].xyz) * float3(v.uvIn.xy, 1.0)).xy;
|
||||
vtf.indUv.y = 1.0 - vtf.indUv.y;
|
||||
vtf.strength = swu.strength.xy;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 sceneUv;
|
||||
float2 indUv;
|
||||
float2 strength;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> sceneTex [[ texture(0) ]],
|
||||
texture2d<float> indTex [[ texture(1) ]])
|
||||
{
|
||||
float2 indUv = indTex.sample(samp, vtf.indUv).xy * float2(2.0) - float2(1.0 - 1.0 / 256.0);
|
||||
return float4(sceneTex.sample(samp, vtf.sceneUv + indUv * vtf.strength.xy).rgb, 1.0);
|
||||
}
|
||||
351
Shaders/CTextSupportShader.shader
Normal file
351
Shaders/CTextSupportShader.shader
Normal file
@@ -0,0 +1,351 @@
|
||||
#shader CTextSupportShaderAlpha
|
||||
#instattribute position4 0
|
||||
#instattribute position4 1
|
||||
#instattribute position4 2
|
||||
#instattribute position4 3
|
||||
#instattribute uv4 0
|
||||
#instattribute uv4 1
|
||||
#instattribute uv4 2
|
||||
#instattribute uv4 3
|
||||
#instattribute color 0
|
||||
#instattribute color 1
|
||||
#instattribute color 2
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
layout(location=4) in vec4 uvIn[4];
|
||||
layout(location=8) in vec4 fontColorIn;
|
||||
layout(location=9) in vec4 outlineColorIn;
|
||||
layout(location=10) in vec4 mulColorIn;
|
||||
|
||||
UBINDING0 uniform TextSupportUniform
|
||||
{
|
||||
mat4 mtx;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 fontColor;
|
||||
vec4 outlineColor;
|
||||
vec4 mulColor;
|
||||
vec3 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vec3 pos = posIn[gl_VertexID].xyz;
|
||||
vtf.uv = uvIn[gl_VertexID].xyz;
|
||||
vtf.fontColor = color * fontColorIn;
|
||||
vtf.outlineColor = color * outlineColorIn;
|
||||
vtf.mulColor = mulColorIn;
|
||||
gl_Position = mtx * vec4(pos, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 fontColor;
|
||||
vec4 outlineColor;
|
||||
vec4 mulColor;
|
||||
vec3 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2DArray tex;
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture(tex, vtf.uv);
|
||||
colorOut = (vtf.fontColor * texel.r + vtf.outlineColor * texel.g) * vtf.mulColor;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct InstData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 uvIn[4] : UV;
|
||||
float4 fontColorIn : COLOR0;
|
||||
float4 outlineColorIn : COLOR1;
|
||||
float4 mulColorIn : COLOR2;
|
||||
};
|
||||
|
||||
cbuffer TextSupportUniform : register(b0)
|
||||
{
|
||||
float4x4 mtx;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 fontColor : COLOR0;
|
||||
float4 outlineColor : COLOR1;
|
||||
float4 mulColor : COLOR2;
|
||||
float3 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in InstData inst, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.fontColor = color * inst.fontColorIn;
|
||||
vtf.outlineColor = color * inst.outlineColorIn;
|
||||
vtf.mulColor = inst.mulColorIn;
|
||||
vtf.uv = inst.uvIn[vertId].xyz;
|
||||
vtf.pos = mul(mtx, float4(inst.posIn[vertId].xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 fontColor : COLOR0;
|
||||
float4 outlineColor : COLOR1;
|
||||
float4 mulColor : COLOR2;
|
||||
float3 uv : UV;
|
||||
};
|
||||
|
||||
Texture2DArray tex : register(t0);
|
||||
SamplerState samp : register(s3);
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float4 texel = tex.Sample(samp, vtf.uv.xyz);
|
||||
return (vtf.fontColor * texel.r + vtf.outlineColor * texel.g) * vtf.mulColor;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct InstData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 uvIn[4];
|
||||
float4 fontColorIn;
|
||||
float4 outlineColorIn;
|
||||
float4 mulColorIn;
|
||||
};
|
||||
|
||||
struct TextSupportUniform
|
||||
{
|
||||
float4x4 mtx;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 fontColor;
|
||||
float4 outlineColor;
|
||||
float4 mulColor;
|
||||
float3 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant InstData* instArr [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant TextSupportUniform& uData [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant InstData& inst = instArr[instId];
|
||||
vtf.fontColor = inst.fontColorIn * uData.color;
|
||||
vtf.outlineColor = inst.outlineColorIn * uData.color;
|
||||
vtf.mulColor = inst.mulColorIn;
|
||||
vtf.uv = inst.uvIn[vertId].xyz;
|
||||
vtf.pos = uData.mtx * float4(inst.posIn[vertId].xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 fontColor;
|
||||
float4 outlineColor;
|
||||
float4 mulColor;
|
||||
float3 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler clampSamp [[ sampler(3) ]],
|
||||
texture2d_array<float> tex [[ texture(0) ]])
|
||||
{
|
||||
float4 texel = tex.sample(clampSamp, vtf.uv.xy, vtf.uv.z);
|
||||
return (vtf.fontColor * texel.r + vtf.outlineColor * texel.g) * vtf.mulColor;
|
||||
}
|
||||
|
||||
#shader CTextSupportShaderAdd : CTextSupportShaderAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CTextSupportShaderAddOverdraw : CTextSupportShaderAlpha
|
||||
#srcfac one
|
||||
#dstfac one
|
||||
|
||||
#shader CTextSupportShaderImageAlpha
|
||||
#instattribute position4 0
|
||||
#instattribute position4 1
|
||||
#instattribute position4 2
|
||||
#instattribute position4 3
|
||||
#instattribute uv4 0
|
||||
#instattribute uv4 1
|
||||
#instattribute uv4 2
|
||||
#instattribute uv4 3
|
||||
#instattribute color 0
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec3 posIn[4];
|
||||
layout(location=4) in vec2 uvIn[4];
|
||||
layout(location=8) in vec4 colorIn;
|
||||
|
||||
UBINDING0 uniform TextSupportUniform
|
||||
{
|
||||
mat4 mtx;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vec3 pos = posIn[gl_VertexID].xyz;
|
||||
vtf.uv = uvIn[gl_VertexID];
|
||||
vtf.color = color * colorIn;
|
||||
gl_Position = mtx * vec4(pos, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture(tex, vtf.uv);
|
||||
colorOut = vtf.color * texel;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct InstData
|
||||
{
|
||||
float4 posIn[4] : POSITION;
|
||||
float4 uvIn[4] : UV;
|
||||
float4 colorIn : COLOR;
|
||||
};
|
||||
|
||||
cbuffer TextSupportUniform : register(b0)
|
||||
{
|
||||
float4x4 mtx;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in InstData inst, in uint vertId : SV_VertexID)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color * inst.colorIn;
|
||||
vtf.uv = inst.uvIn[vertId].xy;
|
||||
vtf.pos = mul(mtx, float4(inst.posIn[vertId].xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
};
|
||||
|
||||
Texture2D tex : register(t0);
|
||||
SamplerState samp : register(s3);
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float4 texel = tex.Sample(samp, vtf.uv);
|
||||
return vtf.color * texel;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct InstData
|
||||
{
|
||||
float4 posIn[4];
|
||||
float4 uvIn[4];
|
||||
float4 colorIn;
|
||||
};
|
||||
|
||||
struct TextSupportUniform
|
||||
{
|
||||
float4x4 mtx;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant InstData* instArr [[ buffer(1) ]],
|
||||
uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],
|
||||
constant TextSupportUniform& uData [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant InstData& inst = instArr[instId];
|
||||
vtf.color = uData.color * inst.colorIn;
|
||||
vtf.uv = inst.uvIn[vertId].xy;
|
||||
vtf.pos = uData.mtx * float4(inst.posIn[vertId].xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 pos [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler clampSamp [[ sampler(3) ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
float4 texel = tex.sample(clampSamp, vtf.uv);
|
||||
return vtf.color * texel;
|
||||
}
|
||||
|
||||
#shader CTextSupportShaderImageAdd : CTextSupportShaderImageAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CTextSupportShaderImageAddOverdraw : CTextSupportShaderImageAlpha
|
||||
#srcfac one
|
||||
#dstfac one
|
||||
273
Shaders/CTexturedQuadFilter.shader
Normal file
273
Shaders/CTexturedQuadFilter.shader
Normal file
@@ -0,0 +1,273 @@
|
||||
#shader CTexturedQuadFilterAlpha
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform TexuredQuadUniform
|
||||
{
|
||||
mat4 mtx;
|
||||
vec4 color;
|
||||
float lod;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
float lod;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
vtf.uv = uvIn.xy;
|
||||
vtf.lod = lod;
|
||||
gl_Position = mtx * vec4(posIn.xyz, 1.0);
|
||||
gl_Position = FLIPFROMGL(gl_Position);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
float lod;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * vec4(texture(tex, vtf.uv, vtf.lod).rgb, 1.0);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer TexuredQuadUniform : register(b0)
|
||||
{
|
||||
float4x4 mat;
|
||||
float4 color;
|
||||
float lod;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
float lod : LOD;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.lod = lod;
|
||||
vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
float lod : LOD;
|
||||
};
|
||||
|
||||
Texture2D tex : register(t0);
|
||||
SamplerState samp : register(s3);
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * float4(tex.SampleBias(samp, vtf.uv, vtf.lod).rgb, 1.0);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct TexuredQuadUniform
|
||||
{
|
||||
float4x4 mat;
|
||||
float4 color;
|
||||
float lod;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
float lod;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = tqu.color;
|
||||
vtf.uv = v.uvIn.xy;
|
||||
vtf.lod = tqu.lod;
|
||||
vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
float lod;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler clampSamp [[ sampler(3) ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * float4(tex.sample(clampSamp, vtf.uv, bias(vtf.lod)).rgb, 1.0);
|
||||
}
|
||||
|
||||
#shader CTexturedQuadFilterAlphaGEqual : CTexturedQuadFilterAlpha
|
||||
#depthtest gequal
|
||||
|
||||
#shader CTexturedQuadFilterAlphaLEqual : CTexturedQuadFilterAlpha
|
||||
#depthtest lequal
|
||||
|
||||
#shader CTexturedQuadFilterAdd : CTexturedQuadFilterAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
|
||||
#shader CTexturedQuadFilterAddGEqual : CTexturedQuadFilterAdd
|
||||
#depthtest gequal
|
||||
|
||||
#shader CTexturedQuadFilterAddLEqual : CTexturedQuadFilterAdd
|
||||
#depthtest lequal
|
||||
|
||||
#shader CTexturedQuadFilterSubtract : CTexturedQuadFilterAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac subtract
|
||||
#depthtest none
|
||||
|
||||
#shader CTexturedQuadFilterSubtractGEqual : CTexturedQuadFilterSubtract
|
||||
#depthtest gequal
|
||||
|
||||
#shader CTexturedQuadFilterSubtractLEqual : CTexturedQuadFilterSubtract
|
||||
#depthtest lequal
|
||||
|
||||
#shader CTexturedQuadFilterMult : CTexturedQuadFilterAlpha
|
||||
#srcfac zero
|
||||
#dstfac srccolor
|
||||
#depthtest none
|
||||
|
||||
#shader CTexturedQuadFilterMultGEqual : CTexturedQuadFilterMult
|
||||
#depthtest gequal
|
||||
|
||||
#shader CTexturedQuadFilterMultLEqual : CTexturedQuadFilterMult
|
||||
#depthtest lequal
|
||||
|
||||
#shader CTexturedQuadFilterInvDstMult : CTexturedQuadFilterAlpha
|
||||
#srcfac zero
|
||||
#dstfac invsrccolor
|
||||
#depthtest none
|
||||
|
||||
#shader CTexturedQuadFilterInvDstMultGEqual : CTexturedQuadFilterInvDstMult
|
||||
#depthtest gequal
|
||||
|
||||
#shader CTexturedQuadFilterInvDstMultLEqual : CTexturedQuadFilterInvDstMult
|
||||
#depthtest lequal
|
||||
|
||||
#shader CTexturedQuadFilterAlphaTexAlpha : CTexturedQuadFilterAlpha
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest none
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
float lod;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv, vtf.lod);
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : UV;
|
||||
float lod : LOD;
|
||||
};
|
||||
|
||||
Texture2D tex : register(t0);
|
||||
SamplerState samp : register(s3);
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color * tex.SampleBias(samp, vtf.uv, vtf.lod);
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
float2 uv;
|
||||
float lod;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler clampSamp [[ sampler(3) ]],
|
||||
texture2d<float> tex [[ texture(0) ]])
|
||||
{
|
||||
return vtf.color * tex.sample(clampSamp, vtf.uv, bias(vtf.lod));
|
||||
}
|
||||
|
||||
#shader CTexturedQuadFilterAlphaTexAdd : CTexturedQuadFilterAlphaTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
|
||||
#shader CTexturedQuadFilterAlphaTexSubtract : CTexturedQuadFilterAlphaTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac subtract
|
||||
|
||||
#shader CTexturedQuadFilterAlphaTexMult : CTexturedQuadFilterAlphaTexAlpha
|
||||
#srcfac zero
|
||||
#dstfac srccolor
|
||||
|
||||
#shader CTexturedQuadFilterAlphaTexInvDstMult : CTexturedQuadFilterAlphaTexAlpha
|
||||
#srcfac zero
|
||||
#dstfac invsrccolor
|
||||
|
||||
225
Shaders/CThermalColdFilter.shader
Normal file
225
Shaders/CThermalColdFilter.shader
Normal file
@@ -0,0 +1,225 @@
|
||||
#shader CThermalColdFilter
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac one
|
||||
#dstfac zero
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform ThermalColdUniform
|
||||
{
|
||||
mat4 shiftMtx;
|
||||
mat4 indMtx;
|
||||
vec4 shiftScale;
|
||||
vec4 colorReg0;
|
||||
vec4 colorReg1;
|
||||
vec4 colorReg2;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
mat3 indMtx;
|
||||
vec4 colorReg0;
|
||||
vec4 colorReg1;
|
||||
vec4 colorReg2;
|
||||
vec2 sceneUv;
|
||||
vec2 shiftUv;
|
||||
vec2 shiftScale;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.indMtx = mat3(indMtx);
|
||||
vtf.colorReg0 = colorReg0;
|
||||
vtf.colorReg1 = colorReg1;
|
||||
vtf.colorReg2 = colorReg2;
|
||||
vtf.sceneUv = uvIn.xy;
|
||||
vtf.shiftUv = (mat3(shiftMtx) * uvIn.xyz).xy;
|
||||
vtf.shiftScale = shiftScale.xy;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
mat3 indMtx;
|
||||
vec4 colorReg0;
|
||||
vec4 colorReg1;
|
||||
vec4 colorReg2;
|
||||
vec2 sceneUv;
|
||||
vec2 shiftUv;
|
||||
vec2 shiftScale;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D sceneTex;
|
||||
TBINDING1 uniform sampler2D shiftTex;
|
||||
const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
|
||||
void main()
|
||||
{
|
||||
vec2 shiftCoordTexel = texture(shiftTex, vtf.shiftUv).xy;
|
||||
vec2 shiftCoord = vtf.sceneUv + shiftCoordTexel * vtf.shiftScale;
|
||||
float shiftScene0 = dot(texture(sceneTex, shiftCoord), kRGBToYPrime);
|
||||
float shiftScene1 = dot(texture(sceneTex, shiftCoord + vec2(vtf.shiftScale.x / 8.0, 0.0)), kRGBToYPrime);
|
||||
vec2 indCoord = (vtf.indMtx * vec3(shiftScene0 - 0.5, shiftScene1 - 0.5, 1.0)).xy;
|
||||
float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime);
|
||||
colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * shiftScene0 + vtf.colorReg2;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer ThermalColdUniform : register(b0)
|
||||
{
|
||||
float4x4 shiftMtx;
|
||||
float4x4 indMtx;
|
||||
float4 shiftScale;
|
||||
float4 colorReg0;
|
||||
float4 colorReg1;
|
||||
float4 colorReg2;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float3x3 indMtx : INDMTX;
|
||||
float4 colorReg0 : COLORREG0;
|
||||
float4 colorReg1 : COLORREG1;
|
||||
float4 colorReg2 : COLORREG2;
|
||||
float2 sceneUv : SCENEUV;
|
||||
float2 shiftUv : SHIFTUV;
|
||||
float2 shiftScale : SHIFTSCALE;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.indMtx = float3x3(indMtx[0].xyz, indMtx[1].xyz, indMtx[2].xyz);
|
||||
vtf.colorReg0 = colorReg0;
|
||||
vtf.colorReg1 = colorReg1;
|
||||
vtf.colorReg2 = colorReg2;
|
||||
vtf.sceneUv = v.uvIn.xy;
|
||||
vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;
|
||||
vtf.shiftUv = (mul(float3x3(shiftMtx[0].xyz, shiftMtx[1].xyz, shiftMtx[2].xyz), v.uvIn.xyz)).xy;
|
||||
vtf.shiftScale = shiftScale.xy;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
Texture2D sceneTex : register(t0);
|
||||
Texture2D shiftTex : register(t1);
|
||||
SamplerState samp : register(s3);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float3x3 indMtx : INDMTX;
|
||||
float4 colorReg0 : COLORREG0;
|
||||
float4 colorReg1 : COLORREG1;
|
||||
float4 colorReg2 : COLORREG2;
|
||||
float2 sceneUv : SCENEUV;
|
||||
float2 shiftUv : SHIFTUV;
|
||||
float2 shiftScale : SHIFTSCALE;
|
||||
};
|
||||
|
||||
static const float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float2 shiftCoordTexel = shiftTex.Sample(samp, vtf.shiftUv).xy;
|
||||
float2 shiftCoord = vtf.sceneUv + shiftCoordTexel * vtf.shiftScale;
|
||||
float shiftScene0 = dot(sceneTex.Sample(samp, shiftCoord), kRGBToYPrime);
|
||||
float shiftScene1 = dot(sceneTex.Sample(samp, shiftCoord + float2(vtf.shiftScale.x / 8.0, 0.0)), kRGBToYPrime);
|
||||
float2 indCoord = (mul(vtf.indMtx, float3(shiftScene0 - 0.5, shiftScene1 - 0.5, 1.0))).xy;
|
||||
float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);
|
||||
return vtf.colorReg0 * indScene + vtf.colorReg1 * shiftScene0 + vtf.colorReg2;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct ThermalColdUniform
|
||||
{
|
||||
float4x4 shiftMtx;
|
||||
float4x4 indMtx;
|
||||
float4 shiftScale;
|
||||
float4 colorReg0;
|
||||
float4 colorReg1;
|
||||
float4 colorReg2;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float3 indMtx0;
|
||||
float3 indMtx1;
|
||||
float3 indMtx2;
|
||||
float4 colorReg0;
|
||||
float4 colorReg1;
|
||||
float4 colorReg2;
|
||||
float2 sceneUv;
|
||||
float2 shiftUv;
|
||||
float2 shiftScale;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ThermalColdUniform& tcu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.indMtx0 = tcu.indMtx[0].xyz;
|
||||
vtf.indMtx1 = tcu.indMtx[1].xyz;
|
||||
vtf.indMtx2 = tcu.indMtx[2].xyz;
|
||||
vtf.colorReg0 = tcu.colorReg0;
|
||||
vtf.colorReg1 = tcu.colorReg1;
|
||||
vtf.colorReg2 = tcu.colorReg2;
|
||||
vtf.sceneUv = v.uvIn.xy;
|
||||
vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;
|
||||
vtf.shiftUv = (float3x3(tcu.shiftMtx[0].xyz, tcu.shiftMtx[1].xyz, tcu.shiftMtx[2].xyz) * v.uvIn.xyz).xy;
|
||||
vtf.shiftScale = tcu.shiftScale.xy;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float3 indMtx0;
|
||||
float3 indMtx1;
|
||||
float3 indMtx2;
|
||||
float4 colorReg0;
|
||||
float4 colorReg1;
|
||||
float4 colorReg2;
|
||||
float2 sceneUv;
|
||||
float2 shiftUv;
|
||||
float2 shiftScale;
|
||||
};
|
||||
|
||||
constant float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(3) ]],
|
||||
texture2d<float> sceneTex [[ texture(0) ]],
|
||||
texture2d<float> shiftTex [[ texture(1) ]])
|
||||
{
|
||||
float2 shiftCoordTexel = shiftTex.sample(samp, vtf.shiftUv).xy;
|
||||
float2 shiftCoord = vtf.sceneUv + shiftCoordTexel * vtf.shiftScale;
|
||||
float shiftScene0 = dot(sceneTex.sample(samp, shiftCoord), kRGBToYPrime);
|
||||
float shiftScene1 = dot(sceneTex.sample(samp, shiftCoord + float2(vtf.shiftScale.x / 8.0, 0.0)), kRGBToYPrime);
|
||||
float2 indCoord = (float3x3(vtf.indMtx0, vtf.indMtx1, vtf.indMtx2) * float3(shiftScene0 - 0.5, shiftScene1 - 0.5, 1.0)).xy;
|
||||
float indScene = dot(sceneTex.sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);
|
||||
return vtf.colorReg0 * indScene + vtf.colorReg1 * shiftScene0 + vtf.colorReg2;
|
||||
}
|
||||
144
Shaders/CThermalHotFilter.shader
Normal file
144
Shaders/CThermalHotFilter.shader
Normal file
@@ -0,0 +1,144 @@
|
||||
#shader CThermalHotFilter
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac dstalpha
|
||||
#dstfac invdstalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform ThermalHotUniform
|
||||
{
|
||||
vec4 colorReg0;
|
||||
vec4 colorReg1;
|
||||
vec4 colorReg2;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 sceneUv;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.sceneUv = uvIn.xy;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 sceneUv;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D sceneTex;
|
||||
TBINDING1 uniform sampler2D paletteTex;
|
||||
const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
|
||||
void main()
|
||||
{
|
||||
float sceneSample = dot(texture(sceneTex, vtf.sceneUv), kRGBToYPrime);
|
||||
vec4 colorSample = texture(paletteTex, vec2(sceneSample / 17.0, 0.5));
|
||||
colorOut = vec4((colorSample * sceneSample).rgb, 0.0);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer ThermalHotUniform : register(b0)
|
||||
{
|
||||
float4 colorReg0;
|
||||
float4 colorReg1;
|
||||
float4 colorReg2;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 sceneUv : UV;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.sceneUv = v.uvIn.xy;
|
||||
vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
Texture2D sceneTex : register(t0);
|
||||
Texture2D paletteTex : register(t1);
|
||||
SamplerState samp : register(s0);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 sceneUv : UV;
|
||||
};
|
||||
|
||||
static const float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime);
|
||||
float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 17.0, 0.5));
|
||||
return float4((colorSample * sceneSample).rgb, 0.0);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct ThermalHotUniform
|
||||
{
|
||||
float4 colorReg0;
|
||||
float4 colorReg1;
|
||||
float4 colorReg2;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 sceneUv;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ThermalHotUniform& thu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.sceneUv = v.uvIn.xy;
|
||||
vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 sceneUv;
|
||||
};
|
||||
|
||||
constant float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> sceneTex [[ texture(0) ]],
|
||||
texture2d<float> paletteTex [[ texture(1) ]])
|
||||
{
|
||||
float sceneSample = dot(sceneTex.sample(samp, vtf.sceneUv), kRGBToYPrime);
|
||||
float4 colorSample = paletteTex.sample(samp, float2(sceneSample / 17.0, 0.5));
|
||||
return float4((colorSample * sceneSample).rgb, 0.0);
|
||||
}
|
||||
122
Shaders/CWorldShadowShader.shader
Normal file
122
Shaders/CWorldShadowShader.shader
Normal file
@@ -0,0 +1,122 @@
|
||||
#shader CWorldShadowShader
|
||||
#attribute position4
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
|
||||
UBINDING0 uniform ColoredQuadUniform
|
||||
{
|
||||
mat4 xf;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = color;
|
||||
gl_Position = xf * vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
};
|
||||
|
||||
cbuffer ColoredQuadUniform : register(b0)
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = color;
|
||||
vtf.position = mul(xf, float4(v.posIn.xyz, 1.0));
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
};
|
||||
|
||||
struct ColoredQuadUniform
|
||||
{
|
||||
float4x4 xf;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ColoredQuadUniform& cqu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = cqu.color;
|
||||
vtf.position = cqu.xf * float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
{
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#shader CWorldShadowShaderZ : CWorldShadowShader
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
254
Shaders/CXRayBlurFilter.shader
Normal file
254
Shaders/CXRayBlurFilter.shader
Normal file
@@ -0,0 +1,254 @@
|
||||
#shader CXRayBlurFilter
|
||||
#attribute position4
|
||||
#attribute uv4
|
||||
#srcfac one
|
||||
#dstfac zero
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform XRayBlurUniform
|
||||
{
|
||||
mat4 uv0;
|
||||
mat4 uv1;
|
||||
mat4 uv2;
|
||||
mat4 uv3;
|
||||
mat4 uv4;
|
||||
mat4 uv5;
|
||||
mat4 uv6;
|
||||
mat4 uv7;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 uv0;
|
||||
vec2 uv1;
|
||||
vec2 uv2;
|
||||
vec2 uv3;
|
||||
vec2 uv4;
|
||||
vec2 uv5;
|
||||
vec2 uv6;
|
||||
vec2 uv7;
|
||||
};
|
||||
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.uv0 = (uv0 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv1 = (uv1 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv2 = (uv2 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv3 = (uv3 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv4 = (uv4 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv5 = (uv5 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv6 = (uv6 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv7 = (uv7 * vec4(uvIn.xy, 0.0, 1.0)).xy;
|
||||
gl_Position = vec4(posIn.xyz, 1.0);
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
{
|
||||
vec2 uv0;
|
||||
vec2 uv1;
|
||||
vec2 uv2;
|
||||
vec2 uv3;
|
||||
vec2 uv4;
|
||||
vec2 uv5;
|
||||
vec2 uv6;
|
||||
vec2 uv7;
|
||||
};
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D sceneTex;
|
||||
TBINDING1 uniform sampler2D paletteTex;
|
||||
const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
|
||||
void main()
|
||||
{
|
||||
vec4 colorSample = texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv4), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv5), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv6), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv7), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorOut = colorSample;
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn : POSITION;
|
||||
float4 uvIn : UV;
|
||||
};
|
||||
|
||||
cbuffer XRayBlurUniform : register(b0)
|
||||
{
|
||||
float4x4 uv0;
|
||||
float4x4 uv1;
|
||||
float4x4 uv2;
|
||||
float4x4 uv3;
|
||||
float4x4 uv4;
|
||||
float4x4 uv5;
|
||||
float4x4 uv6;
|
||||
float4x4 uv7;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv0 : UV0;
|
||||
float2 uv1 : UV1;
|
||||
float2 uv2 : UV2;
|
||||
float2 uv3 : UV3;
|
||||
float2 uv4 : UV4;
|
||||
float2 uv5 : UV5;
|
||||
float2 uv6 : UV6;
|
||||
float2 uv7 : UV7;
|
||||
};
|
||||
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uv0 = mul(uv0, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv0.y = 1.0 - vtf.uv0.y;
|
||||
vtf.uv1 = mul(uv1, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv1.y = 1.0 - vtf.uv1.y;
|
||||
vtf.uv2 = mul(uv2, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv2.y = 1.0 - vtf.uv2.y;
|
||||
vtf.uv3 = mul(uv3, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv3.y = 1.0 - vtf.uv3.y;
|
||||
vtf.uv4 = mul(uv4, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv4.y = 1.0 - vtf.uv4.y;
|
||||
vtf.uv5 = mul(uv5, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv5.y = 1.0 - vtf.uv5.y;
|
||||
vtf.uv6 = mul(uv6, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv6.y = 1.0 - vtf.uv6.y;
|
||||
vtf.uv7 = mul(uv7, float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv7.y = 1.0 - vtf.uv7.y;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
Texture2D sceneTex : register(t0);
|
||||
Texture2D paletteTex : register(t1);
|
||||
SamplerState samp : register(s3);
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv0 : UV0;
|
||||
float2 uv1 : UV1;
|
||||
float2 uv2 : UV2;
|
||||
float2 uv3 : UV3;
|
||||
float2 uv4 : UV4;
|
||||
float2 uv5 : UV5;
|
||||
float2 uv6 : UV6;
|
||||
float2 uv7 : UV7;
|
||||
};
|
||||
|
||||
static const float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float4 colorSample = paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv4), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv5), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv6), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv7), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
return colorSample;
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
struct VertData
|
||||
{
|
||||
float4 posIn [[ attribute(0) ]];
|
||||
float4 uvIn [[ attribute(1) ]];
|
||||
};
|
||||
|
||||
struct XRayBlurUniform
|
||||
{
|
||||
float4x4 uv0;
|
||||
float4x4 uv1;
|
||||
float4x4 uv2;
|
||||
float4x4 uv3;
|
||||
float4x4 uv4;
|
||||
float4x4 uv5;
|
||||
float4x4 uv6;
|
||||
float4x4 uv7;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 uv0;
|
||||
float2 uv1;
|
||||
float2 uv2;
|
||||
float2 uv3;
|
||||
float2 uv4;
|
||||
float2 uv5;
|
||||
float2 uv6;
|
||||
float2 uv7;
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(VertData v [[ stage_in ]], constant XRayBlurUniform& xbu [[ buffer(2) ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.uv0 = (xbu.uv0 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv0.y = 1.0 - vtf.uv0.y;
|
||||
vtf.uv1 = (xbu.uv1 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv1.y = 1.0 - vtf.uv1.y;
|
||||
vtf.uv2 = (xbu.uv2 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv2.y = 1.0 - vtf.uv2.y;
|
||||
vtf.uv3 = (xbu.uv3 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv3.y = 1.0 - vtf.uv3.y;
|
||||
vtf.uv4 = (xbu.uv4 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv4.y = 1.0 - vtf.uv4.y;
|
||||
vtf.uv5 = (xbu.uv5 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv5.y = 1.0 - vtf.uv5.y;
|
||||
vtf.uv6 = (xbu.uv6 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv6.y = 1.0 - vtf.uv6.y;
|
||||
vtf.uv7 = (xbu.uv7 * float4(v.uvIn.xy, 0.0, 1.0)).xy;
|
||||
vtf.uv7.y = 1.0 - vtf.uv7.y;
|
||||
vtf.position = float4(v.posIn.xyz, 1.0);
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float2 uv0;
|
||||
float2 uv1;
|
||||
float2 uv2;
|
||||
float2 uv3;
|
||||
float2 uv4;
|
||||
float2 uv5;
|
||||
float2 uv6;
|
||||
float2 uv7;
|
||||
};
|
||||
|
||||
constant float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(3) ]],
|
||||
texture2d<float> sceneTex [[ texture(0) ]],
|
||||
texture2d<float> paletteTex [[ texture(1) ]])
|
||||
{
|
||||
float4 colorSample = paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv4), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv5), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv6), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv7), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;
|
||||
return colorSample;
|
||||
}
|
||||
17
Shaders/shader_CFluidPlaneShader.cpp
Normal file
17
Shaders/shader_CFluidPlaneShader.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "shader_CFluidPlaneShader.hpp"
|
||||
|
||||
const boo::VertexElementDescriptor Shader_CFluidPlaneShader::VtxFmtElems[5] =
|
||||
{
|
||||
{boo::VertexSemantic::Position4},
|
||||
{boo::VertexSemantic::Normal4, 0},
|
||||
{boo::VertexSemantic::Normal4, 1},
|
||||
{boo::VertexSemantic::Normal4, 2},
|
||||
{boo::VertexSemantic::Color}
|
||||
};
|
||||
|
||||
const boo::VertexElementDescriptor Shader_CFluidPlaneShader::TessVtxFmtElems[3] =
|
||||
{
|
||||
{boo::VertexSemantic::Position4},
|
||||
{boo::VertexSemantic::UV4, 0},
|
||||
{boo::VertexSemantic::UV4, 1}
|
||||
};
|
||||
131
Shaders/shader_CFluidPlaneShader.hpp
Normal file
131
Shaders/shader_CFluidPlaneShader.hpp
Normal file
@@ -0,0 +1,131 @@
|
||||
#pragma once
|
||||
#include "hecl/PipelineBase.hpp"
|
||||
#include "athena/Global.hpp"
|
||||
#include "hecl/hecl.hpp"
|
||||
|
||||
#ifndef URDE_MAX_LIGHTS
|
||||
#define URDE_MAX_LIGHTS 8
|
||||
#endif
|
||||
|
||||
enum class EFluidType
|
||||
{
|
||||
NormalWater,
|
||||
PoisonWater,
|
||||
Lava,
|
||||
PhazonFluid,
|
||||
Four,
|
||||
ThickLava
|
||||
};
|
||||
|
||||
struct SFluidPlaneShaderInfo
|
||||
{
|
||||
EFluidType m_type;
|
||||
bool m_hasPatternTex1;
|
||||
bool m_hasPatternTex2;
|
||||
bool m_hasColorTex;
|
||||
bool m_hasBumpMap;
|
||||
bool m_hasEnvMap;
|
||||
bool m_hasEnvBumpMap;
|
||||
bool m_hasLightmap;
|
||||
bool m_tessellation;
|
||||
bool m_doubleLightmapBlend;
|
||||
bool m_additive;
|
||||
|
||||
SFluidPlaneShaderInfo(EFluidType type, bool hasPatternTex1, bool hasPatternTex2, bool hasColorTex,
|
||||
bool hasBumpMap, bool hasEnvMap, bool hasEnvBumpMap, bool hasLightmap,
|
||||
bool tessellation, bool doubleLightmapBlend, bool additive)
|
||||
: m_type(type), m_hasPatternTex1(hasPatternTex1), m_hasPatternTex2(hasPatternTex2), m_hasColorTex(hasColorTex),
|
||||
m_hasBumpMap(hasBumpMap), m_hasEnvMap(hasEnvMap), m_hasEnvBumpMap(hasEnvBumpMap), m_hasLightmap(hasLightmap),
|
||||
m_tessellation(tessellation), m_doubleLightmapBlend(doubleLightmapBlend), m_additive(additive)
|
||||
{}
|
||||
};
|
||||
|
||||
struct SFluidPlaneDoorShaderInfo
|
||||
{
|
||||
bool m_hasPatternTex1;
|
||||
bool m_hasPatternTex2;
|
||||
bool m_hasColorTex;
|
||||
|
||||
SFluidPlaneDoorShaderInfo(bool hasPatternTex1, bool hasPatternTex2, bool hasColorTex)
|
||||
: m_hasPatternTex1(hasPatternTex1), m_hasPatternTex2(hasPatternTex2), m_hasColorTex(hasColorTex)
|
||||
{}
|
||||
};
|
||||
|
||||
class Shader_CFluidPlaneShader : public hecl::TessellationShader
|
||||
{
|
||||
friend class Shader_CFluidPlaneDoorShader;
|
||||
static const boo::VertexElementDescriptor VtxFmtElems[5];
|
||||
static const boo::VertexElementDescriptor TessVtxFmtElems[3];
|
||||
const SFluidPlaneShaderInfo& m_info;
|
||||
public:
|
||||
Shader_CFluidPlaneShader(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
: m_info(in), VtxFmt(tessellation ? TessVtxFmtElems : VtxFmtElems),
|
||||
PipelineInfo({in.m_additive ? boo::BlendFactor::One : boo::BlendFactor::SrcAlpha,
|
||||
in.m_additive ? boo::BlendFactor::One : boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
|
||||
boo::CullMode::None, tessellation ? 1 : 0}),
|
||||
HasTessellation(tessellation) {}
|
||||
|
||||
const boo::VertexFormatInfo VtxFmt;
|
||||
const boo::AdditionalPipelineInfo PipelineInfo;
|
||||
bool HasTessellation;
|
||||
static constexpr bool HasHash = false;
|
||||
static constexpr uint64_t Hash() { return 0; }
|
||||
const SFluidPlaneShaderInfo& info() const { return m_info; }
|
||||
};
|
||||
|
||||
template<typename P, typename S>
|
||||
class StageObject_CFluidPlaneShader : public hecl::StageBinary<P, S>
|
||||
{
|
||||
static std::string BuildShader(const SFluidPlaneShaderInfo& in, bool tessellation);
|
||||
public:
|
||||
StageObject_CFluidPlaneShader(hecl::StageConverter<P, S>& conv, hecl::FactoryCtx& ctx,
|
||||
const Shader_CFluidPlaneShader& in)
|
||||
: hecl::StageBinary<P, S>(conv, ctx, hecl::StageSourceText<P, S>(BuildShader(in.info(), in.HasTessellation))) {}
|
||||
};
|
||||
|
||||
class Shader_CFluidPlaneDoorShader : public hecl::GeneralShader
|
||||
{
|
||||
const SFluidPlaneDoorShaderInfo& m_info;
|
||||
public:
|
||||
explicit Shader_CFluidPlaneDoorShader(const SFluidPlaneDoorShaderInfo& in)
|
||||
: m_info(in), VtxFmt(Shader_CFluidPlaneShader::VtxFmtElems),
|
||||
PipelineInfo({boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
|
||||
boo::CullMode::None}) {}
|
||||
|
||||
const boo::VertexFormatInfo VtxFmt;
|
||||
const boo::AdditionalPipelineInfo PipelineInfo;
|
||||
static constexpr bool HasHash = false;
|
||||
static constexpr uint64_t Hash() { return 0; }
|
||||
const SFluidPlaneDoorShaderInfo& info() const { return m_info; }
|
||||
};
|
||||
|
||||
template<typename P, typename S>
|
||||
class StageObject_CFluidPlaneDoorShader : public hecl::StageBinary<P, S>
|
||||
{
|
||||
static std::string BuildShader(const SFluidPlaneDoorShaderInfo& in);
|
||||
public:
|
||||
StageObject_CFluidPlaneDoorShader(hecl::StageConverter<P, S>& conv, hecl::FactoryCtx& ctx,
|
||||
const Shader_CFluidPlaneDoorShader& in)
|
||||
: hecl::StageBinary<P, S>(conv, ctx, hecl::StageSourceText<P, S>(BuildShader(in.info()))) {}
|
||||
};
|
||||
|
||||
#define UNIVERSAL_PIPELINES_shader_CFluidPlaneShader \
|
||||
::Shader_CFluidPlaneShader \
|
||||
::Shader_CFluidPlaneDoorShader
|
||||
#define OPENGL_STAGES_shader_CFluidPlaneShader \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneShader, hecl::PlatformType::OpenGL) \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneDoorShader, hecl::PlatformType::OpenGL)
|
||||
#define VULKAN_STAGES_shader_CFluidPlaneShader \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneShader, hecl::PlatformType::Vulkan) \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneDoorShader, hecl::PlatformType::Vulkan)
|
||||
#define D3D11_STAGES_shader_CFluidPlaneShader \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneShader, hecl::PlatformType::D3D11) \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneDoorShader, hecl::PlatformType::D3D11)
|
||||
#define METAL_STAGES_shader_CFluidPlaneShader \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneShader, hecl::PlatformType::Metal) \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneDoorShader, hecl::PlatformType::Metal)
|
||||
#define NX_STAGES_shader_CFluidPlaneShader \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneShader, hecl::PlatformType::NX) \
|
||||
STAGE_SPECIALIZATIONS(::StageObject_CFluidPlaneDoorShader, hecl::PlatformType::NX)
|
||||
832
Shaders/shader_CFluidPlaneShaderGLSL.cpp
Normal file
832
Shaders/shader_CFluidPlaneShaderGLSL.cpp
Normal file
@@ -0,0 +1,832 @@
|
||||
#include "shader_CFluidPlaneShader.hpp"
|
||||
|
||||
static const char* VS =
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec4 normalIn;\n"
|
||||
"layout(location=2) in vec4 binormalIn;\n"
|
||||
"layout(location=3) in vec4 tangentIn;\n"
|
||||
"layout(location=4) in vec4 colorIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform FluidPlaneUniform\n"
|
||||
"{\n"
|
||||
" mat4 mv;\n"
|
||||
" mat4 mvNorm;\n"
|
||||
" mat4 proj;\n"
|
||||
" mat4 texMtxs[6];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 mvPos;\n"
|
||||
" vec4 mvNorm;\n"
|
||||
" vec4 mvBinorm;\n"
|
||||
" vec4 mvTangent;\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uvs[7];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 pos = vec4(posIn.xyz, 1.0);\n"
|
||||
" vtf.mvPos = mv * pos;\n"
|
||||
" gl_Position = proj * vtf.mvPos;\n"
|
||||
" vtf.mvNorm = mvNorm * normalIn;\n"
|
||||
" vtf.mvBinorm = mvNorm * binormalIn;\n"
|
||||
" vtf.mvTangent = mvNorm * tangentIn;\n"
|
||||
" vtf.color = vec4(colorIn.xyz, 1.0);\n"
|
||||
" vtf.uvs[0] = (texMtxs[0] * pos).xy;\n"
|
||||
" vtf.uvs[1] = (texMtxs[1] * pos).xy;\n"
|
||||
" vtf.uvs[2] = (texMtxs[2] * pos).xy;\n"
|
||||
"%s" // Additional TCGs here
|
||||
"}\n";
|
||||
|
||||
static const char* TessVS =
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec4 outerLevelsIn;\n"
|
||||
"layout(location=2) in vec2 innerLevelsIn;\n"
|
||||
"\n"
|
||||
"struct VertToControl\n"
|
||||
"{\n"
|
||||
" vec4 minMaxPos;\n"
|
||||
" vec4 outerLevels;\n"
|
||||
" vec2 innerLevels;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToControl vtc;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtc.minMaxPos = posIn;\n"
|
||||
" vtc.outerLevels = outerLevelsIn;\n"
|
||||
" vtc.innerLevels = innerLevelsIn;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* TessCS =
|
||||
"#extension GL_ARB_tessellation_shader: enable\n"
|
||||
"layout(vertices = 1) out;\n"
|
||||
"\n"
|
||||
"struct VertToControl\n"
|
||||
"{\n"
|
||||
" vec4 minMaxPos;\n"
|
||||
" vec4 outerLevels;\n"
|
||||
" vec2 innerLevels;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToControl vtc[];\n"
|
||||
"SBINDING(0) patch out vec4 minMaxPos;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" minMaxPos = vtc[gl_InvocationID].minMaxPos;\n"
|
||||
" for (int i=0 ; i<4 ; ++i)\n"
|
||||
" gl_TessLevelOuter[i] = vtc[gl_InvocationID].outerLevels[i];\n"
|
||||
" for (int i=0 ; i<2 ; ++i)\n"
|
||||
" gl_TessLevelInner[i] = vtc[gl_InvocationID].innerLevels[i];\n"
|
||||
"}";
|
||||
|
||||
static const char* TessES =
|
||||
"#extension GL_ARB_tessellation_shader: enable\n"
|
||||
"layout(quads, equal_spacing) in;\n"
|
||||
"\n"
|
||||
"struct Ripple\n"
|
||||
"{\n"
|
||||
" vec4 center; // time, distFalloff\n"
|
||||
" vec4 params; // amplitude, lookupPhase, lookupTime\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform FluidPlaneUniform\n"
|
||||
"{\n"
|
||||
" mat4 mv;\n"
|
||||
" mat4 mvNorm;\n"
|
||||
" mat4 proj;\n"
|
||||
" mat4 texMtxs[6];\n"
|
||||
" Ripple ripples[20];\n"
|
||||
" vec4 colorMul;\n"
|
||||
" float rippleNormResolution;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 mvPos;\n"
|
||||
" vec4 mvNorm;\n"
|
||||
" vec4 mvBinorm;\n"
|
||||
" vec4 mvTangent;\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uvs[7];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) patch in vec4 minMaxPos;\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"\n"
|
||||
"TBINDING%d uniform sampler2D RippleMap;\n"
|
||||
"\n"
|
||||
"const float PI_X2 = 6.283185307179586;\n"
|
||||
"\n"
|
||||
"void ApplyRipple(in Ripple ripple, in vec2 pos, inout float height)\n"
|
||||
"{\n"
|
||||
" float dist = length(ripple.center.xy - pos);\n"
|
||||
" float rippleV = textureLod(RippleMap, vec2(dist * ripple.center.w, ripple.center.z), 0.0).r;\n"
|
||||
" height += rippleV * ripple.params.x * sin((dist * ripple.params.y + ripple.params.z) * PI_X2);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 posIn = vec2(mix(minMaxPos.x, minMaxPos.z, gl_TessCoord.x),\n"
|
||||
" mix(minMaxPos.y, minMaxPos.w, gl_TessCoord.y));\n"
|
||||
" float height = 0.0;\n"
|
||||
" float upHeight = 0.0;\n"
|
||||
" float downHeight = 0.0;\n"
|
||||
" float rightHeight = 0.0;\n"
|
||||
" float leftHeight = 0.0;\n"
|
||||
" for (int i=0 ; i<20 ; ++i)\n"
|
||||
" {\n"
|
||||
" ApplyRipple(ripples[i], posIn, height);\n"
|
||||
" ApplyRipple(ripples[i], posIn + vec2(0.0, rippleNormResolution), upHeight);\n"
|
||||
" ApplyRipple(ripples[i], posIn - vec2(0.0, rippleNormResolution), downHeight);\n"
|
||||
" ApplyRipple(ripples[i], posIn + vec2(rippleNormResolution, 0.0), rightHeight);\n"
|
||||
" ApplyRipple(ripples[i], posIn - vec2(rippleNormResolution, 0.0), leftHeight);\n"
|
||||
" }\n"
|
||||
" vec4 normalIn = vec4(normalize(vec3((leftHeight - rightHeight),\n"
|
||||
" (downHeight - upHeight),\n"
|
||||
" rippleNormResolution)), 1.0);\n"
|
||||
" vec4 binormalIn = vec4(normalIn.x, normalIn.z, -normalIn.y, 1.0);\n"
|
||||
" vec4 tangentIn = vec4(normalIn.z, normalIn.y, -normalIn.x, 1.0);\n"
|
||||
" vec4 pos = vec4(posIn, height, 1.0);\n"
|
||||
" vtf.mvPos = mv * pos;\n"
|
||||
" gl_Position = proj * vtf.mvPos;\n"
|
||||
" vtf.mvNorm = mvNorm * normalIn;\n"
|
||||
" vtf.mvBinorm = mvNorm * binormalIn;\n"
|
||||
" vtf.mvTangent = mvNorm * tangentIn;\n"
|
||||
" vtf.color = max(height, 0.0) * colorMul;\n"
|
||||
" vtf.color.a = 1.0;\n"
|
||||
" vtf.uvs[0] = (texMtxs[0] * pos).xy;\n"
|
||||
" vtf.uvs[1] = (texMtxs[1] * pos).xy;\n"
|
||||
" vtf.uvs[2] = (texMtxs[2] * pos).xy;\n"
|
||||
"%s\n" // Additional TCGs here
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" vec4 pos;\n"
|
||||
" vec4 dir;\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 linAtt;\n"
|
||||
" vec4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" vec4 color;\n"
|
||||
" float indScale;\n"
|
||||
" float start;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"UBINDING2 uniform LightingUniform\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" vec4 ambient;\n"
|
||||
" vec4 kColor0;\n"
|
||||
" vec4 kColor1;\n"
|
||||
" vec4 kColor2;\n"
|
||||
" vec4 kColor3;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vec4 LightingFunc(vec3 mvPosIn, vec3 mvNormIn)\n"
|
||||
"{\n"
|
||||
" vec4 ret = ambient;\n"
|
||||
" \n"
|
||||
" for (int i=0 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" vec3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = clamp(dot(normalize(delta), lights[i].dir.xyz), 0.0, 1.0);\n"
|
||||
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lights[i].linAtt[1] * dist +\n"
|
||||
" lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[i].angAtt[1] * angDot +\n"
|
||||
" lights[i].angAtt[0];\n"
|
||||
" ret += lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return ret;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 mvPos;\n"
|
||||
" vec4 mvNorm;\n"
|
||||
" vec4 mvBinorm;\n"
|
||||
" vec4 mvTangent;\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uvs[7];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"%s" // Textures here
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 lighting = LightingFunc(vtf.mvPos.xyz, normalize(vtf.mvNorm.xyz));\n"
|
||||
"%s" // Combiner expression here
|
||||
"}\n";
|
||||
|
||||
static const char* FSDoor =
|
||||
"\n"
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" vec4 pos;\n"
|
||||
" vec4 dir;\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 linAtt;\n"
|
||||
" vec4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" vec4 color;\n"
|
||||
" float indScale;\n"
|
||||
" float start;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"UBINDING2 uniform LightingUniform\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" vec4 ambient;\n"
|
||||
" vec4 kColor0;\n"
|
||||
" vec4 kColor1;\n"
|
||||
" vec4 kColor2;\n"
|
||||
" vec4 kColor3;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 mvPos;\n"
|
||||
" vec4 mvNorm;\n"
|
||||
" vec4 mvBinorm;\n"
|
||||
" vec4 mvTangent;\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uvs[7];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"%s" // Textures here
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"%s" // Combiner expression here
|
||||
"}\n";
|
||||
|
||||
static std::string _BuildFS(const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
std::string textures;
|
||||
std::string combiner;
|
||||
int nextTex = 0;
|
||||
int nextTCG = 3;
|
||||
int bumpMapUv, envBumpMapUv, envMapUv, lightmapUv;
|
||||
|
||||
if (info.m_hasPatternTex1)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D patternTex1;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D patternTex2;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasColorTex)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D colorTex;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D bumpMap;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasEnvMap)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D envMap;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasEnvBumpMap)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D envBumpMap;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D lightMap;\n", nextTex++);
|
||||
}
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
bumpMapUv = nextTCG++;
|
||||
}
|
||||
if (info.m_hasEnvBumpMap)
|
||||
{
|
||||
envBumpMapUv = nextTCG++;
|
||||
}
|
||||
if (info.m_hasEnvMap)
|
||||
{
|
||||
envMapUv = nextTCG++;
|
||||
}
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
lightmapUv = nextTCG;
|
||||
}
|
||||
|
||||
switch (info.m_type)
|
||||
{
|
||||
case EFluidType::NormalWater:
|
||||
case EFluidType::PhazonFluid:
|
||||
case EFluidType::Four:
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
combiner += hecl::Format(" vec4 lightMapTexel = texture(lightMap, vtf.uvs[%d]);\n", lightmapUv);
|
||||
// 0: Tex4TCG, Tex4, doubleLightmapBlend ? NULL : GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, doubleLightmapBlend ? ZERO : RAS
|
||||
// Output reg 2
|
||||
// KColor 2
|
||||
if (info.m_doubleLightmapBlend)
|
||||
{
|
||||
// 1: Tex4TCG2, Tex4, GX_COLOR1A1
|
||||
// C2, TEX, KONST, RAS
|
||||
// Output reg 2
|
||||
// KColor 3
|
||||
// Tex * K2 + Lighting
|
||||
combiner += " lighting += mix(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// mix(Tex * K2, Tex, K3) + Lighting
|
||||
combiner += " lighting += lightMapTexel * kColor2;\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Next: Tex0TCG, Tex0, GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// Next: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// Next: Tex2TCG, Tex2, GX_COLOR1A1
|
||||
// ZERO, TEX, hasTex4 ? C2 : RAS, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + Lighting) * Tex1 + VertColor + Tex2 * Lighting
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (texture(patternTex1, vtf.uvs[0]) * kColor0 + lighting) *\n"
|
||||
" texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = lighting * texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
|
||||
if (info.m_hasColorTex && !info.m_hasEnvMap && info.m_hasEnvBumpMap)
|
||||
{
|
||||
// Make previous stage indirect, mtx0
|
||||
combiner += hecl::Format(" vec2 indUvs = (texture(envBumpMap, vtf.uvs[%d]).ra - vec2(0.5, 0.5)) *\n"
|
||||
" vec2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
||||
combiner += " colorOut += texture(colorTex, indUvs + vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
else if (info.m_hasEnvMap)
|
||||
{
|
||||
// Next: envTCG, envTex, NULL
|
||||
// PREV, TEX, KONST, ZERO
|
||||
// Output reg prev
|
||||
// KColor 1
|
||||
|
||||
// Make previous stage indirect, mtx0
|
||||
if (info.m_hasColorTex)
|
||||
combiner += " colorOut += texture(colorTex, vtf.uvs[2]) * lighting;\n";
|
||||
combiner += hecl::Format(" vec2 indUvs = (texture(envBumpMap, vtf.uvs[%d]).ra - vec2(0.5, 0.5)) *\n"
|
||||
" vec2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
||||
combiner += hecl::Format(" colorOut = mix(colorOut, texture(envMap, indUvs + vtf.uvs[%d]), kColor1);\n",
|
||||
envMapUv);
|
||||
}
|
||||
else if (info.m_hasColorTex)
|
||||
{
|
||||
combiner += " colorOut += texture(colorTex, vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::PoisonWater:
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
combiner += hecl::Format(" vec4 lightMapTexel = texture(lightMap, vtf.uvs[%d]);\n", lightmapUv);
|
||||
// 0: Tex4TCG, Tex4, doubleLightmapBlend ? NULL : GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, doubleLightmapBlend ? ZERO : RAS
|
||||
// Output reg 2
|
||||
// KColor 2
|
||||
if (info.m_doubleLightmapBlend)
|
||||
{
|
||||
// 1: Tex4TCG2, Tex4, GX_COLOR1A1
|
||||
// C2, TEX, KONST, RAS
|
||||
// Output reg 2
|
||||
// KColor 3
|
||||
// Tex * K2 + Lighting
|
||||
combiner += " lighting += mix(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// mix(Tex * K2, Tex, K3) + Lighting
|
||||
combiner += " lighting += lightMapTexel * kColor2;\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Next: Tex0TCG, Tex0, GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// Next: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// Next: Tex2TCG, Tex2, GX_COLOR1A1
|
||||
// ZERO, TEX, hasTex4 ? C2 : RAS, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + Lighting) * Tex1 + VertColor + Tex2 * Lighting
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (texture(patternTex1, vtf.uvs[0]) * kColor0 + lighting) *\n"
|
||||
" texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = lighting * texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
if (info.m_hasColorTex)
|
||||
{
|
||||
if (info.m_hasEnvBumpMap)
|
||||
{
|
||||
// Make previous stage indirect, mtx0
|
||||
combiner += hecl::Format(" vec2 indUvs = (texture(envBumpMap, vtf.uvs[%d]).ra - vec2(0.5, 0.5)) *\n"
|
||||
" vec2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
||||
combiner += " colorOut += texture(colorTex, indUvs + vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut += texture(colorTex, vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::Lava:
|
||||
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// 1: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// 2: Tex2TCG, Tex2, NULL
|
||||
// ZERO, TEX, ONE, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + VertColor) * Tex1 + VertColor + Tex2
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (texture(patternTex1, vtf.uvs[0]) * kColor0 + vtf.color) *\n"
|
||||
" texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = vtf.color * texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
if (info.m_hasColorTex)
|
||||
combiner += " colorOut += texture(colorTex, vtf.uvs[2]);\n";
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
// 3: bumpMapTCG, bumpMap, NULL
|
||||
// ZERO, TEX, ONE, HALF
|
||||
// Output reg 0, no clamp, no bias
|
||||
|
||||
// 4: bumpMapTCG2, bumpMap, NULL
|
||||
// ZERO, TEX, ONE, C0
|
||||
// Output reg 0, subtract, clamp, no bias
|
||||
|
||||
combiner += " vec3 lightVec = lights[3].pos.xyz - vtf.mvPos.xyz;\n"
|
||||
" float lx = dot(vtf.mvTangent, lightVec);\n"
|
||||
" float ly = dot(vtf.mvBinorm, lightVec);\n";
|
||||
combiner += hecl::Format(" vec4 emboss1 = texture(bumpMap, vtf.uvs[%d]) + vec4(0.5);\n"
|
||||
" vec4 emboss2 = texture(bumpMap, vtf.uvs[%d] + vec2(lx, ly));\n",
|
||||
bumpMapUv, bumpMapUv);
|
||||
|
||||
// 5: NULL, NULL, NULL
|
||||
// ZERO, PREV, C0, ZERO
|
||||
// Output reg prev, scale 2, clamp
|
||||
|
||||
// colorOut * clamp(emboss1 + 0.5 - emboss2, 0.0, 1.0) * 2.0
|
||||
combiner += "colorOut *= clamp((emboss1 + vec4(0.5) - emboss2) * vec4(2.0), vec4(0.0), vec4(1.0));\n";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::ThickLava:
|
||||
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// 1: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// 2: Tex2TCG, Tex2, NULL
|
||||
// ZERO, TEX, ONE, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + VertColor) * Tex1 + VertColor + Tex2
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (texture(patternTex1, vtf.uvs[0]) * kColor0 + vtf.color) *\n"
|
||||
" texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = vtf.color * texture(patternTex2, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
if (info.m_hasColorTex)
|
||||
combiner += " colorOut += texture(colorTex, vtf.uvs[2]);\n";
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
// 3: bumpMapTCG, bumpMap, NULL
|
||||
// ZERO, TEX, PREV, ZERO
|
||||
// Output reg prev, scale 2
|
||||
combiner += hecl::Format(" vec4 emboss1 = texture(bumpMap, vtf.uvs[%d]) + vec4(0.5);\n", bumpMapUv);
|
||||
combiner += "colorOut *= emboss1 * vec4(2.0);\n";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
combiner += " colorOut.a = kColor0.a;\n";
|
||||
|
||||
char *finalFSs;
|
||||
asprintf(&finalFSs, FS, textures.c_str(), combiner.c_str());
|
||||
std::string ret(finalFSs);
|
||||
free(finalFSs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static std::string _BuildAdditionalTCGs(const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
std::string additionalTCGs;
|
||||
int nextTCG = 3;
|
||||
int nextMtx = 4;
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[0] * pos).xy;\n", nextTCG++);
|
||||
}
|
||||
if (info.m_hasEnvBumpMap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[3] * vec4(normalIn.xyz, 1.0)).xy;\n", nextTCG++);
|
||||
}
|
||||
if (info.m_hasEnvMap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[%d] * pos).xy;\n", nextTCG++, nextMtx++);
|
||||
}
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[%d] * pos).xy;\n", nextTCG, nextMtx);
|
||||
}
|
||||
|
||||
return additionalTCGs;
|
||||
}
|
||||
|
||||
static std::string _BuildVS(const SFluidPlaneShaderInfo& info, bool tessellation)
|
||||
{
|
||||
if (tessellation)
|
||||
return TessVS;
|
||||
|
||||
std::string additionalTCGs = _BuildAdditionalTCGs(info);
|
||||
|
||||
char *finalVSs;
|
||||
asprintf(&finalVSs, VS, additionalTCGs.c_str());
|
||||
std::string ret(finalVSs);
|
||||
free(finalVSs);
|
||||
return ret;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildVS(in, tessellation);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildVS(in, tessellation);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildVS(in, tessellation);
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Control>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return TessCS;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Control>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return TessCS;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Control>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return TessCS;
|
||||
}
|
||||
|
||||
static std::string BuildES(const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
int nextTex = 0;
|
||||
if (info.m_hasPatternTex1)
|
||||
nextTex++;
|
||||
if (info.m_hasPatternTex2)
|
||||
nextTex++;
|
||||
if (info.m_hasColorTex)
|
||||
nextTex++;
|
||||
if (info.m_hasBumpMap)
|
||||
nextTex++;
|
||||
if (info.m_hasEnvMap)
|
||||
nextTex++;
|
||||
if (info.m_hasEnvBumpMap)
|
||||
nextTex++;
|
||||
if (info.m_hasLightmap)
|
||||
nextTex++;
|
||||
|
||||
std::string additionalTCGs = _BuildAdditionalTCGs(info);
|
||||
|
||||
char *finalESs;
|
||||
asprintf(&finalESs, TessES, nextTex, additionalTCGs.c_str());
|
||||
std::string ret(finalESs);
|
||||
free(finalESs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Evaluation>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return BuildES(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Evaluation>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return BuildES(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Evaluation>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return BuildES(in);
|
||||
}
|
||||
|
||||
static std::string _BuildVS(const SFluidPlaneDoorShaderInfo& info)
|
||||
{
|
||||
char *finalVSs;
|
||||
asprintf(&finalVSs, VS, "");
|
||||
std::string ret(finalVSs);
|
||||
free(finalVSs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static std::string _BuildFS(const SFluidPlaneDoorShaderInfo& info)
|
||||
{
|
||||
int nextTex = 0;
|
||||
std::string textures;
|
||||
std::string combiner;
|
||||
|
||||
if (info.m_hasPatternTex1)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D patternTex1;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D patternTex2;\n", nextTex++);
|
||||
}
|
||||
if (info.m_hasColorTex)
|
||||
{
|
||||
textures += hecl::Format("TBINDING%d uniform sampler2D colorTex;\n", nextTex++);
|
||||
}
|
||||
|
||||
// Tex0 * kColor0 * Tex1 + Tex2
|
||||
if (info.m_hasPatternTex1 && info.m_hasPatternTex2)
|
||||
{
|
||||
combiner += " colorOut = texture(patternTex1, vtf.uvs[0]) * kColor0 *\n"
|
||||
" texture(patternTex2, vtf.uvs[1]);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vec4(0.0);\n";
|
||||
}
|
||||
|
||||
if (info.m_hasColorTex)
|
||||
{
|
||||
combiner += " colorOut += texture(colorTex, vtf.uvs[2]);\n";
|
||||
}
|
||||
|
||||
combiner += " colorOut.a = kColor0.a;\n";
|
||||
|
||||
char *finalFSs;
|
||||
asprintf(&finalFSs, FSDoor, textures.c_str(), combiner.c_str());
|
||||
std::string ret(finalFSs);
|
||||
free(finalFSs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneDoorShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneDoorShaderInfo& in)
|
||||
{
|
||||
return _BuildVS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneDoorShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneDoorShaderInfo& in)
|
||||
{
|
||||
return _BuildVS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneDoorShader<hecl::PlatformType::NX, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneDoorShaderInfo& in)
|
||||
{
|
||||
return _BuildVS(in);
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneDoorShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneDoorShaderInfo& in)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneDoorShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneDoorShaderInfo& in)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneDoorShader<hecl::PlatformType::NX, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneDoorShaderInfo& in)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
771
Shaders/shader_CFluidPlaneShaderHLSL.cpp
Normal file
771
Shaders/shader_CFluidPlaneShaderHLSL.cpp
Normal file
@@ -0,0 +1,771 @@
|
||||
#include "shader_CFluidPlaneShader.hpp"
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float4 normalIn : NORMAL0;\n"
|
||||
" float4 binormalIn : NORMAL1;\n"
|
||||
" float4 tangentIn : NORMAL2;\n"
|
||||
" float4 colorIn : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer FluidPlaneUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mv;\n"
|
||||
" float4x4 mvNorm;\n"
|
||||
" float4x4 proj;\n"
|
||||
" float4x4 texMtxs[6];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
" float4 mvPos : POSITION;\n"
|
||||
" float4 mvNorm : NORMAL;\n"
|
||||
" float4 mvBinorm : BINORMAL;\n"
|
||||
" float4 mvTangent : TANGENT;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uvs[7] : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" float4 pos = float4(v.posIn.xyz, 1.0);\n"
|
||||
" float4 normalIn = v.normalIn;\n"
|
||||
" vtf.mvPos = mul(mv, pos);\n"
|
||||
" vtf.pos = mul(proj, vtf.mvPos);\n"
|
||||
" vtf.mvNorm = mul(mvNorm, v.normalIn);\n"
|
||||
" vtf.mvBinorm = mul(mvNorm, v.binormalIn);\n"
|
||||
" vtf.mvTangent = mul(mvNorm, v.tangentIn);\n"
|
||||
" vtf.color = float4(v.colorIn.xyz, 1.0);\n"
|
||||
" vtf.uvs[0] = mul(texMtxs[0], pos).xy;\n"
|
||||
" vtf.uvs[1] = mul(texMtxs[1], pos).xy;\n"
|
||||
" vtf.uvs[2] = mul(texMtxs[2], pos).xy;\n"
|
||||
"%s" // Additional TCGs here
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* TessVS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float4 outerLevelsIn : UV0;\n"
|
||||
" float2 innerLevelsIn : UV1;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToControl\n"
|
||||
"{\n"
|
||||
" float4 minMaxPos : POSITION;\n"
|
||||
" float4 outerLevels : OUTERLEVELS;\n"
|
||||
" float2 innerLevels : INNERLEVELS;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToControl main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToControl vtc;\n"
|
||||
" vtc.minMaxPos = v.posIn;\n"
|
||||
" vtc.outerLevels = v.outerLevelsIn;\n"
|
||||
" vtc.innerLevels = v.innerLevelsIn;\n"
|
||||
" return vtc;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* TessCS =
|
||||
"struct VertToControl\n"
|
||||
"{\n"
|
||||
" float4 minMaxPos : POSITION;\n"
|
||||
" float4 outerLevels : OUTERLEVELS;\n"
|
||||
" float2 innerLevels : INNERLEVELS;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ControlToEvaluation\n"
|
||||
"{\n"
|
||||
" float4 minMaxPos : POSITION;\n"
|
||||
" float outerLevels[4] : SV_TessFactor;\n"
|
||||
" float innerLevels[2] : SV_InsideTessFactor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ControlPoint\n"
|
||||
"{};\n"
|
||||
"\n"
|
||||
"ControlToEvaluation patchmain(InputPatch<VertToControl, 1> vtc, uint id : SV_PrimitiveID)\n"
|
||||
"{\n"
|
||||
" ControlToEvaluation cte;\n"
|
||||
" cte.minMaxPos = vtc[id].minMaxPos;\n"
|
||||
" for (int i=0 ; i<4 ; ++i)\n"
|
||||
" cte.outerLevels[i] = vtc[id].outerLevels[i];\n"
|
||||
" for (int i=0 ; i<2 ; ++i)\n"
|
||||
" cte.innerLevels[i] = vtc[id].innerLevels[i];\n"
|
||||
" return cte;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"[domain(\"quad\")]\n"
|
||||
"[partitioning(\"integer\")]\n"
|
||||
"[outputtopology(\"triangle_cw\")]\n"
|
||||
"[outputcontrolpoints(1)]\n"
|
||||
"[patchconstantfunc(\"patchmain\")]\n"
|
||||
"ControlPoint main(InputPatch<VertToControl, 1> vtc, uint i : SV_OutputControlPointID, uint id : SV_PrimitiveID)\n"
|
||||
"{\n"
|
||||
" ControlPoint pt;\n"
|
||||
" return pt;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* TessES =
|
||||
"struct Ripple\n"
|
||||
"{\n"
|
||||
" float4 center; // time, distFalloff\n"
|
||||
" float4 params; // amplitude, lookupPhase, lookupTime\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer FluidPlaneUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mv;\n"
|
||||
" float4x4 mvNorm;\n"
|
||||
" float4x4 proj;\n"
|
||||
" float4x4 texMtxs[6];\n"
|
||||
" Ripple ripples[20];\n"
|
||||
" float4 colorMul;\n"
|
||||
" float rippleNormResolution;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
" float4 mvPos : POSITION;\n"
|
||||
" float4 mvNorm : NORMAL;\n"
|
||||
" float4 mvBinorm : BINORMAL;\n"
|
||||
" float4 mvTangent : TANGENT;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uvs[7] : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ControlToEvaluation\n"
|
||||
"{\n"
|
||||
" float4 minMaxPos : POSITION;\n"
|
||||
" float outerLevels[4] : SV_TessFactor;\n"
|
||||
" float innerLevels[2] : SV_InsideTessFactor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ControlPoint\n"
|
||||
"{};\n"
|
||||
"\n"
|
||||
"Texture2D RippleMap : register(t%d);\n"
|
||||
"SamplerState samp : register(s2);\n"
|
||||
"\n"
|
||||
"static const float PI_X2 = 6.283185307179586;\n"
|
||||
"\n"
|
||||
"static void ApplyRipple(in Ripple ripple, in float2 pos, inout float height)\n"
|
||||
"{\n"
|
||||
" float dist = length(ripple.center.xy - pos);\n"
|
||||
" float rippleV = RippleMap.SampleLevel(samp, float2(dist * ripple.center.w, ripple.center.z), 0.0).r;\n"
|
||||
" height += rippleV * ripple.params.x * sin((dist * ripple.params.y + ripple.params.z) * PI_X2);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"[domain(\"quad\")]\n"
|
||||
"VertToFrag main(in ControlToEvaluation cte, in float2 TessCoord : SV_DomainLocation,\n"
|
||||
" const OutputPatch<ControlPoint, 1> bezpatch)\n"
|
||||
"{\n"
|
||||
" float2 posIn = float2(lerp(cte.minMaxPos.x, cte.minMaxPos.z, TessCoord.x),\n"
|
||||
" lerp(cte.minMaxPos.y, cte.minMaxPos.w, TessCoord.y));\n"
|
||||
" float height = 0.0;\n"
|
||||
" float upHeight = 0.0;\n"
|
||||
" float downHeight = 0.0;\n"
|
||||
" float rightHeight = 0.0;\n"
|
||||
" float leftHeight = 0.0;\n"
|
||||
" for (int i=0 ; i<20 ; ++i)\n"
|
||||
" {\n"
|
||||
" ApplyRipple(ripples[i], posIn, height);\n"
|
||||
" ApplyRipple(ripples[i], posIn + float2(0.0, rippleNormResolution), upHeight);\n"
|
||||
" ApplyRipple(ripples[i], posIn - float2(0.0, rippleNormResolution), downHeight);\n"
|
||||
" ApplyRipple(ripples[i], posIn + float2(rippleNormResolution, 0.0), rightHeight);\n"
|
||||
" ApplyRipple(ripples[i], posIn - float2(rippleNormResolution, 0.0), leftHeight);\n"
|
||||
" }\n"
|
||||
" float4 normalIn = float4(normalize(float3((leftHeight - rightHeight),\n"
|
||||
" (downHeight - upHeight),\n"
|
||||
" rippleNormResolution)), 1.0);\n"
|
||||
" float4 binormalIn = float4(normalIn.x, normalIn.z, -normalIn.y, 1.0);\n"
|
||||
" float4 tangentIn = float4(normalIn.z, normalIn.y, -normalIn.x, 1.0);\n"
|
||||
" float4 pos = float4(posIn, height, 1.0);\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.mvPos = mul(mv, pos);\n"
|
||||
" vtf.pos = mul(proj, vtf.mvPos);\n"
|
||||
" vtf.mvNorm = mul(mvNorm, normalIn);\n"
|
||||
" vtf.mvBinorm = mul(mvNorm, binormalIn);\n"
|
||||
" vtf.mvTangent = mul(mvNorm, tangentIn);\n"
|
||||
" vtf.color = max(height, 0.0) * colorMul;\n"
|
||||
" vtf.color.a = 1.0;\n"
|
||||
" vtf.uvs[0] = mul(texMtxs[0], pos).xy;\n"
|
||||
" vtf.uvs[1] = mul(texMtxs[1], pos).xy;\n"
|
||||
" vtf.uvs[2] = mul(texMtxs[2], pos).xy;\n"
|
||||
"%s\n" // Additional TCGs here
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" float4 pos;\n"
|
||||
" float4 dir;\n"
|
||||
" float4 color;\n"
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" float4 color;\n"
|
||||
" float indScale;\n"
|
||||
" float start;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer LightingUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" float4 ambient;\n"
|
||||
" float4 kColor0;\n"
|
||||
" float4 kColor1;\n"
|
||||
" float4 kColor2;\n"
|
||||
" float4 kColor3;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"static float4 LightingFunc(float3 mvPosIn, float3 mvNormIn)\n"
|
||||
"{\n"
|
||||
" float4 ret = ambient;\n"
|
||||
" \n"
|
||||
" for (int i=0 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" float3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = clamp(dot(normalize(delta), lights[i].dir.xyz), 0.0, 1.0);\n"
|
||||
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lights[i].linAtt[1] * dist +\n"
|
||||
" lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[i].angAtt[1] * angDot +\n"
|
||||
" lights[i].angAtt[0];\n"
|
||||
" ret += lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return ret;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
" float4 mvPos : POSITION;\n"
|
||||
" float4 mvNorm : NORMAL;\n"
|
||||
" float4 mvBinorm : BINORMAL;\n"
|
||||
" float4 mvTangent : TANGENT;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uvs[7] : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"%s" // Textures here
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float4 lighting = LightingFunc(vtf.mvPos.xyz, normalize(vtf.mvNorm.xyz));\n"
|
||||
" float4 colorOut;\n"
|
||||
"%s" // Combiner expression here
|
||||
" return colorOut;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FSDoor =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" float4 pos;\n"
|
||||
" float4 dir;\n"
|
||||
" float4 color;\n"
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" float4 color;\n"
|
||||
" float indScale;\n"
|
||||
" float start;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer LightingUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" float4 ambient;\n"
|
||||
" float4 kColor0;\n"
|
||||
" float4 kColor1;\n"
|
||||
" float4 kColor2;\n"
|
||||
" float4 kColor3;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
" float4 mvPos : POSITION;\n"
|
||||
" float4 mvNorm : NORMAL;\n"
|
||||
" float4 mvBinorm : BINORMAL;\n"
|
||||
" float4 mvTangent : TANGENT;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uvs[7] : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"%s" // Textures here
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float4 colorOut;\n"
|
||||
"%s" // Combiner expression here
|
||||
" return colorOut;\n"
|
||||
"}\n";
|
||||
|
||||
static std::string _BuildFS(const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
std::string additionalTCGs;
|
||||
std::string textures;
|
||||
std::string combiner;
|
||||
int nextTex = 0;
|
||||
int nextTCG = 3;
|
||||
int nextMtx = 4;
|
||||
int bumpMapUv, envBumpMapUv, envMapUv, lightmapUv;
|
||||
|
||||
if (info.m_hasPatternTex1)
|
||||
textures += hecl::Format("Texture2D patternTex1 : register(t%d);\n", nextTex++);
|
||||
if (info.m_hasPatternTex2)
|
||||
textures += hecl::Format("Texture2D patternTex2 : register(t%d);\n", nextTex++);
|
||||
if (info.m_hasColorTex)
|
||||
textures += hecl::Format("Texture2D colorTex : register(t%d);\n", nextTex++);
|
||||
if (info.m_hasBumpMap)
|
||||
textures += hecl::Format("Texture2D bumpMap : register(t%d);\n", nextTex++);
|
||||
if (info.m_hasEnvMap)
|
||||
textures += hecl::Format("Texture2D envMap : register(t%d);\n", nextTex++);
|
||||
if (info.m_hasEnvBumpMap)
|
||||
textures += hecl::Format("Texture2D envBumpMap : register(t%d);\n", nextTex++);
|
||||
if (info.m_hasLightmap)
|
||||
textures += hecl::Format("Texture2D lightMap : register(t%d);\n", nextTex++);
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
bumpMapUv = nextTCG;
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = mul(texMtxs[0], pos).xy;\n", nextTCG++);
|
||||
}
|
||||
if (info.m_hasEnvBumpMap)
|
||||
{
|
||||
envBumpMapUv = nextTCG;
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = mul(texMtxs[3], float4(normalIn.xyz, 1.0)).xy;\n", nextTCG++);
|
||||
}
|
||||
if (info.m_hasEnvMap)
|
||||
{
|
||||
envMapUv = nextTCG;
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = mul(texMtxs[%d], pos).xy;\n", nextTCG++, nextMtx++);
|
||||
}
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
lightmapUv = nextTCG;
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = mul(texMtxs[%d], pos).xy;\n", nextTCG++, nextMtx++);
|
||||
}
|
||||
|
||||
switch (info.m_type)
|
||||
{
|
||||
case EFluidType::NormalWater:
|
||||
case EFluidType::PhazonFluid:
|
||||
case EFluidType::Four:
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
combiner += hecl::Format(" float4 lightMapTexel = lightMap.Sample(samp, vtf.uvs[%d]);\n", lightmapUv);
|
||||
// 0: Tex4TCG, Tex4, doubleLightmapBlend ? NULL : GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, doubleLightmapBlend ? ZERO : RAS
|
||||
// Output reg 2
|
||||
// KColor 2
|
||||
if (info.m_doubleLightmapBlend)
|
||||
{
|
||||
// 1: Tex4TCG2, Tex4, GX_COLOR1A1
|
||||
// C2, TEX, KONST, RAS
|
||||
// Output reg 2
|
||||
// KColor 3
|
||||
// Tex * K2 + Lighting
|
||||
combiner += " lighting += lerp(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// mix(Tex * K2, Tex, K3) + Lighting
|
||||
combiner += " lighting += lightMapTexel * kColor2;\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Next: Tex0TCG, Tex0, GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// Next: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// Next: Tex2TCG, Tex2, GX_COLOR1A1
|
||||
// ZERO, TEX, hasTex4 ? C2 : RAS, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + Lighting) * Tex1 + VertColor + Tex2 * Lighting
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (patternTex1.Sample(samp, vtf.uvs[0]) * kColor0 + lighting) *\n"
|
||||
" patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = lighting * patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
|
||||
if (info.m_hasColorTex && !info.m_hasEnvMap && info.m_hasEnvBumpMap)
|
||||
{
|
||||
// Make previous stage indirect, mtx0
|
||||
combiner += hecl::Format(" float2 indUvs = (envBumpMap.Sample(samp, vtf.uvs[%d]).ra - float2(0.5, 0.5)) *\n"
|
||||
" float2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
||||
combiner += " colorOut += colorTex.Sample(samp, indUvs + vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
else if (info.m_hasEnvMap)
|
||||
{
|
||||
// Next: envTCG, envTex, NULL
|
||||
// PREV, TEX, KONST, ZERO
|
||||
// Output reg prev
|
||||
// KColor 1
|
||||
|
||||
// Make previous stage indirect, mtx0
|
||||
if (info.m_hasColorTex)
|
||||
combiner += " colorOut += colorTex.Sample(samp, vtf.uvs[2]) * lighting;\n";
|
||||
combiner += hecl::Format(" float2 indUvs = (envBumpMap.Sample(samp, vtf.uvs[%d]).ra - float2(0.5, 0.5)) *\n"
|
||||
" float2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
||||
combiner += hecl::Format(" colorOut = lerp(colorOut, envMap.Sample(samp, indUvs + vtf.uvs[%d]), kColor1);\n",
|
||||
envMapUv);
|
||||
}
|
||||
else if (info.m_hasColorTex)
|
||||
{
|
||||
combiner += " colorOut += colorTex.Sample(samp, vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::PoisonWater:
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
combiner += hecl::Format(" float4 lightMapTexel = lightMap.Sample(samp, vtf.uvs[%d]);\n", lightmapUv);
|
||||
// 0: Tex4TCG, Tex4, doubleLightmapBlend ? NULL : GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, doubleLightmapBlend ? ZERO : RAS
|
||||
// Output reg 2
|
||||
// KColor 2
|
||||
if (info.m_doubleLightmapBlend)
|
||||
{
|
||||
// 1: Tex4TCG2, Tex4, GX_COLOR1A1
|
||||
// C2, TEX, KONST, RAS
|
||||
// Output reg 2
|
||||
// KColor 3
|
||||
// Tex * K2 + Lighting
|
||||
combiner += " lighting += lerp(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// mix(Tex * K2, Tex, K3) + Lighting
|
||||
combiner += " lighting += lightMapTexel * kColor2;\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Next: Tex0TCG, Tex0, GX_COLOR1A1
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// Next: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// Next: Tex2TCG, Tex2, GX_COLOR1A1
|
||||
// ZERO, TEX, hasTex4 ? C2 : RAS, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + Lighting) * Tex1 + VertColor + Tex2 * Lighting
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (patternTex1.Sample(samp, vtf.uvs[0]) * kColor0 + lighting) *\n"
|
||||
" patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = lighting * patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
if (info.m_hasColorTex)
|
||||
{
|
||||
if (info.m_hasEnvBumpMap)
|
||||
{
|
||||
// Make previous stage indirect, mtx0
|
||||
combiner += hecl::Format(" float2 indUvs = (envBumpMap.Sample(samp, vtf.uvs[%d]).ra - float2(0.5, 0.5)) *\n"
|
||||
" float2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
||||
combiner += " colorOut += colorTex.Sample(samp, indUvs + vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut += colorTex.Sample(samp, vtf.uvs[2]) * lighting;\n";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::Lava:
|
||||
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// 1: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// 2: Tex2TCG, Tex2, NULL
|
||||
// ZERO, TEX, ONE, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + VertColor) * Tex1 + VertColor + Tex2
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (patternTex1.Sample(samp, vtf.uvs[0]) * kColor0 + vtf.color) *\n"
|
||||
" patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = vtf.color * patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
if (info.m_hasColorTex)
|
||||
combiner += " colorOut += colorTex.Sample(samp, vtf.uvs[2]);\n";
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
// 3: bumpMapTCG, bumpMap, NULL
|
||||
// ZERO, TEX, ONE, HALF
|
||||
// Output reg 0, no clamp, no bias
|
||||
|
||||
// 4: bumpMapTCG2, bumpMap, NULL
|
||||
// ZERO, TEX, ONE, C0
|
||||
// Output reg 0, subtract, clamp, no bias
|
||||
|
||||
combiner += " float3 lightVec = lights[3].pos.xyz - vtf.mvPos.xyz;\n"
|
||||
" float lx = dot(vtf.mvTangent.xyz, lightVec);\n"
|
||||
" float ly = dot(vtf.mvBinorm.xyz, lightVec);\n";
|
||||
combiner += hecl::Format(" float4 emboss1 = bumpMap.Sample(samp, vtf.uvs[%d]) + float4(0.5);\n"
|
||||
" float4 emboss2 = bumpMap.Sample(samp, vtf.uvs[%d] + float2(lx, ly));\n",
|
||||
bumpMapUv, bumpMapUv);
|
||||
|
||||
// 5: NULL, NULL, NULL
|
||||
// ZERO, PREV, C0, ZERO
|
||||
// Output reg prev, scale 2, clamp
|
||||
|
||||
// colorOut * clamp(emboss1 + 0.5 - emboss2, 0.0, 1.0) * 2.0
|
||||
combiner += "colorOut *= clamp((emboss1 + float4(0.5) - emboss2) * float4(2.0), float4(0.0), float4(1.0));\n";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::ThickLava:
|
||||
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
||||
// ZERO, TEX, KONST, RAS
|
||||
// Output reg prev
|
||||
// KColor 0
|
||||
|
||||
// 1: Tex1TCG, Tex1, GX_COLOR0A0
|
||||
// ZERO, TEX, PREV, RAS
|
||||
// Output reg prev
|
||||
|
||||
// 2: Tex2TCG, Tex2, NULL
|
||||
// ZERO, TEX, ONE, PREV
|
||||
// Output reg prev
|
||||
|
||||
// (Tex0 * kColor0 + VertColor) * Tex1 + VertColor + Tex2
|
||||
if (info.m_hasPatternTex2)
|
||||
{
|
||||
if (info.m_hasPatternTex1)
|
||||
combiner += " colorOut = (patternTex1.Sample(samp, vtf.uvs[0]) * kColor0 + vtf.color) *\n"
|
||||
" patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
else
|
||||
combiner += " colorOut = vtf.color * patternTex2.Sample(samp, vtf.uvs[1]) + vtf.color;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
combiner += " colorOut = vtf.color;\n";
|
||||
}
|
||||
|
||||
if (info.m_hasColorTex)
|
||||
combiner += " colorOut += colorTex.Sample(samp, vtf.uvs[2]);\n";
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
// 3: bumpMapTCG, bumpMap, NULL
|
||||
// ZERO, TEX, PREV, ZERO
|
||||
// Output reg prev, scale 2
|
||||
combiner += hecl::Format(" float4 emboss1 = bumpMap.Sample(samp, vtf.uvs[%d]) + float4(0.5);\n", bumpMapUv);
|
||||
combiner += "colorOut *= emboss1 * float4(2.0);\n";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
combiner += " colorOut.a = kColor0.a;\n";
|
||||
|
||||
char *finalFS;
|
||||
asprintf(&finalFS, FS, textures.c_str(), combiner.c_str());
|
||||
std::string ret(finalFS);
|
||||
free(finalFS);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static std::string _BuildAdditionalTCGs(const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
std::string additionalTCGs;
|
||||
int nextTCG = 3;
|
||||
int nextMtx = 4;
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[0] * pos).xy;\n", nextTCG++);
|
||||
}
|
||||
if (info.m_hasEnvBumpMap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[3] * vec4(normalIn.xyz, 1.0)).xy;\n", nextTCG++);
|
||||
}
|
||||
if (info.m_hasEnvMap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[%d] * pos).xy;\n", nextTCG++, nextMtx++);
|
||||
}
|
||||
if (info.m_hasLightmap)
|
||||
{
|
||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = (texMtxs[%d] * pos).xy;\n", nextTCG, nextMtx);
|
||||
}
|
||||
|
||||
return additionalTCGs;
|
||||
}
|
||||
|
||||
static std::string _BuildVS(const SFluidPlaneShaderInfo& info, bool tessellation)
|
||||
{
|
||||
if (tessellation)
|
||||
return TessVS;
|
||||
|
||||
std::string additionalTCGs = _BuildAdditionalTCGs(info);
|
||||
|
||||
char *finalVSs;
|
||||
asprintf(&finalVSs, VS, additionalTCGs.c_str());
|
||||
std::string ret(finalVSs);
|
||||
free(finalVSs);
|
||||
return ret;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildVS(in, tessellation);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildVS(in, tessellation);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Vertex>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildVS(in, tessellation);
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Fragment>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return _BuildFS(in);
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Control>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return TessCS;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Control>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return TessCS;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Control>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return TessCS;
|
||||
}
|
||||
|
||||
static std::string BuildES(const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
int nextTex = 0;
|
||||
if (info.m_hasPatternTex1)
|
||||
nextTex++;
|
||||
if (info.m_hasPatternTex2)
|
||||
nextTex++;
|
||||
if (info.m_hasColorTex)
|
||||
nextTex++;
|
||||
if (info.m_hasBumpMap)
|
||||
nextTex++;
|
||||
if (info.m_hasEnvMap)
|
||||
nextTex++;
|
||||
if (info.m_hasEnvBumpMap)
|
||||
nextTex++;
|
||||
if (info.m_hasLightmap)
|
||||
nextTex++;
|
||||
|
||||
std::string additionalTCGs = _BuildAdditionalTCGs(info);
|
||||
|
||||
char *finalESs;
|
||||
asprintf(&finalESs, TessES, nextTex, additionalTCGs.c_str());
|
||||
std::string ret(finalESs);
|
||||
free(finalESs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::OpenGL, hecl::PipelineStage::Evaluation>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return BuildES(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::Vulkan, hecl::PipelineStage::Evaluation>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return BuildES(in);
|
||||
}
|
||||
template <>
|
||||
std::string StageObject_CFluidPlaneShader<hecl::PlatformType::NX, hecl::PipelineStage::Evaluation>::BuildShader
|
||||
(const SFluidPlaneShaderInfo& in, bool tessellation)
|
||||
{
|
||||
return BuildES(in);
|
||||
}
|
||||
0
Shaders/shader_CFluidPlaneShaderMetal.cpp
Normal file
0
Shaders/shader_CFluidPlaneShaderMetal.cpp
Normal file
Reference in New Issue
Block a user