diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2026-07-23 11:13:17 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-23 11:13:17 -0500 |
| commit | 6eeeae0340a9eb549ec9a250731a91d7aff2a073 (patch) | |
| tree | 1279109f0ca10052f5832730fb9365b51e4c1555 | |
| parent | 2e733f5e178f9587acb70efcf20da2c9e6cace31 (diff) | |
Sync shaders from LUS (#1804)
| -rw-r--r-- | mm/assets/custom/shaders/directx/default.shader.hlsl | 34 | ||||
| -rw-r--r-- | mm/assets/custom/shaders/metal/default.shader.metal | 65 | ||||
| -rw-r--r-- | mm/assets/custom/shaders/opengl/default.shader.fs | 211 | ||||
| -rw-r--r-- | mm/assets/custom/shaders/opengl/default.shader.glsl | 297 | ||||
| -rw-r--r-- | mm/assets/custom/shaders/opengl/default.shader.vs | 79 |
5 files changed, 368 insertions, 318 deletions
diff --git a/mm/assets/custom/shaders/directx/default.shader.hlsl b/mm/assets/custom/shaders/directx/default.shader.hlsl index 980becb8c..3025a1121 100644 --- a/mm/assets/custom/shaders/directx/default.shader.hlsl +++ b/mm/assets/custom/shaders/directx/default.shader.hlsl @@ -77,7 +77,7 @@ float random(in float3 value) { // Original author: ArthurCarvalho // Based on GLSL implementation by twinaphex, mupen64plus-libretro project. -@if(o_three_point_filtering && o_textures[0] || o_textures[1]) +@if(o_three_point_filtering && (o_textures[0] || o_textures[1])) cbuffer PerDrawCB : register(b1) { struct { uint width; @@ -98,6 +98,13 @@ float4 tex2D3PointFilter(in Texture2D tex, in SamplerState tSampler, in float2 t } @end +@if(o_prim_depth) +cbuffer PerPrimDepthCB : register(b2) { + float prim_depth; + float3 _pad; // pad to 16-byte cbuffer alignment +} +@end + PSInput VSMain( float4 position : POSITION @for(i in 0..2) @@ -180,7 +187,14 @@ PSInput VSMain( #define MOD(x, y) ((x) - (y) * floor((x)/(y))) #define WRAP(x, low, high) MOD((x)-(low), (high)-(low)) + (low) -float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET { +struct PSOutput { + float4 color : SV_TARGET; + @if(o_prim_depth) + float depth : SV_Depth; + @end +}; + +PSOutput PSMain(PSInput input, float4 screenSpace : SV_Position) { @for(i in 0..2) @if(o_textures[i]) float2 tc@{i} = input.uv@{i}; @@ -317,16 +331,24 @@ float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET { @if(o_invisible) texel.a = 0.0; @end + @end + + PSOutput output; + @if(o_alpha) @if(srgb_mode) - return fromLinear(texel); + output.color = fromLinear(texel); @else - return texel; + output.color = texel; @end @else @if(srgb_mode) - return fromLinear(float4(texel, 1.0)); + output.color = fromLinear(float4(texel, 1.0)); @else - return float4(texel, 1.0); + output.color = float4(texel, 1.0); @end @end + @if(o_prim_depth) + output.depth = prim_depth; + @end + return output; } diff --git a/mm/assets/custom/shaders/metal/default.shader.metal b/mm/assets/custom/shaders/metal/default.shader.metal index a771ba10c..bf876398e 100644 --- a/mm/assets/custom/shaders/metal/default.shader.metal +++ b/mm/assets/custom/shaders/metal/default.shader.metal @@ -9,6 +9,20 @@ struct FrameUniforms { float noiseScale; }; +struct DrawUniforms { + int textureFiltering[6]; + @if(o_prim_depth) + float prim_depth; + @end +}; + +struct FragOut { + float4 color [[color(0)]]; + @if(o_prim_depth) + float depth [[depth(any)]]; + @end +}; + struct Vertex { float4 position [[attribute(@{get_vertex_index()})]]; @{update_floats(4)} @@ -123,31 +137,33 @@ float4 mod(float4 a, float4 b) { #define WRAP(x, low, high) mod((x)-(low), (high)-(low)) + (low) #define TEX_OFFSET(tex, texSmplr, texCoord, off, texSize) tex.sample(texSmplr, texCoord - off / texSize) -@if(o_three_point_filtering) - float4 filter3point(thread const texture2d<float> tex, thread const sampler texSmplr, thread const float2& texCoord, thread const float2& texSize) { - float2 offset = fract((texCoord * texSize) - float2(0.5)); - offset -= float2(step(1.0, offset.x + offset.y)); - float4 c0 = TEX_OFFSET(tex, texSmplr, texCoord, offset, texSize); - float4 c1 = TEX_OFFSET(tex, texSmplr, texCoord, float2(offset.x - sign(offset.x), offset.y), texSize); - float4 c2 = TEX_OFFSET(tex, texSmplr, texCoord, float2(offset.x, offset.y - sign(offset.y)), texSize); - return c0 + abs(offset.x) * (c1 - c0) + abs(offset.y) * (c2 - c0); - } +float4 filter3point(thread const texture2d<float> tex, thread const sampler texSmplr, thread const float2& texCoord, thread const float2& texSize) { + float2 offset = fract((texCoord * texSize) - float2(0.5)); + offset -= float2(step(1.0, offset.x + offset.y)); + float4 c0 = TEX_OFFSET(tex, texSmplr, texCoord, offset, texSize); + float4 c1 = TEX_OFFSET(tex, texSmplr, texCoord, float2(offset.x - sign(offset.x), offset.y), texSize); + float4 c2 = TEX_OFFSET(tex, texSmplr, texCoord, float2(offset.x, offset.y - sign(offset.y)), texSize); + return c0 + abs(offset.x) * (c1 - c0) + abs(offset.y) * (c2 - c0); +} - float4 hookTexture2D(thread const texture2d<float> tex, thread const sampler texSmplr, thread const float2& uv, thread const float2& texSize) { +float4 hookTexture2D(thread const texture2d<float> tex, thread const sampler texSmplr, thread const float2& uv, thread const float2& texSize, thread const int filtering) { +@if(o_three_point_filtering) + if(filtering == @{FILTER_THREE_POINT}) { return filter3point(tex, texSmplr, uv, texSize); } -@else - float4 hookTexture2D(thread const texture2d<float> tex, thread const sampler texSmplr, thread const float2& uv, thread const float2& texSize) { - return tex.sample(texSmplr, uv); - } @end + return tex.sample(texSmplr, uv); +} float random(float3 value) { float random = dot(sin(value), float3(12.9898, 78.233, 37.719)); return fract(sin(random) * 143758.5453); } -fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUniforms &frameUniforms [[buffer(0)]] +fragment FragOut fragmentShader( + ProjectedVertex in [[stage_in]], + constant FrameUniforms &frameUniforms [[buffer(0)]], + constant DrawUniforms &drawUniforms [[buffer(1)]] @if(o_textures[0]) , texture2d<float> uTex0 [[texture(0)]], sampler uTex0Smplr [[sampler(0)]] @end @@ -184,13 +200,13 @@ fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUn @end @end - float4 texVal@{i} = hookTexture2D(uTex@{i}, uTex@{i}Smplr, vTexCoordAdj@{i}, texSize@{i}); + float4 texVal@{i} = hookTexture2D(uTex@{i}, uTex@{i}Smplr, vTexCoordAdj@{i}, texSize@{i}, drawUniforms.textureFiltering[@{i}]); @if(o_masks[i]) float2 maskSize@{i} = float2(uTexMask@{i}.get_width(), uTexMask@{i}.get_height()); - float4 maskVal@{i} = hookTexture2D(uTexMask@{i}, uTex@{i}Smplr, vTexCoordAdj@{i}, maskSize@{i}); + float4 maskVal@{i} = hookTexture2D(uTexMask@{i}, uTex@{i}Smplr, vTexCoordAdj@{i}, maskSize@{i}, drawUniforms.textureFiltering[@{i}]); @if(o_blend[i]) - float4 blendVal@{i} = hookTexture2D(uTexBlend@{i}, uTex@{i}Smplr, vTexCoordAdj@{i}, texSize@{i}); + float4 blendVal@{i} = hookTexture2D(uTexBlend@{i}, uTex@{i}Smplr, vTexCoordAdj@{i}, texSize@{i}, drawUniforms.textureFiltering[@{i}]); @else float4 blendVal@{i} = float4(0, 0, 0, 0); @end @@ -266,10 +282,11 @@ fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUn @end @if(o_alpha && o_noise) - float2 coords = screenSpace.xy * noise_scale; - texel.w *= round(saturate(random(float3(floor(coords), noise_frame)) + texel.w - 0.5)); + float2 coords = in.position.xy * frameUniforms.noiseScale; + texel.w *= round(saturate(random(float3(floor(coords), float(frameUniforms.frameCount))) + texel.w - 0.5)); @end + FragOut out; @if(o_alpha) @if(o_alpha_threshold) if (texel.w < 8.0 / 256.0) discard_fragment(); @@ -277,8 +294,12 @@ fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUn @if(o_invisible) texel.w = 0.0; @end - return texel; + out.color = texel; @else - return float4(texel, 1.0); + out.color = float4(texel, 1.0); + @end + @if(o_prim_depth) + out.depth = drawUniforms.prim_depth; @end + return out; }
\ No newline at end of file diff --git a/mm/assets/custom/shaders/opengl/default.shader.fs b/mm/assets/custom/shaders/opengl/default.shader.fs deleted file mode 100644 index 404caae62..000000000 --- a/mm/assets/custom/shaders/opengl/default.shader.fs +++ /dev/null @@ -1,211 +0,0 @@ -@prism(type='fragment', name='Fast3D Fragment Shader', version='1.0.0', description='Ported shader to prism', author='Emill & Prism Team') - -@{GLSL_VERSION} - -@if(core_opengl || opengles) -out vec4 vOutColor; -@end - -@for(i in 0..2) - @if(o_textures[i]) - @{attr} vec2 vTexCoord@{i}; - @for(j in 0..2) - @if(o_clamp[i][j]) - @if(j == 0) - @{attr} float vTexClampS@{i}; - @else - @{attr} float vTexClampT@{i}; - @end - @end - @end - @end -@end - -@if(o_fog) @{attr} vec4 vFog; -@if(o_grayscale) @{attr} vec4 vGrayscaleColor; - -@for(i in 0..o_inputs) - @if(o_alpha) - @{attr} vec4 vInput@{i + 1}; - @else - @{attr} vec3 vInput@{i + 1}; - @end -@end - -@if(o_textures[0]) uniform sampler2D uTex0; -@if(o_textures[1]) uniform sampler2D uTex1; - -@if(o_masks[0]) uniform sampler2D uTexMask0; -@if(o_masks[1]) uniform sampler2D uTexMask1; - -@if(o_blend[0]) uniform sampler2D uTexBlend0; -@if(o_blend[1]) uniform sampler2D uTexBlend1; - -uniform int frame_count; -uniform float noise_scale; - -uniform int texture_width[2]; -uniform int texture_height[2]; -uniform int texture_filtering[2]; - -#define TEX_OFFSET(off) @{texture}(tex, texCoord - off / texSize) -#define WRAP(x, low, high) mod((x)-(low), (high)-(low)) + (low) - -float random(in vec3 value) { - float random = dot(sin(value), vec3(12.9898, 78.233, 37.719)); - return fract(sin(random) * 143758.5453); -} - -vec4 fromLinear(vec4 linearRGB){ - bvec3 cutoff = lessThan(linearRGB.rgb, vec3(0.0031308)); - vec3 higher = vec3(1.055)*pow(linearRGB.rgb, vec3(1.0/2.4)) - vec3(0.055); - vec3 lower = linearRGB.rgb * vec3(12.92); - return vec4(mix(higher, lower, cutoff), linearRGB.a); -} - -vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) { - vec2 offset = fract(texCoord*texSize - vec2(0.5)); - offset -= step(1.0, offset.x + offset.y); - vec4 c0 = TEX_OFFSET(offset); - vec4 c1 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y)); - vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y))); - return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); -} - -vec4 hookTexture2D(in int id, sampler2D tex, in vec2 uv, in vec2 texSize) { -@if(o_three_point_filtering) - if(texture_filtering[id] == @{FILTER_THREE_POINT}) { - return filter3point(tex, uv, texSize); - } -@end - return @{texture}(tex, uv); -} - -#define TEX_SIZE(tex) vec2(texture_width[tex], texture_height[tex]) - -void main() { - @for(i in 0..2) - @if(o_textures[i]) - @{s = o_clamp[i][0]} - @{t = o_clamp[i][1]} - - vec2 texSize@{i} = TEX_SIZE(@{i}); - - @if(!s && !t) - vec2 vTexCoordAdj@{i} = vTexCoord@{i}; - @else - @if(s && t) - vec2 vTexCoordAdj@{i} = clamp(vTexCoord@{i}, 0.5 / texSize@{i}, vec2(vTexClampS@{i}, vTexClampT@{i})); - @elseif(s) - vec2 vTexCoordAdj@{i} = vec2(clamp(vTexCoord@{i}.s, 0.5 / texSize@{i}.s, vTexClampS@{i}), vTexCoord@{i}.t); - @else - vec2 vTexCoordAdj@{i} = vec2(vTexCoord@{i}.s, clamp(vTexCoord@{i}.t, 0.5 / texSize@{i}.t, vTexClampT@{i})); - @end - @end - - vec4 texVal@{i} = hookTexture2D(@{i}, uTex@{i}, vTexCoordAdj@{i}, texSize@{i}); - - @if(o_masks[i]) - @if(opengles) - vec2 maskSize@{i} = vec2(textureSize(uTexMask@{i}, 0)); - @else - vec2 maskSize@{i} = textureSize(uTexMask@{i}, 0); - @end - - vec4 maskVal@{i} = hookTexture2D(@{i}, uTexMask@{i}, vTexCoordAdj@{i}, maskSize@{i}); - - @if(o_blend[i]) - vec4 blendVal@{i} = hookTexture2D(@{i}, uTexBlend@{i}, vTexCoordAdj@{i}, texSize@{i}); - @else - vec4 blendVal@{i} = vec4(0, 0, 0, 0); - @end - - texVal@{i} = mix(texVal@{i}, blendVal@{i}, maskVal@{i}.a); - @end - @end - @end - - @if(o_alpha) - vec4 texel; - @else - vec3 texel; - @end - - @if(o_2cyc) - @{f_range = 2} - @else - @{f_range = 1} - @end - - @for(c in 0..f_range) - @if(c == 1) - @if(o_alpha) - @if(o_c[c][1][2] == SHADER_COMBINED) - texel.a = WRAP(texel.a, -1.01, 1.01); - @else - texel.a = WRAP(texel.a, -0.51, 1.51); - @end - @end - - @if(o_c[c][0][2] == SHADER_COMBINED) - texel.rgb = WRAP(texel.rgb, -1.01, 1.01); - @else - texel.rgb = WRAP(texel.rgb, -0.51, 1.51); - @end - @end - - @if(!o_color_alpha_same[c] && o_alpha) - texel = vec4(@{ - append_formula(o_c[c], o_do_single[c][0], - o_do_multiply[c][0], o_do_mix[c][0], false, false, true, c == 0) - }, @{append_formula(o_c[c], o_do_single[c][1], - o_do_multiply[c][1], o_do_mix[c][1], true, true, true, c == 0) - }); - @else - texel = @{append_formula(o_c[c], o_do_single[c][0], - o_do_multiply[c][0], o_do_mix[c][0], o_alpha, false, - o_alpha, c == 0)}; - @end - @end - - texel = WRAP(texel, -0.51, 1.51); - texel = clamp(texel, 0.0, 1.0); - // TODO discard if alpha is 0? - @if(o_fog) - @if(o_alpha) - texel = vec4(mix(texel.rgb, vFog.rgb, vFog.a), texel.a); - @else - texel = mix(texel, vFog.rgb, vFog.a); - @end - @end - - @if(o_texture_edge && o_alpha) - if (texel.a > 0.19) texel.a = 1.0; else discard; - @end - - @if(o_alpha && o_noise) - texel.a *= floor(clamp(random(vec3(floor(gl_FragCoord.xy * noise_scale), float(frame_count))) + texel.a, 0.0, 1.0)); - @end - - @if(o_grayscale) - float intensity = (texel.r + texel.g + texel.b) / 3.0; - vec3 new_texel = vGrayscaleColor.rgb * intensity; - texel.rgb = mix(texel.rgb, new_texel, vGrayscaleColor.a); - @end - - @if(o_alpha) - @if(o_alpha_threshold) - if (texel.a < 8.0 / 256.0) discard; - @end - @if(o_invisible) - texel.a = 0.0; - @end - @{vOutColor} = texel; - @else - @{vOutColor} = vec4(texel, 1.0); - @end - - @if(srgb_mode) - @{vOutColor} = fromLinear(@{vOutColor}); - @end -}
\ No newline at end of file diff --git a/mm/assets/custom/shaders/opengl/default.shader.glsl b/mm/assets/custom/shaders/opengl/default.shader.glsl new file mode 100644 index 000000000..530926095 --- /dev/null +++ b/mm/assets/custom/shaders/opengl/default.shader.glsl @@ -0,0 +1,297 @@ +@prism(type='fragment', name='Fast3D Fragment Shader', version='1.0.0', description='Ported shader to prism', author='Emill & Prism Team') + +@{GLSL_VERSION} + +@if(VERTEX_SHADER) + @{attr} vec4 aVtxPos; + + @for(i in 0..2) + @if(o_textures[i]) + @{attr} vec2 aTexCoord@{i}; + @{out} vec2 vTexCoord@{i}; + @{update_floats(2)} + @for(j in 0..2) + @if(o_clamp[i][j]) + @if(j == 0) + @{attr} float aTexClampS@{i}; + @{out} float vTexClampS@{i}; + @else + @{attr} float aTexClampT@{i}; + @{out} float vTexClampT@{i}; + @end + @{update_floats(1)} + @end + @end + @end + @end + + @if(o_fog) + @{attr} vec4 aFog; + @{out} vec4 vFog; + @{update_floats(4)} + @end + + @if(o_grayscale) + @{attr} vec4 aGrayscaleColor; + @{out} vec4 vGrayscaleColor; + @{update_floats(4)} + @end + + @for(i in 0..o_inputs) + @if(o_alpha) + @{attr} vec4 aInput@{i + 1}; + @{out} vec4 vInput@{i + 1}; + @{update_floats(4)} + @else + @{attr} vec3 aInput@{i + 1}; + @{out} vec3 vInput@{i + 1}; + @{update_floats(3)} + @end + @end + + void main() { + @for(i in 0..2) + @if(o_textures[i]) + vTexCoord@{i} = aTexCoord@{i}; + @for(j in 0..2) + @if(o_clamp[i][j]) + @if(j == 0) + vTexClampS@{i} = aTexClampS@{i}; + @else + vTexClampT@{i} = aTexClampT@{i}; + @end + @end + @end + @end + @end + @if(o_fog) + vFog = aFog; + @end + @if(o_grayscale) + vGrayscaleColor = aGrayscaleColor; + @end + @for(i in 0..o_inputs) + vInput@{i + 1} = aInput@{i + 1}; + @end + gl_Position = aVtxPos; + @if(opengles) + gl_Position.z *= 0.3f; + @end + } +@else + @if(core_opengl || opengles) + out vec4 vOutColor; + @end + + @for(i in 0..2) + @if(o_textures[i]) + @{attr} vec2 vTexCoord@{i}; + @for(j in 0..2) + @if(o_clamp[i][j]) + @if(j == 0) + @{attr} float vTexClampS@{i}; + @else + @{attr} float vTexClampT@{i}; + @end + @end + @end + @end + @end + + @if(o_fog) @{attr} vec4 vFog; + @if(o_grayscale) @{attr} vec4 vGrayscaleColor; + + @for(i in 0..o_inputs) + @if(o_alpha) + @{attr} vec4 vInput@{i + 1}; + @else + @{attr} vec3 vInput@{i + 1}; + @end + @end + + @if(o_textures[0]) uniform sampler2D uTex0; + @if(o_textures[1]) uniform sampler2D uTex1; + + @if(o_masks[0]) uniform sampler2D uTexMask0; + @if(o_masks[1]) uniform sampler2D uTexMask1; + + @if(o_blend[0]) uniform sampler2D uTexBlend0; + @if(o_blend[1]) uniform sampler2D uTexBlend1; + + uniform int frame_count; + uniform float noise_scale; + + @if(o_prim_depth) + uniform float prim_depth; + @end + + uniform int texture_width[2]; + uniform int texture_height[2]; + uniform int texture_filtering[2]; + + #define TEX_OFFSET(off) @{texture}(tex, texCoord - off / texSize) + #define WRAP(x, low, high) mod((x)-(low), (high)-(low)) + (low) + + float random(in vec3 value) { + float random = dot(sin(value), vec3(12.9898, 78.233, 37.719)); + return fract(sin(random) * 143758.5453); + } + + vec4 fromLinear(vec4 linearRGB){ + bvec3 cutoff = lessThan(linearRGB.rgb, vec3(0.0031308)); + vec3 higher = vec3(1.055)*pow(linearRGB.rgb, vec3(1.0/2.4)) - vec3(0.055); + vec3 lower = linearRGB.rgb * vec3(12.92); + return vec4(mix(higher, lower, cutoff), linearRGB.a); + } + + vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) { + vec2 offset = fract(texCoord*texSize - vec2(0.5)); + offset -= step(1.0, offset.x + offset.y); + vec4 c0 = TEX_OFFSET(offset); + vec4 c1 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y)); + vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y))); + return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); + } + + vec4 hookTexture2D(in int id, sampler2D tex, in vec2 uv, in vec2 texSize) { + @if(o_three_point_filtering) + if(texture_filtering[id] == @{FILTER_THREE_POINT}) { + return filter3point(tex, uv, texSize); + } + @end + return @{texture}(tex, uv); + } + + #define TEX_SIZE(tex) vec2(texture_width[tex], texture_height[tex]) + + void main() { + @for(i in 0..2) + @if(o_textures[i]) + @{s = o_clamp[i][0]} + @{t = o_clamp[i][1]} + + vec2 texSize@{i} = TEX_SIZE(@{i}); + + @if(!s && !t) + vec2 vTexCoordAdj@{i} = vTexCoord@{i}; + @else + @if(s && t) + vec2 vTexCoordAdj@{i} = clamp(vTexCoord@{i}, 0.5 / texSize@{i}, vec2(vTexClampS@{i}, vTexClampT@{i})); + @elseif(s) + vec2 vTexCoordAdj@{i} = vec2(clamp(vTexCoord@{i}.s, 0.5 / texSize@{i}.s, vTexClampS@{i}), vTexCoord@{i}.t); + @else + vec2 vTexCoordAdj@{i} = vec2(vTexCoord@{i}.s, clamp(vTexCoord@{i}.t, 0.5 / texSize@{i}.t, vTexClampT@{i})); + @end + @end + + vec4 texVal@{i} = hookTexture2D(@{i}, uTex@{i}, vTexCoordAdj@{i}, texSize@{i}); + + @if(o_masks[i]) + @if(opengles) + vec2 maskSize@{i} = vec2(textureSize(uTexMask@{i}, 0)); + @else + vec2 maskSize@{i} = textureSize(uTexMask@{i}, 0); + @end + + vec4 maskVal@{i} = hookTexture2D(@{i}, uTexMask@{i}, vTexCoordAdj@{i}, maskSize@{i}); + + @if(o_blend[i]) + vec4 blendVal@{i} = hookTexture2D(@{i}, uTexBlend@{i}, vTexCoordAdj@{i}, texSize@{i}); + @else + vec4 blendVal@{i} = vec4(0, 0, 0, 0); + @end + + texVal@{i} = mix(texVal@{i}, blendVal@{i}, maskVal@{i}.a); + @end + @end + @end + + @if(o_alpha) + vec4 texel; + @else + vec3 texel; + @end + + @if(o_2cyc) + @{f_range = 2} + @else + @{f_range = 1} + @end + + @for(c in 0..f_range) + @if(c == 1) + @if(o_alpha) + @if(o_c[c][1][2] == SHADER_COMBINED) + texel.a = WRAP(texel.a, -1.01, 1.01); + @else + texel.a = WRAP(texel.a, -0.51, 1.51); + @end + @end + + @if(o_c[c][0][2] == SHADER_COMBINED) + texel.rgb = WRAP(texel.rgb, -1.01, 1.01); + @else + texel.rgb = WRAP(texel.rgb, -0.51, 1.51); + @end + @end + + @if(!o_color_alpha_same[c] && o_alpha) + texel = vec4(@{ + append_formula(o_c[c], o_do_single[c][0], + o_do_multiply[c][0], o_do_mix[c][0], false, false, true, c == 0) + }, @{append_formula(o_c[c], o_do_single[c][1], + o_do_multiply[c][1], o_do_mix[c][1], true, true, true, c == 0) + }); + @else + texel = @{append_formula(o_c[c], o_do_single[c][0], + o_do_multiply[c][0], o_do_mix[c][0], o_alpha, false, + o_alpha, c == 0)}; + @end + @end + + texel = WRAP(texel, -0.51, 1.51); + texel = clamp(texel, 0.0, 1.0); + // TODO discard if alpha is 0? + @if(o_fog) + @if(o_alpha) + texel = vec4(mix(texel.rgb, vFog.rgb, vFog.a), texel.a); + @else + texel = mix(texel, vFog.rgb, vFog.a); + @end + @end + + @if(o_texture_edge && o_alpha) + if (texel.a > 0.19) texel.a = 1.0; else discard; + @end + + @if(o_alpha && o_noise) + texel.a *= floor(clamp(random(vec3(floor(gl_FragCoord.xy * noise_scale), float(frame_count))) + texel.a, 0.0, 1.0)); + @end + + @if(o_grayscale) + float intensity = (texel.r + texel.g + texel.b) / 3.0; + vec3 new_texel = vGrayscaleColor.rgb * intensity; + texel.rgb = mix(texel.rgb, new_texel, vGrayscaleColor.a); + @end + + @if(o_alpha) + @if(o_alpha_threshold) + if (texel.a < 8.0 / 256.0) discard; + @end + @if(o_invisible) + texel.a = 0.0; + @end + @{vOutColor} = texel; + @else + @{vOutColor} = vec4(texel, 1.0); + @end + + @if(srgb_mode) + @{vOutColor} = fromLinear(@{vOutColor}); + @end + + @if(o_prim_depth) + gl_FragDepth = prim_depth; + @end + } +@end
\ No newline at end of file diff --git a/mm/assets/custom/shaders/opengl/default.shader.vs b/mm/assets/custom/shaders/opengl/default.shader.vs deleted file mode 100644 index cf0f62765..000000000 --- a/mm/assets/custom/shaders/opengl/default.shader.vs +++ /dev/null @@ -1,79 +0,0 @@ -@prism(type='fragment', name='Fast3D Fragment Shader', version='1.0.0', description='Ported shader to prism', author='Emill & Prism Team') - -@{GLSL_VERSION} - -@{attr} vec4 aVtxPos; - -@for(i in 0..2) - @if(o_textures[i]) - @{attr} vec2 aTexCoord@{i}; - @{out} vec2 vTexCoord@{i}; - @{update_floats(2)} - @for(j in 0..2) - @if(o_clamp[i][j]) - @if(j == 0) - @{attr} float aTexClampS@{i}; - @{out} float vTexClampS@{i}; - @else - @{attr} float aTexClampT@{i}; - @{out} float vTexClampT@{i}; - @end - @{update_floats(1)} - @end - @end - @end -@end - -@if(o_fog) - @{attr} vec4 aFog; - @{out} vec4 vFog; - @{update_floats(4)} -@end - -@if(o_grayscale) - @{attr} vec4 aGrayscaleColor; - @{out} vec4 vGrayscaleColor; - @{update_floats(4)} -@end - -@for(i in 0..o_inputs) - @if(o_alpha) - @{attr} vec4 aInput@{i + 1}; - @{out} vec4 vInput@{i + 1}; - @{update_floats(4)} - @else - @{attr} vec3 aInput@{i + 1}; - @{out} vec3 vInput@{i + 1}; - @{update_floats(3)} - @end -@end - -void main() { - @for(i in 0..2) - @if(o_textures[i]) - vTexCoord@{i} = aTexCoord@{i}; - @for(j in 0..2) - @if(o_clamp[i][j]) - @if(j == 0) - vTexClampS@{i} = aTexClampS@{i}; - @else - vTexClampT@{i} = aTexClampT@{i}; - @end - @end - @end - @end - @end - @if(o_fog) - vFog = aFog; - @end - @if(o_grayscale) - vGrayscaleColor = aGrayscaleColor; - @end - @for(i in 0..o_inputs) - vInput@{i + 1} = aInput@{i + 1}; - @end - gl_Position = aVtxPos; - @if(opengles) - gl_Position.z *= 0.3f; - @end -}
\ No newline at end of file |
