Skip to content

Instantly share code, notes, and snippets.

@cdata
Last active October 21, 2024 21:41
Show Gist options
  • Save cdata/22a420fee91854366e13f01983e04dfd to your computer and use it in GitHub Desktop.
Save cdata/22a420fee91854366e13f01983e04dfd to your computer and use it in GitHub Desktop.
#version 300 es
precision highp float;
precision highp int;
struct MeshX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OR4XAZLTX {
mat3x4 world_from_local;
mat3x4 previous_world_from_local;
mat2x4 local_from_world_transpose_a;
float local_from_world_transpose_b;
uint flags;
uvec2 lightmap_uv_rect;
};
struct ColorGradingX_naga_oil_mod_XMJSXM6K7OJSW4ZDFOI5DU5TJMV3QX {
mat3x3 balance;
vec3 saturation;
vec3 contrast;
vec3 gamma;
vec3 gain;
vec3 lift;
vec2 midtone_range;
float exposure;
float hue;
float post_saturation;
};
struct ViewX_naga_oil_mod_XMJSXM6K7OJSW4ZDFOI5DU5TJMV3QX {
mat4x4 clip_from_world;
mat4x4 unjittered_clip_from_world;
mat4x4 world_from_clip;
mat4x4 world_from_view;
mat4x4 view_from_world;
mat4x4 clip_from_view;
mat4x4 view_from_clip;
vec3 world_position;
float exposure;
vec4 viewport;
vec4 frustum[6];
ColorGradingX_naga_oil_mod_XMJSXM6K7OJSW4ZDFOI5DU5TJMV3QX color_grading;
float mip_bias;
};
struct DirectionalCascadeX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
mat4x4 clip_from_world;
float texel_size;
float far_bound;
};
struct DirectionalLightX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
DirectionalCascadeX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX cascades[1];
vec4 color;
vec3 direction_to_light;
uint flags;
float shadow_depth_bias;
float shadow_normal_bias;
uint num_cascades;
float cascades_overlap_proportion;
uint depth_texture_base_index;
uint skip;
};
struct LightsX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
DirectionalLightX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX directional_lights[1];
vec4 ambient_color;
uvec4 cluster_dimensions;
vec4 cluster_factors;
uint n_directional_lights;
int spot_light_shadowmap_offset;
uint environment_map_smallest_specular_mip_level;
float environment_map_intensity;
};
struct FogX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
vec4 base_color;
vec4 directional_light_color;
vec3 be;
float directional_light_exponent;
vec3 bi;
uint mode;
};
struct ClusterableObjectX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
vec4 light_custom_data;
vec4 color_inverse_square_range;
vec4 position_radius;
uint flags;
float shadow_depth_bias;
float shadow_normal_bias;
float spot_light_tan_angle;
};
struct ClusterableObjectsX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
ClusterableObjectX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX data[256];
};
struct ClusterLightIndexListsX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
uvec4 data[1024];
};
struct ClusterOffsetsAndCountsX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
uvec4 data[1024];
};
struct LightProbeX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
mat3x4 light_from_world_transposed;
int cubemap_index;
float intensity;
};
struct LightProbesX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
LightProbeX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX reflection_probes[8];
LightProbeX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX irradiance_volumes[8];
int reflection_probe_count;
int irradiance_volume_count;
int view_cubemap_index;
uint smallest_specular_mip_level_for_view;
float intensity_for_view;
};
struct ScreenSpaceReflectionsSettingsX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OZUWK527OR4XAZLTX {
float perceptual_roughness_threshold;
float thickness;
uint linear_steps;
float linear_march_exponent;
uint bisection_steps;
uint use_secant;
};
struct GlobalsX_naga_oil_mod_XMJSXM6K7OJSW4ZDFOI5DUZ3MN5RGC3DTX {
float time;
float delta_time;
uint frame_count;
float _webgl2_padding;
};
struct Vertex {
vec3 position;
vec3 normal;
vec2 uv;
uint operation;
uvec3 palette;
uint atlas_index;
uvec2 source_xy;
ivec2 screen_xy;
uvec2 length_;
uint layer_mask;
};
struct VertexOutput {
vec4 clip_position;
vec2 uv;
uint operation;
uvec3 palette;
uint atlas_index;
uvec2 source_xy;
vec2 length_;
uint layer_mask;
};
const uint MESH_FLAGS_SIGN_DETERMINANT_MODEL_3X3_BITX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7OR4XAZLTX = 2147483648u;
const vec2 CHARACTER_PIXEL_SIZE = vec2(16.0);
const vec2 ATLAS_CHARACTER_SIZE = vec2(16.0);
const uint PALETTE_SIZE = 16u;
const vec2 ATLAS_PIXEL_SIZE = vec2(256.0, 256.0);
const vec2 PALETTE_PIXEL_SIZE = vec2(16.0);
const uint MAX_MAP_LAYERS = 4u;
const uint SPRITE_OPERATION = 0u;
const uint MAP_OPERATION = 1u;
const uint PALETTE_LOCK_MASK = 65535u;
const uint LOCK_COUNTER_MASK = 32768u;
uniform highp sampler2D _group_2_binding_0_fs;
uniform highp sampler2D _group_2_binding_2_fs;
uniform highp usampler2DArray _group_2_binding_4_fs;
smooth in vec2 _vs2fs_location0;
flat in uint _vs2fs_location1;
flat in uvec3 _vs2fs_location2;
flat in uint _vs2fs_location3;
flat in uvec2 _vs2fs_location4;
smooth in vec2 _vs2fs_location5;
flat in uint _vs2fs_location6;
layout(location = 0) out vec4 _fs2p_location0;
mat4x4 affine3_to_squareX_naga_oil_mod_XMJSXM6K7OJSW4ZDFOI5DU3LBORUHGX(mat3x4 affine) {
return transpose(mat4x4(affine[0], affine[1], affine[2], vec4(0.0, 0.0, 0.0, 1.0)));
}
mat3x3 mat2x4_f32_to_mat3x3_unpackX_naga_oil_mod_XMJSXM6K7OJSW4ZDFOI5DU3LBORUHGX(mat2x4 a, float b) {
return mat3x3(a[0].xyz, vec3(a[0].w, a[1].xy), vec3(a[1].zw, b));
}
vec4 mesh_position_local_to_worldX_naga_oil_mod_XMJSXM6K7OBRHEOR2NVSXG2C7MZ2W4Y3UNFXW44YX(mat4x4 world_from_local, vec4 vertex_position) {
return (world_from_local * vertex_position);
}
vec4 sample_palette(uint index, uvec3 palette) {
uint palette_index = 0u;
uint free_indices_0_ = 0u;
uint free_indices_1_ = 0u;
uint free_bits = 0u;
uint lock_counter = 0u;
uint i = 0u;
uint free_indices = 0u;
uint palette_offset = palette.y;
uint palette_lock = palette.z;
palette_index = (index % PALETTE_SIZE);
uint _e8 = palette_index;
bool is_free = (((palette_lock >> _e8) & 1u) == 0u);
if (is_free) {
if ((palette_lock > 0u)) {
lock_counter = palette_lock;
bool loop_init = true;
while(true) {
if (!loop_init) {
uint _e59 = i;
i = (_e59 + 1u);
}
loop_init = false;
uint _e18 = i;
if ((_e18 < PALETTE_SIZE)) {
} else {
break;
}
{
uint _e21 = lock_counter;
if (((_e21 & 1u) == 0u)) {
uint _e27 = free_bits;
uint _e28 = free_bits;
uint buffer_offset = (_e27 - ((_e28 / 8u) * 8u));
uint _e34 = i;
uint value = (uint(_e34) << (4u * buffer_offset));
uint _e39 = free_bits;
if ((buffer_offset < _e39)) {
uint _e42 = free_indices_1_;
free_indices_1_ = (_e42 | value);
} else {
uint _e45 = free_indices_0_;
free_indices_0_ = (_e45 | value);
}
uint _e48 = free_bits;
free_bits = (_e48 + 1u);
} else {
uint _e50 = i;
if ((_e50 < index)) {
uint _e53 = palette_index;
palette_index = (_e53 - 1u);
}
}
uint _e56 = lock_counter;
lock_counter = (_e56 >> 1u);
}
}
uint _e61 = palette_index;
uint _e63 = free_bits;
palette_index = ((_e61 + palette_offset) % _e63);
uint _e65 = free_indices_0_;
free_indices = _e65;
uint _e67 = palette_index;
if ((_e67 > 7u)) {
uint _e70 = free_indices_1_;
free_indices = _e70;
uint _e72 = palette_index;
palette_index = (_e72 - 8u);
}
uint _e74 = free_indices;
uint _e75 = palette_index;
palette_index = ((_e74 >> (_e75 * 4u)) & 15u);
} else {
uint _e81 = palette_index;
palette_index = ((_e81 + palette_offset) % PALETTE_SIZE);
}
}
uint _e85 = palette_index;
vec2 palette_uv_1 = vec2(fract((float(_e85) / 16.0)), 0.0);
vec4 _e95 = textureLod(_group_2_binding_2_fs, vec2(palette_uv_1), 0.0);
return _e95;
}
vec4 sample_sprite(uint atlas_index, uvec3 palette_1, vec2 uv) {
uint palette_index_1 = 0u;
vec2 atlas_coordinates = vec2(float((atlas_index % 16u)), float(((atlas_index / 16u) % 16u)));
vec2 atlas_uv = ((vec2(uv.x, (1.0 - uv.y)) / vec2(16.0)) + (atlas_coordinates / vec2(16.0)));
vec4 _e26 = textureLod(_group_2_binding_0_fs, vec2(atlas_uv), 0.0);
palette_index_1 = uint((_e26.x * 256.0));
uint _e32 = palette_index_1;
vec4 _e34 = sample_palette(_e32, palette_1);
return _e34;
}
vec4 sample_map_layer(uint layer, uvec2 source_xy, vec2 length_, uvec3 palette_2, vec2 uv_1) {
vec2 map_uv = vec2(uv_1.x, (1.0 - uv_1.y));
uvec2 map_size = uvec2(textureSize(_group_2_binding_4_fs, 0).xy).xy;
vec2 map_source_xy = (vec2(source_xy) / CHARACTER_PIXEL_SIZE);
vec2 map_length = floor((length_ / CHARACTER_PIXEL_SIZE));
uvec2 map_coords = uvec2((map_source_xy + (map_length * map_uv)));
uvec4 _e24 = texelFetch(_group_2_binding_4_fs, ivec3(map_coords, layer), 0);
uint atlas_index_1 = _e24.x;
vec2 tile_length = (length_ / CHARACTER_PIXEL_SIZE);
vec2 tile = ((tile_length * map_uv) + fract(map_source_xy));
vec2 tile_uv = fract(tile);
vec4 _e38 = sample_sprite(atlas_index_1, palette_2, vec2(tile_uv.x, (1.0 - tile_uv.y)));
return _e38;
}
vec4 sample_map(uvec2 source_xy_1, vec2 length_1, uint layer_mask, uvec3 palette_3, vec2 uv_2) {
bool mask_includes[4] = bool[4](true, true, true, true);
vec4 final_color = vec4(0.0);
uint i_1 = 0u;
uint map_layers = min(uint(textureSize(_group_2_binding_4_fs).z), MAX_MAP_LAYERS);
if ((layer_mask > 0u)) {
mask_includes = bool[4](((layer_mask & 1u) == 1u), (((layer_mask >> 1u) & 1u) == 1u), (((layer_mask >> 1u) & 1u) == 1u), (((layer_mask >> 1u) & 1u) == 1u));
}
bool loop_init_1 = true;
while(true) {
if (!loop_init_1) {
uint _e54 = i_1;
i_1 = (_e54 + 1u);
}
loop_init_1 = false;
uint _e37 = i_1;
if ((_e37 < map_layers)) {
} else {
break;
}
{
uint _e39 = i_1;
bool include_layer = mask_includes[_e39];
if (!(include_layer)) {
continue;
}
uint _e43 = i_1;
vec4 _e48 = sample_map_layer(_e43, source_xy_1, length_1, palette_3, uv_2);
if ((_e48.w > 0.0)) {
final_color = _e48;
}
}
}
vec4 _e56 = final_color;
return _e56;
}
void main() {
VertexOutput in_ = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1, _vs2fs_location2, _vs2fs_location3, _vs2fs_location4, _vs2fs_location5, _vs2fs_location6);
vec2 palette_uv = vec2(0.1875, 0.0);
uint operation = in_.operation;
uint atlas_index_2 = in_.atlas_index;
vec2 uv_3 = in_.uv;
uvec3 palette_4 = in_.palette;
vec2 length_2 = in_.length_;
uvec2 source_xy_2 = in_.source_xy;
uint layer_mask_1 = in_.layer_mask;
if ((operation == SPRITE_OPERATION)) {
vec4 _e13 = sample_sprite(atlas_index_2, palette_4, uv_3);
_fs2p_location0 = _e13;
return;
} else {
if ((operation == MAP_OPERATION)) {
vec4 _e16 = sample_map(source_xy_2, length_2, layer_mask_1, palette_4, uv_3);
_fs2p_location0 = _e16;
return;
}
}
_fs2p_location0 = vec4(0.0);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment