mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-05 23:45:42 +00:00
normalize line endings in generated files
This commit is contained in:
committed by
Ryan Fleury
parent
9447cce94d
commit
c62afbcf83
@@ -1,69 +1,69 @@
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
String8* r_d3d11_g_vshad_kind_source_table[5] =
|
||||
{
|
||||
&r_d3d11_g_rect_shader_src,
|
||||
&r_d3d11_g_blur_shader_src,
|
||||
&r_d3d11_g_mesh_shader_src,
|
||||
&r_d3d11_g_geo3dcomposite_shader_src,
|
||||
&r_d3d11_g_finalize_shader_src,
|
||||
};
|
||||
|
||||
String8 r_d3d11_g_vshad_kind_source_name_table[5] =
|
||||
{
|
||||
str8_lit_comp("r_d3d11_g_rect_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_blur_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_mesh_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_geo3dcomposite_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_finalize_shader_src"),
|
||||
};
|
||||
|
||||
D3D11_INPUT_ELEMENT_DESC * r_d3d11_g_vshad_kind_elements_ptr_table[5] =
|
||||
{
|
||||
r_d3d11_g_rect_ilay_elements,
|
||||
0,
|
||||
r_d3d11_g_mesh_ilay_elements,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
U64 r_d3d11_g_vshad_kind_elements_count_table[5] =
|
||||
{
|
||||
ArrayCount(r_d3d11_g_rect_ilay_elements) ,
|
||||
0,
|
||||
ArrayCount(r_d3d11_g_mesh_ilay_elements) ,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
String8* r_d3d11_g_pshad_kind_source_table[5] =
|
||||
{
|
||||
&r_d3d11_g_rect_shader_src,
|
||||
&r_d3d11_g_blur_shader_src,
|
||||
&r_d3d11_g_mesh_shader_src,
|
||||
&r_d3d11_g_geo3dcomposite_shader_src,
|
||||
&r_d3d11_g_finalize_shader_src,
|
||||
};
|
||||
|
||||
String8 r_d3d11_g_pshad_kind_source_name_table[5] =
|
||||
{
|
||||
str8_lit_comp("r_d3d11_g_rect_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_blur_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_mesh_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_geo3dcomposite_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_finalize_shader_src"),
|
||||
};
|
||||
|
||||
U64 r_d3d11_g_uniform_type_kind_size_table[3] =
|
||||
{
|
||||
sizeof(R_D3D11_Uniforms_Rect),
|
||||
sizeof(R_D3D11_Uniforms_Blur),
|
||||
sizeof(R_D3D11_Uniforms_Mesh),
|
||||
};
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
String8* r_d3d11_g_vshad_kind_source_table[5] =
|
||||
{
|
||||
&r_d3d11_g_rect_shader_src,
|
||||
&r_d3d11_g_blur_shader_src,
|
||||
&r_d3d11_g_mesh_shader_src,
|
||||
&r_d3d11_g_geo3dcomposite_shader_src,
|
||||
&r_d3d11_g_finalize_shader_src,
|
||||
};
|
||||
|
||||
String8 r_d3d11_g_vshad_kind_source_name_table[5] =
|
||||
{
|
||||
str8_lit_comp("r_d3d11_g_rect_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_blur_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_mesh_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_geo3dcomposite_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_finalize_shader_src"),
|
||||
};
|
||||
|
||||
D3D11_INPUT_ELEMENT_DESC * r_d3d11_g_vshad_kind_elements_ptr_table[5] =
|
||||
{
|
||||
r_d3d11_g_rect_ilay_elements,
|
||||
0,
|
||||
r_d3d11_g_mesh_ilay_elements,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
U64 r_d3d11_g_vshad_kind_elements_count_table[5] =
|
||||
{
|
||||
ArrayCount(r_d3d11_g_rect_ilay_elements) ,
|
||||
0,
|
||||
ArrayCount(r_d3d11_g_mesh_ilay_elements) ,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
String8* r_d3d11_g_pshad_kind_source_table[5] =
|
||||
{
|
||||
&r_d3d11_g_rect_shader_src,
|
||||
&r_d3d11_g_blur_shader_src,
|
||||
&r_d3d11_g_mesh_shader_src,
|
||||
&r_d3d11_g_geo3dcomposite_shader_src,
|
||||
&r_d3d11_g_finalize_shader_src,
|
||||
};
|
||||
|
||||
String8 r_d3d11_g_pshad_kind_source_name_table[5] =
|
||||
{
|
||||
str8_lit_comp("r_d3d11_g_rect_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_blur_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_mesh_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_geo3dcomposite_shader_src"),
|
||||
str8_lit_comp("r_d3d11_g_finalize_shader_src"),
|
||||
};
|
||||
|
||||
U64 r_d3d11_g_uniform_type_kind_size_table[3] =
|
||||
{
|
||||
sizeof(R_D3D11_Uniforms_Rect),
|
||||
sizeof(R_D3D11_Uniforms_Blur),
|
||||
sizeof(R_D3D11_Uniforms_Mesh),
|
||||
};
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
|
||||
@@ -1,483 +1,483 @@
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef RENDER_D3D11_META_H
|
||||
#define RENDER_D3D11_META_H
|
||||
|
||||
typedef enum R_D3D11_VShadKind
|
||||
{
|
||||
R_D3D11_VShadKind_Rect,
|
||||
R_D3D11_VShadKind_Blur,
|
||||
R_D3D11_VShadKind_Mesh,
|
||||
R_D3D11_VShadKind_Geo3DComposite,
|
||||
R_D3D11_VShadKind_Finalize,
|
||||
R_D3D11_VShadKind_COUNT,
|
||||
} R_D3D11_VShadKind;
|
||||
|
||||
typedef enum R_D3D11_PShadKind
|
||||
{
|
||||
R_D3D11_PShadKind_Rect,
|
||||
R_D3D11_PShadKind_Blur,
|
||||
R_D3D11_PShadKind_Mesh,
|
||||
R_D3D11_PShadKind_Geo3DComposite,
|
||||
R_D3D11_PShadKind_Finalize,
|
||||
R_D3D11_PShadKind_COUNT,
|
||||
} R_D3D11_PShadKind;
|
||||
|
||||
typedef enum R_D3D11_UniformTypeKind
|
||||
{
|
||||
R_D3D11_UniformTypeKind_Rect,
|
||||
R_D3D11_UniformTypeKind_Blur,
|
||||
R_D3D11_UniformTypeKind_Mesh,
|
||||
R_D3D11_UniformTypeKind_COUNT,
|
||||
} R_D3D11_UniformTypeKind;
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
read_only global String8 r_d3d11_g_rect_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"cbuffer Globals : register(b0)\n"
|
||||
"{\n"
|
||||
" float2 viewport_size_px;\n"
|
||||
" float opacity;\n"
|
||||
" row_major float4x4 texture_sample_channel_map;\n"
|
||||
" float2 texture_t2d_size_px;\n"
|
||||
" row_major float3x3 xform;\n"
|
||||
" float2 xform_scale;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" float4 dst_rect_px : POS;\n"
|
||||
" float4 src_rect_px : TEX;\n"
|
||||
" float4 color00 : COL0;\n"
|
||||
" float4 color01 : COL1;\n"
|
||||
" float4 color10 : COL2;\n"
|
||||
" float4 color11 : COL3;\n"
|
||||
" float4 corner_radii_px : CRAD;\n"
|
||||
" float4 style_params : STY; // x: border_thickness_px, y: softness_px, z: omit_texture, w: shear\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" nointerpolation float2 rect_half_size_px : PSIZE;\n"
|
||||
" float2 texcoord_pct : TEX;\n"
|
||||
" float2 sdf_sample_pos : SDF;\n"
|
||||
" float4 tint : TINT;\n"
|
||||
" float corner_radius_px : CRAD;\n"
|
||||
" nointerpolation float border_thickness_px : BTHC;\n"
|
||||
" nointerpolation float softness_px : SFT;\n"
|
||||
" nointerpolation float omit_texture : OTX;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D main_t2d : register(t0);\n"
|
||||
"SamplerState main_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"float rect_sdf(float2 sample_pos, float2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float linear_from_srgb_f32(float x)\n"
|
||||
"{\n"
|
||||
" return x < 0.0404482362771082 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float4 linear_from_srgba(float4 v)\n"
|
||||
"{\n"
|
||||
" float4 result = float4(linear_from_srgb_f32(v.x),\n"
|
||||
" linear_from_srgb_f32(v.y),\n"
|
||||
" linear_from_srgb_f32(v.z),\n"
|
||||
" v.w);\n"
|
||||
" return result;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex cpu2vertex)\n"
|
||||
"{\n"
|
||||
" //- rjf: unpack & xform rectangle src/dst vertices\n"
|
||||
" float2 dst_p0_px = cpu2vertex.dst_rect_px.xy;\n"
|
||||
" float2 dst_p1_px = cpu2vertex.dst_rect_px.zw;\n"
|
||||
" float2 src_p0_px = cpu2vertex.src_rect_px.xy;\n"
|
||||
" float2 src_p1_px = cpu2vertex.src_rect_px.zw;\n"
|
||||
" float2 dst_size_px = abs(dst_p1_px - dst_p0_px);\n"
|
||||
" \n"
|
||||
" //- rjf: unpack style params\n"
|
||||
" float border_thickness_px = cpu2vertex.style_params.x;\n"
|
||||
" float softness_px = cpu2vertex.style_params.y;\n"
|
||||
" float omit_texture = cpu2vertex.style_params.z;\n"
|
||||
" float shear_px = cpu2vertex.style_params.w;\n"
|
||||
" \n"
|
||||
" //- rjf: prep per-vertex arrays to sample from (p: position, t: texcoord, c: colorcoord, r: cornerradius)\n"
|
||||
" float2 dst_p_verts_px[] =\n"
|
||||
" {\n"
|
||||
" float2(dst_p0_px.x, dst_p1_px.y),\n"
|
||||
" float2(dst_p0_px.x, dst_p0_px.y),\n"
|
||||
" float2(dst_p1_px.x, dst_p1_px.y + shear_px),\n"
|
||||
" float2(dst_p1_px.x, dst_p0_px.y + shear_px),\n"
|
||||
" };\n"
|
||||
" float2 src_p_verts_px[] =\n"
|
||||
" {\n"
|
||||
" float2(src_p0_px.x, src_p1_px.y),\n"
|
||||
" float2(src_p0_px.x, src_p0_px.y),\n"
|
||||
" float2(src_p1_px.x, src_p1_px.y),\n"
|
||||
" float2(src_p1_px.x, src_p0_px.y),\n"
|
||||
" };\n"
|
||||
" float dst_r_verts_px[] =\n"
|
||||
" {\n"
|
||||
" cpu2vertex.corner_radii_px.y,\n"
|
||||
" cpu2vertex.corner_radii_px.x,\n"
|
||||
" cpu2vertex.corner_radii_px.w,\n"
|
||||
" cpu2vertex.corner_radii_px.z,\n"
|
||||
" };\n"
|
||||
" float4 src_color[] =\n"
|
||||
" {\n"
|
||||
" cpu2vertex.color01,\n"
|
||||
" cpu2vertex.color00,\n"
|
||||
" cpu2vertex.color11,\n"
|
||||
" cpu2vertex.color10,\n"
|
||||
" };\n"
|
||||
" float2 dst_verts_pct = float2((cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,\n"
|
||||
" (cpu2vertex.vertex_id & 1) ? 0.f : 1.f);\n"
|
||||
" \n"
|
||||
" // rjf: fill vertex -> pixel data\n"
|
||||
" Vertex2Pixel vertex2pixel;\n"
|
||||
" {\n"
|
||||
" float2 xformed_pos = mul(xform, float3(dst_p_verts_px[cpu2vertex.vertex_id], 1.f)).xy;\n"
|
||||
" xformed_pos.y = viewport_size_px.y - xformed_pos.y;\n"
|
||||
" vertex2pixel.position.xy = 2.f * xformed_pos/viewport_size_px - 1.f;\n"
|
||||
" vertex2pixel.position.z = 0.f;\n"
|
||||
" vertex2pixel.position.w = 1.f;\n"
|
||||
" vertex2pixel.rect_half_size_px = dst_size_px / 2.f * xform_scale;\n"
|
||||
" vertex2pixel.texcoord_pct = src_p_verts_px[cpu2vertex.vertex_id] / texture_t2d_size_px;\n"
|
||||
" vertex2pixel.sdf_sample_pos = (2.f * dst_verts_pct - 1.f) * vertex2pixel.rect_half_size_px;\n"
|
||||
" vertex2pixel.tint = src_color[cpu2vertex.vertex_id];\n"
|
||||
" vertex2pixel.corner_radius_px = dst_r_verts_px[cpu2vertex.vertex_id];\n"
|
||||
" vertex2pixel.border_thickness_px = border_thickness_px;\n"
|
||||
" vertex2pixel.softness_px = softness_px;\n"
|
||||
" vertex2pixel.omit_texture = omit_texture;\n"
|
||||
" }\n"
|
||||
" return vertex2pixel;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel vertex2pixel) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" // rjf: blend corner colors to produce final tint\n"
|
||||
" float4 tint = vertex2pixel.tint;\n"
|
||||
" \n"
|
||||
" // rjf: sample texture\n"
|
||||
" float4 albedo_sample = float4(1, 1, 1, 1);\n"
|
||||
" if(vertex2pixel.omit_texture < 1)\n"
|
||||
" {\n"
|
||||
" albedo_sample = mul(main_t2d.Sample(main_sampler, vertex2pixel.texcoord_pct), texture_sample_channel_map);\n"
|
||||
" albedo_sample = linear_from_srgba(albedo_sample);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: determine SDF sample position\n"
|
||||
" float2 sdf_sample_pos = vertex2pixel.sdf_sample_pos;\n"
|
||||
" \n"
|
||||
" // rjf: sample for borders\n"
|
||||
" float border_sdf_t = 1;\n"
|
||||
" if(vertex2pixel.border_thickness_px > 0)\n"
|
||||
" {\n"
|
||||
" float border_sdf_s = rect_sdf(sdf_sample_pos,\n"
|
||||
" vertex2pixel.rect_half_size_px - float2(vertex2pixel.softness_px*2.f, vertex2pixel.softness_px*2.f) - vertex2pixel.border_thickness_px,\n"
|
||||
" max(vertex2pixel.corner_radius_px-vertex2pixel.border_thickness_px, 0));\n"
|
||||
" border_sdf_t = smoothstep(0, 2*vertex2pixel.softness_px, border_sdf_s);\n"
|
||||
" }\n"
|
||||
" if(border_sdf_t < 0.001f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_t = 1;\n"
|
||||
" if(vertex2pixel.corner_radius_px > 0 || vertex2pixel.softness_px > 0.75f)\n"
|
||||
" {\n"
|
||||
" float corner_sdf_s = rect_sdf(sdf_sample_pos,\n"
|
||||
" vertex2pixel.rect_half_size_px - float2(vertex2pixel.softness_px*2.f, vertex2pixel.softness_px*2.f),\n"
|
||||
" vertex2pixel.corner_radius_px);\n"
|
||||
" corner_sdf_t = 1-smoothstep(0, 2*vertex2pixel.softness_px, corner_sdf_s);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: form+return final color\n"
|
||||
" float4 final_color = albedo_sample;\n"
|
||||
" final_color *= tint;\n"
|
||||
" final_color.a *= opacity;\n"
|
||||
" final_color.a *= corner_sdf_t;\n"
|
||||
" final_color.a *= border_sdf_t;\n"
|
||||
" return final_color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_blur_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"cbuffer Globals : register(b0)\n"
|
||||
"{\n"
|
||||
" float4 rect;\n"
|
||||
" float4 corner_radii_px;\n"
|
||||
" float2 direction;\n"
|
||||
" float2 viewport_size;\n"
|
||||
" uint blur_count;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"cbuffer Kernel : register(b1)\n"
|
||||
"{\n"
|
||||
" float4 kernel[32];\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
" float2 sdf_sample_pos : SDF;\n"
|
||||
" nointerpolation float2 rect_half_size : RHS;\n"
|
||||
" float corner_radius : RAD;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D stage_t2d : register(t0);\n"
|
||||
"SamplerState stage_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"float rect_sdf(float2 sample_pos, float2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" float2 vertex_positions__scrn[] =\n"
|
||||
" {\n"
|
||||
" rect.xw,\n"
|
||||
" rect.xy,\n"
|
||||
" rect.zw,\n"
|
||||
" rect.zy,\n"
|
||||
" };\n"
|
||||
" float corner_radii__px[] =\n"
|
||||
" {\n"
|
||||
" corner_radii_px.y,\n"
|
||||
" corner_radii_px.x,\n"
|
||||
" corner_radii_px.w,\n"
|
||||
" corner_radii_px.z,\n"
|
||||
" };\n"
|
||||
" float2 cornercoords__pct = float2((c2v.vertex_id >> 1) ? 1.f : 0.f,\n"
|
||||
" (c2v.vertex_id & 1) ? 0.f : 1.f);\n"
|
||||
" \n"
|
||||
" float2 vertex_position__pct = vertex_positions__scrn[c2v.vertex_id] / viewport_size;\n"
|
||||
" float2 vertex_position__scr = 2.f * vertex_position__pct - 1.f;\n"
|
||||
" \n"
|
||||
" float2 rect_half_size = float2((rect.z-rect.x)/2, (rect.w-rect.y)/2);\n"
|
||||
" \n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" {\n"
|
||||
" v2p.position = float4(vertex_position__scr.x, -vertex_position__scr.y, 0.f, 1.f);\n"
|
||||
" v2p.texcoord = vertex_position__pct;\n"
|
||||
" v2p.sdf_sample_pos = (2.f * cornercoords__pct - 1.f) * rect_half_size;\n"
|
||||
" v2p.rect_half_size = rect_half_size - 2.f;\n"
|
||||
" v2p.corner_radius = corner_radii__px[c2v.vertex_id];\n"
|
||||
" }\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" // rjf: blend weighted texture samples into color\n"
|
||||
" float3 color = kernel[0].x * stage_t2d.Sample(stage_sampler, v2p.texcoord).rgb;\n"
|
||||
" for(uint i = 1; i < blur_count; i += 1)\n"
|
||||
" {\n"
|
||||
" float weight = kernel[i].x;\n"
|
||||
" float offset = kernel[i].y;\n"
|
||||
" color += weight * stage_t2d.Sample(stage_sampler, v2p.texcoord - offset * direction).rgb;\n"
|
||||
" color += weight * stage_t2d.Sample(stage_sampler, v2p.texcoord + offset * direction).rgb;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_s = rect_sdf(v2p.sdf_sample_pos, v2p.rect_half_size, v2p.corner_radius);\n"
|
||||
" float corner_sdf_t = 1-smoothstep(0, 2, corner_sdf_s);\n"
|
||||
" \n"
|
||||
" // rjf: weight output color by sdf\n"
|
||||
" // this is doing alpha testing, leave blurring only where mostly opaque pixels are\n"
|
||||
" if(corner_sdf_t < 0.9f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return float4(color, 1.f);\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_mesh_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"cbuffer Uniforms : register(b0)\n"
|
||||
"{\n"
|
||||
" row_major float4x4 xform;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" float3 position : POS;\n"
|
||||
" float3 normal : NOR;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
" float3 color : COL;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
" float4 color : COL;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Vertex2Pixel vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" v2p.position = mul(float4(c2v.position, 1.f), xform);\n"
|
||||
" v2p.texcoord = c2v.texcoord;\n"
|
||||
" v2p.color = float4(c2v.color, 1.f);\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float4 ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" return v2p.color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_geo3dcomposite_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D stage_t2d : register(t0);\n"
|
||||
"SamplerState stage_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" float4 vertex_positions__modl[] =\n"
|
||||
" {\n"
|
||||
" float4(0, 0, 0, 1),\n"
|
||||
" float4(0, 1, 0, 1),\n"
|
||||
" float4(1, 0, 0, 1),\n"
|
||||
" float4(1, 1, 0, 1),\n"
|
||||
" };\n"
|
||||
" float4 vertex_position__modl = vertex_positions__modl[c2v.vertex_id];\n"
|
||||
" float4 vertex_position__clip = float4(2*vertex_position__modl.x - 1, 2*vertex_position__modl.y - 1, 0, 1);\n"
|
||||
" float2 texcoord = float2(vertex_position__modl.x, vertex_position__modl.y);\n"
|
||||
" texcoord.y = 1-texcoord.y;\n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" {\n"
|
||||
" v2p.position = vertex_position__clip;\n"
|
||||
" v2p.texcoord = texcoord;\n"
|
||||
" }\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" float4 final_color = stage_t2d.Sample(stage_sampler, v2p.texcoord);\n"
|
||||
" return final_color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_finalize_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D stage_t2d : register(t0);\n"
|
||||
"SamplerState stage_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" float4 vertex_positions__modl[] =\n"
|
||||
" {\n"
|
||||
" float4(0, 0, 0, 1),\n"
|
||||
" float4(0, 1, 0, 1),\n"
|
||||
" float4(1, 0, 0, 1),\n"
|
||||
" float4(1, 1, 0, 1),\n"
|
||||
" };\n"
|
||||
" float4 vertex_position__modl = vertex_positions__modl[c2v.vertex_id];\n"
|
||||
" float4 vertex_position__clip = float4(2*vertex_position__modl.x - 1, 2*vertex_position__modl.y - 1, 0, 1);\n"
|
||||
" float2 texcoord = float2(vertex_position__modl.x, vertex_position__modl.y);\n"
|
||||
" texcoord.y = 1-texcoord.y;\n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" {\n"
|
||||
" v2p.position = vertex_position__clip;\n"
|
||||
" v2p.texcoord = texcoord;\n"
|
||||
" }\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" float4 final_color = stage_t2d.Sample(stage_sampler, v2p.texcoord);\n"
|
||||
" final_color.a = 1;\n"
|
||||
" return final_color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
#endif // RENDER_D3D11_META_H
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef RENDER_D3D11_META_H
|
||||
#define RENDER_D3D11_META_H
|
||||
|
||||
typedef enum R_D3D11_VShadKind
|
||||
{
|
||||
R_D3D11_VShadKind_Rect,
|
||||
R_D3D11_VShadKind_Blur,
|
||||
R_D3D11_VShadKind_Mesh,
|
||||
R_D3D11_VShadKind_Geo3DComposite,
|
||||
R_D3D11_VShadKind_Finalize,
|
||||
R_D3D11_VShadKind_COUNT,
|
||||
} R_D3D11_VShadKind;
|
||||
|
||||
typedef enum R_D3D11_PShadKind
|
||||
{
|
||||
R_D3D11_PShadKind_Rect,
|
||||
R_D3D11_PShadKind_Blur,
|
||||
R_D3D11_PShadKind_Mesh,
|
||||
R_D3D11_PShadKind_Geo3DComposite,
|
||||
R_D3D11_PShadKind_Finalize,
|
||||
R_D3D11_PShadKind_COUNT,
|
||||
} R_D3D11_PShadKind;
|
||||
|
||||
typedef enum R_D3D11_UniformTypeKind
|
||||
{
|
||||
R_D3D11_UniformTypeKind_Rect,
|
||||
R_D3D11_UniformTypeKind_Blur,
|
||||
R_D3D11_UniformTypeKind_Mesh,
|
||||
R_D3D11_UniformTypeKind_COUNT,
|
||||
} R_D3D11_UniformTypeKind;
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
read_only global String8 r_d3d11_g_rect_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"cbuffer Globals : register(b0)\n"
|
||||
"{\n"
|
||||
" float2 viewport_size_px;\n"
|
||||
" float opacity;\n"
|
||||
" row_major float4x4 texture_sample_channel_map;\n"
|
||||
" float2 texture_t2d_size_px;\n"
|
||||
" row_major float3x3 xform;\n"
|
||||
" float2 xform_scale;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" float4 dst_rect_px : POS;\n"
|
||||
" float4 src_rect_px : TEX;\n"
|
||||
" float4 color00 : COL0;\n"
|
||||
" float4 color01 : COL1;\n"
|
||||
" float4 color10 : COL2;\n"
|
||||
" float4 color11 : COL3;\n"
|
||||
" float4 corner_radii_px : CRAD;\n"
|
||||
" float4 style_params : STY; // x: border_thickness_px, y: softness_px, z: omit_texture, w: shear\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" nointerpolation float2 rect_half_size_px : PSIZE;\n"
|
||||
" float2 texcoord_pct : TEX;\n"
|
||||
" float2 sdf_sample_pos : SDF;\n"
|
||||
" float4 tint : TINT;\n"
|
||||
" float corner_radius_px : CRAD;\n"
|
||||
" nointerpolation float border_thickness_px : BTHC;\n"
|
||||
" nointerpolation float softness_px : SFT;\n"
|
||||
" nointerpolation float omit_texture : OTX;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D main_t2d : register(t0);\n"
|
||||
"SamplerState main_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"float rect_sdf(float2 sample_pos, float2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float linear_from_srgb_f32(float x)\n"
|
||||
"{\n"
|
||||
" return x < 0.0404482362771082 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float4 linear_from_srgba(float4 v)\n"
|
||||
"{\n"
|
||||
" float4 result = float4(linear_from_srgb_f32(v.x),\n"
|
||||
" linear_from_srgb_f32(v.y),\n"
|
||||
" linear_from_srgb_f32(v.z),\n"
|
||||
" v.w);\n"
|
||||
" return result;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex cpu2vertex)\n"
|
||||
"{\n"
|
||||
" //- rjf: unpack & xform rectangle src/dst vertices\n"
|
||||
" float2 dst_p0_px = cpu2vertex.dst_rect_px.xy;\n"
|
||||
" float2 dst_p1_px = cpu2vertex.dst_rect_px.zw;\n"
|
||||
" float2 src_p0_px = cpu2vertex.src_rect_px.xy;\n"
|
||||
" float2 src_p1_px = cpu2vertex.src_rect_px.zw;\n"
|
||||
" float2 dst_size_px = abs(dst_p1_px - dst_p0_px);\n"
|
||||
" \n"
|
||||
" //- rjf: unpack style params\n"
|
||||
" float border_thickness_px = cpu2vertex.style_params.x;\n"
|
||||
" float softness_px = cpu2vertex.style_params.y;\n"
|
||||
" float omit_texture = cpu2vertex.style_params.z;\n"
|
||||
" float shear_px = cpu2vertex.style_params.w;\n"
|
||||
" \n"
|
||||
" //- rjf: prep per-vertex arrays to sample from (p: position, t: texcoord, c: colorcoord, r: cornerradius)\n"
|
||||
" float2 dst_p_verts_px[] =\n"
|
||||
" {\n"
|
||||
" float2(dst_p0_px.x, dst_p1_px.y),\n"
|
||||
" float2(dst_p0_px.x, dst_p0_px.y),\n"
|
||||
" float2(dst_p1_px.x, dst_p1_px.y + shear_px),\n"
|
||||
" float2(dst_p1_px.x, dst_p0_px.y + shear_px),\n"
|
||||
" };\n"
|
||||
" float2 src_p_verts_px[] =\n"
|
||||
" {\n"
|
||||
" float2(src_p0_px.x, src_p1_px.y),\n"
|
||||
" float2(src_p0_px.x, src_p0_px.y),\n"
|
||||
" float2(src_p1_px.x, src_p1_px.y),\n"
|
||||
" float2(src_p1_px.x, src_p0_px.y),\n"
|
||||
" };\n"
|
||||
" float dst_r_verts_px[] =\n"
|
||||
" {\n"
|
||||
" cpu2vertex.corner_radii_px.y,\n"
|
||||
" cpu2vertex.corner_radii_px.x,\n"
|
||||
" cpu2vertex.corner_radii_px.w,\n"
|
||||
" cpu2vertex.corner_radii_px.z,\n"
|
||||
" };\n"
|
||||
" float4 src_color[] =\n"
|
||||
" {\n"
|
||||
" cpu2vertex.color01,\n"
|
||||
" cpu2vertex.color00,\n"
|
||||
" cpu2vertex.color11,\n"
|
||||
" cpu2vertex.color10,\n"
|
||||
" };\n"
|
||||
" float2 dst_verts_pct = float2((cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,\n"
|
||||
" (cpu2vertex.vertex_id & 1) ? 0.f : 1.f);\n"
|
||||
" \n"
|
||||
" // rjf: fill vertex -> pixel data\n"
|
||||
" Vertex2Pixel vertex2pixel;\n"
|
||||
" {\n"
|
||||
" float2 xformed_pos = mul(xform, float3(dst_p_verts_px[cpu2vertex.vertex_id], 1.f)).xy;\n"
|
||||
" xformed_pos.y = viewport_size_px.y - xformed_pos.y;\n"
|
||||
" vertex2pixel.position.xy = 2.f * xformed_pos/viewport_size_px - 1.f;\n"
|
||||
" vertex2pixel.position.z = 0.f;\n"
|
||||
" vertex2pixel.position.w = 1.f;\n"
|
||||
" vertex2pixel.rect_half_size_px = dst_size_px / 2.f * xform_scale;\n"
|
||||
" vertex2pixel.texcoord_pct = src_p_verts_px[cpu2vertex.vertex_id] / texture_t2d_size_px;\n"
|
||||
" vertex2pixel.sdf_sample_pos = (2.f * dst_verts_pct - 1.f) * vertex2pixel.rect_half_size_px;\n"
|
||||
" vertex2pixel.tint = src_color[cpu2vertex.vertex_id];\n"
|
||||
" vertex2pixel.corner_radius_px = dst_r_verts_px[cpu2vertex.vertex_id];\n"
|
||||
" vertex2pixel.border_thickness_px = border_thickness_px;\n"
|
||||
" vertex2pixel.softness_px = softness_px;\n"
|
||||
" vertex2pixel.omit_texture = omit_texture;\n"
|
||||
" }\n"
|
||||
" return vertex2pixel;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel vertex2pixel) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" // rjf: blend corner colors to produce final tint\n"
|
||||
" float4 tint = vertex2pixel.tint;\n"
|
||||
" \n"
|
||||
" // rjf: sample texture\n"
|
||||
" float4 albedo_sample = float4(1, 1, 1, 1);\n"
|
||||
" if(vertex2pixel.omit_texture < 1)\n"
|
||||
" {\n"
|
||||
" albedo_sample = mul(main_t2d.Sample(main_sampler, vertex2pixel.texcoord_pct), texture_sample_channel_map);\n"
|
||||
" albedo_sample = linear_from_srgba(albedo_sample);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: determine SDF sample position\n"
|
||||
" float2 sdf_sample_pos = vertex2pixel.sdf_sample_pos;\n"
|
||||
" \n"
|
||||
" // rjf: sample for borders\n"
|
||||
" float border_sdf_t = 1;\n"
|
||||
" if(vertex2pixel.border_thickness_px > 0)\n"
|
||||
" {\n"
|
||||
" float border_sdf_s = rect_sdf(sdf_sample_pos,\n"
|
||||
" vertex2pixel.rect_half_size_px - float2(vertex2pixel.softness_px*2.f, vertex2pixel.softness_px*2.f) - vertex2pixel.border_thickness_px,\n"
|
||||
" max(vertex2pixel.corner_radius_px-vertex2pixel.border_thickness_px, 0));\n"
|
||||
" border_sdf_t = smoothstep(0, 2*vertex2pixel.softness_px, border_sdf_s);\n"
|
||||
" }\n"
|
||||
" if(border_sdf_t < 0.001f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_t = 1;\n"
|
||||
" if(vertex2pixel.corner_radius_px > 0 || vertex2pixel.softness_px > 0.75f)\n"
|
||||
" {\n"
|
||||
" float corner_sdf_s = rect_sdf(sdf_sample_pos,\n"
|
||||
" vertex2pixel.rect_half_size_px - float2(vertex2pixel.softness_px*2.f, vertex2pixel.softness_px*2.f),\n"
|
||||
" vertex2pixel.corner_radius_px);\n"
|
||||
" corner_sdf_t = 1-smoothstep(0, 2*vertex2pixel.softness_px, corner_sdf_s);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: form+return final color\n"
|
||||
" float4 final_color = albedo_sample;\n"
|
||||
" final_color *= tint;\n"
|
||||
" final_color.a *= opacity;\n"
|
||||
" final_color.a *= corner_sdf_t;\n"
|
||||
" final_color.a *= border_sdf_t;\n"
|
||||
" return final_color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_blur_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"cbuffer Globals : register(b0)\n"
|
||||
"{\n"
|
||||
" float4 rect;\n"
|
||||
" float4 corner_radii_px;\n"
|
||||
" float2 direction;\n"
|
||||
" float2 viewport_size;\n"
|
||||
" uint blur_count;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"cbuffer Kernel : register(b1)\n"
|
||||
"{\n"
|
||||
" float4 kernel[32];\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
" float2 sdf_sample_pos : SDF;\n"
|
||||
" nointerpolation float2 rect_half_size : RHS;\n"
|
||||
" float corner_radius : RAD;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D stage_t2d : register(t0);\n"
|
||||
"SamplerState stage_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"float rect_sdf(float2 sample_pos, float2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" float2 vertex_positions__scrn[] =\n"
|
||||
" {\n"
|
||||
" rect.xw,\n"
|
||||
" rect.xy,\n"
|
||||
" rect.zw,\n"
|
||||
" rect.zy,\n"
|
||||
" };\n"
|
||||
" float corner_radii__px[] =\n"
|
||||
" {\n"
|
||||
" corner_radii_px.y,\n"
|
||||
" corner_radii_px.x,\n"
|
||||
" corner_radii_px.w,\n"
|
||||
" corner_radii_px.z,\n"
|
||||
" };\n"
|
||||
" float2 cornercoords__pct = float2((c2v.vertex_id >> 1) ? 1.f : 0.f,\n"
|
||||
" (c2v.vertex_id & 1) ? 0.f : 1.f);\n"
|
||||
" \n"
|
||||
" float2 vertex_position__pct = vertex_positions__scrn[c2v.vertex_id] / viewport_size;\n"
|
||||
" float2 vertex_position__scr = 2.f * vertex_position__pct - 1.f;\n"
|
||||
" \n"
|
||||
" float2 rect_half_size = float2((rect.z-rect.x)/2, (rect.w-rect.y)/2);\n"
|
||||
" \n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" {\n"
|
||||
" v2p.position = float4(vertex_position__scr.x, -vertex_position__scr.y, 0.f, 1.f);\n"
|
||||
" v2p.texcoord = vertex_position__pct;\n"
|
||||
" v2p.sdf_sample_pos = (2.f * cornercoords__pct - 1.f) * rect_half_size;\n"
|
||||
" v2p.rect_half_size = rect_half_size - 2.f;\n"
|
||||
" v2p.corner_radius = corner_radii__px[c2v.vertex_id];\n"
|
||||
" }\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" // rjf: blend weighted texture samples into color\n"
|
||||
" float3 color = kernel[0].x * stage_t2d.Sample(stage_sampler, v2p.texcoord).rgb;\n"
|
||||
" for(uint i = 1; i < blur_count; i += 1)\n"
|
||||
" {\n"
|
||||
" float weight = kernel[i].x;\n"
|
||||
" float offset = kernel[i].y;\n"
|
||||
" color += weight * stage_t2d.Sample(stage_sampler, v2p.texcoord - offset * direction).rgb;\n"
|
||||
" color += weight * stage_t2d.Sample(stage_sampler, v2p.texcoord + offset * direction).rgb;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_s = rect_sdf(v2p.sdf_sample_pos, v2p.rect_half_size, v2p.corner_radius);\n"
|
||||
" float corner_sdf_t = 1-smoothstep(0, 2, corner_sdf_s);\n"
|
||||
" \n"
|
||||
" // rjf: weight output color by sdf\n"
|
||||
" // this is doing alpha testing, leave blurring only where mostly opaque pixels are\n"
|
||||
" if(corner_sdf_t < 0.9f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return float4(color, 1.f);\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_mesh_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"cbuffer Uniforms : register(b0)\n"
|
||||
"{\n"
|
||||
" row_major float4x4 xform;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" float3 position : POS;\n"
|
||||
" float3 normal : NOR;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
" float3 color : COL;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
" float4 color : COL;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Vertex2Pixel vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" v2p.position = mul(float4(c2v.position, 1.f), xform);\n"
|
||||
" v2p.texcoord = c2v.texcoord;\n"
|
||||
" v2p.color = float4(c2v.color, 1.f);\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float4 ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" return v2p.color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_geo3dcomposite_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D stage_t2d : register(t0);\n"
|
||||
"SamplerState stage_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" float4 vertex_positions__modl[] =\n"
|
||||
" {\n"
|
||||
" float4(0, 0, 0, 1),\n"
|
||||
" float4(0, 1, 0, 1),\n"
|
||||
" float4(1, 0, 0, 1),\n"
|
||||
" float4(1, 1, 0, 1),\n"
|
||||
" };\n"
|
||||
" float4 vertex_position__modl = vertex_positions__modl[c2v.vertex_id];\n"
|
||||
" float4 vertex_position__clip = float4(2*vertex_position__modl.x - 1, 2*vertex_position__modl.y - 1, 0, 1);\n"
|
||||
" float2 texcoord = float2(vertex_position__modl.x, vertex_position__modl.y);\n"
|
||||
" texcoord.y = 1-texcoord.y;\n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" {\n"
|
||||
" v2p.position = vertex_position__clip;\n"
|
||||
" v2p.texcoord = texcoord;\n"
|
||||
" }\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" float4 final_color = stage_t2d.Sample(stage_sampler, v2p.texcoord);\n"
|
||||
" return final_color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_d3d11_g_finalize_shader_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"struct CPU2Vertex\n"
|
||||
"{\n"
|
||||
" uint vertex_id : SV_VertexID;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Vertex2Pixel\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D stage_t2d : register(t0);\n"
|
||||
"SamplerState stage_sampler : register(s0);\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
"vs_main(CPU2Vertex c2v)\n"
|
||||
"{\n"
|
||||
" float4 vertex_positions__modl[] =\n"
|
||||
" {\n"
|
||||
" float4(0, 0, 0, 1),\n"
|
||||
" float4(0, 1, 0, 1),\n"
|
||||
" float4(1, 0, 0, 1),\n"
|
||||
" float4(1, 1, 0, 1),\n"
|
||||
" };\n"
|
||||
" float4 vertex_position__modl = vertex_positions__modl[c2v.vertex_id];\n"
|
||||
" float4 vertex_position__clip = float4(2*vertex_position__modl.x - 1, 2*vertex_position__modl.y - 1, 0, 1);\n"
|
||||
" float2 texcoord = float2(vertex_position__modl.x, vertex_position__modl.y);\n"
|
||||
" texcoord.y = 1-texcoord.y;\n"
|
||||
" Vertex2Pixel v2p;\n"
|
||||
" {\n"
|
||||
" v2p.position = vertex_position__clip;\n"
|
||||
" v2p.texcoord = texcoord;\n"
|
||||
" }\n"
|
||||
" return v2p;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: pixel shader\n"
|
||||
"\n"
|
||||
"float4\n"
|
||||
"ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" float4 final_color = stage_t2d.Sample(stage_sampler, v2p.texcoord);\n"
|
||||
" final_color.a = 1;\n"
|
||||
" return final_color;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
#endif // RENDER_D3D11_META_H
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
String8 r_tex2d_format_display_string_table[9] =
|
||||
{
|
||||
str8_lit_comp("R8"),
|
||||
str8_lit_comp("RG8"),
|
||||
str8_lit_comp("RGBA8"),
|
||||
str8_lit_comp("BGRA8"),
|
||||
str8_lit_comp("R16"),
|
||||
str8_lit_comp("RGBA16"),
|
||||
str8_lit_comp("R32"),
|
||||
str8_lit_comp("RG32"),
|
||||
str8_lit_comp("RGBA32"),
|
||||
};
|
||||
|
||||
U8 r_tex2d_format_bytes_per_pixel_table[9] =
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
4,
|
||||
2,
|
||||
8,
|
||||
4,
|
||||
8,
|
||||
16,
|
||||
};
|
||||
|
||||
String8 r_resource_kind_display_string_table[3] =
|
||||
{
|
||||
str8_lit_comp("Static"),
|
||||
str8_lit_comp("Dynamic"),
|
||||
str8_lit_comp("Stream "),
|
||||
};
|
||||
|
||||
String8 r_tex2d_sample_kind_display_string_table[2] =
|
||||
{
|
||||
str8_lit_comp("Nearest"),
|
||||
str8_lit_comp("Linear"),
|
||||
};
|
||||
|
||||
String8 r_pass_kind_display_string_table[3] =
|
||||
{
|
||||
str8_lit_comp("UI"),
|
||||
str8_lit_comp("Blur"),
|
||||
str8_lit_comp("Geo3D"),
|
||||
};
|
||||
|
||||
U8 r_pass_kind_batch_table[3] =
|
||||
{
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
};
|
||||
|
||||
U64 r_pass_kind_params_size_table[3] =
|
||||
{
|
||||
sizeof(R_PassParams_UI),
|
||||
sizeof(R_PassParams_Blur),
|
||||
sizeof(R_PassParams_Geo3D),
|
||||
};
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
String8 r_tex2d_format_display_string_table[9] =
|
||||
{
|
||||
str8_lit_comp("R8"),
|
||||
str8_lit_comp("RG8"),
|
||||
str8_lit_comp("RGBA8"),
|
||||
str8_lit_comp("BGRA8"),
|
||||
str8_lit_comp("R16"),
|
||||
str8_lit_comp("RGBA16"),
|
||||
str8_lit_comp("R32"),
|
||||
str8_lit_comp("RG32"),
|
||||
str8_lit_comp("RGBA32"),
|
||||
};
|
||||
|
||||
U8 r_tex2d_format_bytes_per_pixel_table[9] =
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
4,
|
||||
2,
|
||||
8,
|
||||
4,
|
||||
8,
|
||||
16,
|
||||
};
|
||||
|
||||
String8 r_resource_kind_display_string_table[3] =
|
||||
{
|
||||
str8_lit_comp("Static"),
|
||||
str8_lit_comp("Dynamic"),
|
||||
str8_lit_comp("Stream "),
|
||||
};
|
||||
|
||||
String8 r_tex2d_sample_kind_display_string_table[2] =
|
||||
{
|
||||
str8_lit_comp("Nearest"),
|
||||
str8_lit_comp("Linear"),
|
||||
};
|
||||
|
||||
String8 r_pass_kind_display_string_table[3] =
|
||||
{
|
||||
str8_lit_comp("UI"),
|
||||
str8_lit_comp("Blur"),
|
||||
str8_lit_comp("Geo3D"),
|
||||
};
|
||||
|
||||
U8 r_pass_kind_batch_table[3] =
|
||||
{
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
};
|
||||
|
||||
U64 r_pass_kind_params_size_table[3] =
|
||||
{
|
||||
sizeof(R_PassParams_UI),
|
||||
sizeof(R_PassParams_Blur),
|
||||
sizeof(R_PassParams_Geo3D),
|
||||
};
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef RENDER_META_H
|
||||
#define RENDER_META_H
|
||||
|
||||
typedef enum R_Tex2DFormat
|
||||
{
|
||||
R_Tex2DFormat_R8,
|
||||
R_Tex2DFormat_RG8,
|
||||
R_Tex2DFormat_RGBA8,
|
||||
R_Tex2DFormat_BGRA8,
|
||||
R_Tex2DFormat_R16,
|
||||
R_Tex2DFormat_RGBA16,
|
||||
R_Tex2DFormat_R32,
|
||||
R_Tex2DFormat_RG32,
|
||||
R_Tex2DFormat_RGBA32,
|
||||
R_Tex2DFormat_COUNT,
|
||||
} R_Tex2DFormat;
|
||||
|
||||
typedef enum R_ResourceKind
|
||||
{
|
||||
R_ResourceKind_Static,
|
||||
R_ResourceKind_Dynamic,
|
||||
R_ResourceKind_Stream,
|
||||
R_ResourceKind_COUNT,
|
||||
} R_ResourceKind;
|
||||
|
||||
typedef enum R_Tex2DSampleKind
|
||||
{
|
||||
R_Tex2DSampleKind_Nearest,
|
||||
R_Tex2DSampleKind_Linear,
|
||||
R_Tex2DSampleKind_COUNT,
|
||||
} R_Tex2DSampleKind;
|
||||
|
||||
typedef enum R_GeoTopologyKind
|
||||
{
|
||||
R_GeoTopologyKind_Lines,
|
||||
R_GeoTopologyKind_LineStrip,
|
||||
R_GeoTopologyKind_Triangles,
|
||||
R_GeoTopologyKind_TriangleStrip,
|
||||
R_GeoTopologyKind_COUNT,
|
||||
} R_GeoTopologyKind;
|
||||
|
||||
typedef enum R_PassKind
|
||||
{
|
||||
R_PassKind_UI,
|
||||
R_PassKind_Blur,
|
||||
R_PassKind_Geo3D,
|
||||
R_PassKind_COUNT,
|
||||
} R_PassKind;
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern String8 r_tex2d_format_display_string_table[9];
|
||||
extern U8 r_tex2d_format_bytes_per_pixel_table[9];
|
||||
extern String8 r_resource_kind_display_string_table[3];
|
||||
extern String8 r_tex2d_sample_kind_display_string_table[2];
|
||||
extern String8 r_pass_kind_display_string_table[3];
|
||||
extern U8 r_pass_kind_batch_table[3];
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
#endif // RENDER_META_H
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef RENDER_META_H
|
||||
#define RENDER_META_H
|
||||
|
||||
typedef enum R_Tex2DFormat
|
||||
{
|
||||
R_Tex2DFormat_R8,
|
||||
R_Tex2DFormat_RG8,
|
||||
R_Tex2DFormat_RGBA8,
|
||||
R_Tex2DFormat_BGRA8,
|
||||
R_Tex2DFormat_R16,
|
||||
R_Tex2DFormat_RGBA16,
|
||||
R_Tex2DFormat_R32,
|
||||
R_Tex2DFormat_RG32,
|
||||
R_Tex2DFormat_RGBA32,
|
||||
R_Tex2DFormat_COUNT,
|
||||
} R_Tex2DFormat;
|
||||
|
||||
typedef enum R_ResourceKind
|
||||
{
|
||||
R_ResourceKind_Static,
|
||||
R_ResourceKind_Dynamic,
|
||||
R_ResourceKind_Stream,
|
||||
R_ResourceKind_COUNT,
|
||||
} R_ResourceKind;
|
||||
|
||||
typedef enum R_Tex2DSampleKind
|
||||
{
|
||||
R_Tex2DSampleKind_Nearest,
|
||||
R_Tex2DSampleKind_Linear,
|
||||
R_Tex2DSampleKind_COUNT,
|
||||
} R_Tex2DSampleKind;
|
||||
|
||||
typedef enum R_GeoTopologyKind
|
||||
{
|
||||
R_GeoTopologyKind_Lines,
|
||||
R_GeoTopologyKind_LineStrip,
|
||||
R_GeoTopologyKind_Triangles,
|
||||
R_GeoTopologyKind_TriangleStrip,
|
||||
R_GeoTopologyKind_COUNT,
|
||||
} R_GeoTopologyKind;
|
||||
|
||||
typedef enum R_PassKind
|
||||
{
|
||||
R_PassKind_UI,
|
||||
R_PassKind_Blur,
|
||||
R_PassKind_Geo3D,
|
||||
R_PassKind_COUNT,
|
||||
} R_PassKind;
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern String8 r_tex2d_format_display_string_table[9];
|
||||
extern U8 r_tex2d_format_bytes_per_pixel_table[9];
|
||||
extern String8 r_resource_kind_display_string_table[3];
|
||||
extern String8 r_tex2d_sample_kind_display_string_table[2];
|
||||
extern String8 r_pass_kind_display_string_table[3];
|
||||
extern U8 r_pass_kind_batch_table[3];
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
#endif // RENDER_META_H
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
String8 r_ogl_shader_kind_name_table[2] =
|
||||
{
|
||||
str8_lit_comp("rect"),
|
||||
str8_lit_comp("blur"),
|
||||
};
|
||||
|
||||
String8 * r_ogl_shader_kind_vshad_src_table[2] =
|
||||
{
|
||||
&r_ogl_rect_vshad_src,
|
||||
&r_ogl_blur_vshad_src,
|
||||
};
|
||||
|
||||
String8 * r_ogl_shader_kind_pshad_src_table[2] =
|
||||
{
|
||||
&r_ogl_rect_pshad_src,
|
||||
&r_ogl_blur_pshad_src,
|
||||
};
|
||||
|
||||
R_OGL_AttributeArray r_ogl_shader_kind_input_attributes_table[2] =
|
||||
{
|
||||
{ r_ogl_rect_input_attributes, ArrayCount(r_ogl_rect_input_attributes) },
|
||||
{ 0, },
|
||||
};
|
||||
|
||||
R_OGL_AttributeArray r_ogl_shader_kind_output_attributes_table[2] =
|
||||
{
|
||||
{ r_ogl_single_color_output_attributes, ArrayCount(r_ogl_single_color_output_attributes) },
|
||||
{ r_ogl_single_color_output_attributes, ArrayCount(r_ogl_single_color_output_attributes) },
|
||||
};
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
String8 r_ogl_shader_kind_name_table[2] =
|
||||
{
|
||||
str8_lit_comp("rect"),
|
||||
str8_lit_comp("blur"),
|
||||
};
|
||||
|
||||
String8 * r_ogl_shader_kind_vshad_src_table[2] =
|
||||
{
|
||||
&r_ogl_rect_vshad_src,
|
||||
&r_ogl_blur_vshad_src,
|
||||
};
|
||||
|
||||
String8 * r_ogl_shader_kind_pshad_src_table[2] =
|
||||
{
|
||||
&r_ogl_rect_pshad_src,
|
||||
&r_ogl_blur_pshad_src,
|
||||
};
|
||||
|
||||
R_OGL_AttributeArray r_ogl_shader_kind_input_attributes_table[2] =
|
||||
{
|
||||
{ r_ogl_rect_input_attributes, ArrayCount(r_ogl_rect_input_attributes) },
|
||||
{ 0, },
|
||||
};
|
||||
|
||||
R_OGL_AttributeArray r_ogl_shader_kind_output_attributes_table[2] =
|
||||
{
|
||||
{ r_ogl_single_color_output_attributes, ArrayCount(r_ogl_single_color_output_attributes) },
|
||||
{ r_ogl_single_color_output_attributes, ArrayCount(r_ogl_single_color_output_attributes) },
|
||||
};
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
|
||||
@@ -1,280 +1,281 @@
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef RENDER_OPENGL_META_H
|
||||
#define RENDER_OPENGL_META_H
|
||||
|
||||
typedef enum R_OGL_ShaderKind
|
||||
{
|
||||
R_OGL_ShaderKind_Rect,
|
||||
R_OGL_ShaderKind_Blur,
|
||||
R_OGL_ShaderKind_COUNT,
|
||||
} R_OGL_ShaderKind;
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern String8 r_ogl_shader_kind_name_table[2];
|
||||
extern String8 * r_ogl_shader_kind_vshad_src_table[2];
|
||||
extern String8 * r_ogl_shader_kind_pshad_src_table[2];
|
||||
extern R_OGL_AttributeArray r_ogl_shader_kind_input_attributes_table[2];
|
||||
extern R_OGL_AttributeArray r_ogl_shader_kind_output_attributes_table[2];
|
||||
read_only global String8 r_ogl_rect_vshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"in vec4 c2v_dst_rect;\n"
|
||||
"in vec4 c2v_src_rect;\n"
|
||||
"in vec4 c2v_colors_0;\n"
|
||||
"in vec4 c2v_colors_1;\n"
|
||||
"in vec4 c2v_colors_2;\n"
|
||||
"in vec4 c2v_colors_3;\n"
|
||||
"in vec4 c2v_corner_radii;\n"
|
||||
"in vec4 c2v_style; // x: border_thickness_px, y: softness_px, z: omit_texture, w: shear\n"
|
||||
"\n"
|
||||
"out vec2 v2p_sdf_sample_pos;\n"
|
||||
"out vec2 v2p_texcoord_pct;\n"
|
||||
"out vec2 v2p_rect_half_size_px;\n"
|
||||
"out vec4 v2p_tint;\n"
|
||||
"out float v2p_corner_radius;\n"
|
||||
"out float v2p_border_thickness;\n"
|
||||
"out float v2p_softness;\n"
|
||||
"out float v2p_omit_texture;\n"
|
||||
"\n"
|
||||
"uniform mat3 u_xform;\n"
|
||||
"uniform sampler2D u_tex_color;\n"
|
||||
"uniform vec2 u_viewport_size_px;\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" // rjf: constants\n"
|
||||
" vec2 vertices[] = vec2[](vec2(-1, -1), vec2(-1, +1), vec2(+1, -1), vec2(+1, +1));\n"
|
||||
" \n"
|
||||
" // rjf: unpack shears\n"
|
||||
" float shears[] = float[](0, 0, c2v_style.w, c2v_style.w);\n"
|
||||
" \n"
|
||||
" // rjf: find dst position\n"
|
||||
" vec2 dst_half_size = (c2v_dst_rect.zw - c2v_dst_rect.xy) / 2;\n"
|
||||
" vec2 dst_center = (c2v_dst_rect.zw + c2v_dst_rect.xy) / 2;\n"
|
||||
" vec2 dst_position = vertices[gl_VertexID] * dst_half_size + dst_center;\n"
|
||||
" dst_position.y += shears[gl_VertexID];\n"
|
||||
" dst_position = (u_xform * vec3(dst_position.x, dst_position.y, 1)).xy;\n"
|
||||
" \n"
|
||||
" // rjf: find src position\n"
|
||||
" vec2 src_half_size = (c2v_src_rect.zw - c2v_src_rect.xy) / 2;\n"
|
||||
" vec2 src_center = (c2v_src_rect.zw + c2v_src_rect.xy) / 2;\n"
|
||||
" vec2 src_position = vertices[gl_VertexID] * src_half_size + src_center;\n"
|
||||
" \n"
|
||||
" // rjf: find color\n"
|
||||
" vec4 colors[] = vec4[](c2v_colors_0, c2v_colors_1, c2v_colors_2, c2v_colors_3);\n"
|
||||
" vec4 color = colors[gl_VertexID];\n"
|
||||
" \n"
|
||||
" // rjf: find corner radius\n"
|
||||
" float corner_radii[] = float[](c2v_corner_radii.x, c2v_corner_radii.y, c2v_corner_radii.z, c2v_corner_radii.w);\n"
|
||||
" float corner_radius = corner_radii[gl_VertexID];\n"
|
||||
" \n"
|
||||
" // rjf: fill outputs\n"
|
||||
" vec2 dst_verts_pct = vec2(((gl_VertexID >> 1) != 1) ? 1.f : 0.f,\n"
|
||||
" ((gl_VertexID & 1) != 0) ? 0.f : 1.f);\n"
|
||||
" ivec2 u_tex_color_size_i = textureSize(u_tex_color, 0);\n"
|
||||
" vec2 u_tex_color_size = vec2(float(u_tex_color_size_i.x), float(u_tex_color_size_i.y));\n"
|
||||
" {\n"
|
||||
" gl_Position = vec4(2 * dst_position.x / u_viewport_size_px.x - 1,\n"
|
||||
" 2 * (1 - dst_position.y / u_viewport_size_px.y) - 1,\n"
|
||||
" 0.0, 1.0);\n"
|
||||
" v2p_sdf_sample_pos = (2.f * dst_verts_pct - 1.f) * dst_half_size;\n"
|
||||
" v2p_texcoord_pct = src_position / u_tex_color_size;\n"
|
||||
" v2p_rect_half_size_px = dst_half_size;\n"
|
||||
" v2p_tint = color;\n"
|
||||
" v2p_corner_radius = corner_radius;\n"
|
||||
" v2p_border_thickness = c2v_style.x;\n"
|
||||
" v2p_softness = c2v_style.y;\n"
|
||||
" v2p_omit_texture = c2v_style.z;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_ogl_rect_pshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"in vec2 v2p_sdf_sample_pos;\n"
|
||||
"in vec2 v2p_texcoord_pct;\n"
|
||||
"in vec2 v2p_rect_half_size_px;\n"
|
||||
"in vec4 v2p_tint;\n"
|
||||
"in float v2p_corner_radius;\n"
|
||||
"in float v2p_border_thickness;\n"
|
||||
"in float v2p_softness;\n"
|
||||
"in float v2p_omit_texture;\n"
|
||||
"\n"
|
||||
"out vec4 final_color;\n"
|
||||
"\n"
|
||||
"uniform float u_opacity;\n"
|
||||
"uniform sampler2D u_tex_color;\n"
|
||||
"uniform mat4 u_texture_sample_channel_map;\n"
|
||||
"\n"
|
||||
"float rect_sdf(vec2 sample_pos, vec2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float linear_from_srgb_f32(float x)\n"
|
||||
"{\n"
|
||||
" return x < 0.0404482362771082 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 linear_from_srgba(vec4 v)\n"
|
||||
"{\n"
|
||||
" vec4 result = vec4(linear_from_srgb_f32(v.x),\n"
|
||||
" linear_from_srgb_f32(v.y),\n"
|
||||
" linear_from_srgb_f32(v.z),\n"
|
||||
" v.w);\n"
|
||||
" return result;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" // rjf: sample texture\n"
|
||||
" vec4 albedo_sample = vec4(1, 1, 1, 1);\n"
|
||||
" if(v2p_omit_texture < 1)\n"
|
||||
" {\n"
|
||||
" albedo_sample = u_texture_sample_channel_map * texture(u_tex_color, v2p_texcoord_pct);\n"
|
||||
" albedo_sample = linear_from_srgba(albedo_sample);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for borders\n"
|
||||
" float border_sdf_t = 1;\n"
|
||||
" if(v2p_border_thickness > 0)\n"
|
||||
" {\n"
|
||||
" float border_sdf_s = rect_sdf(v2p_sdf_sample_pos,\n"
|
||||
" v2p_rect_half_size_px - vec2(v2p_softness*2.f, v2p_softness*2.f) - v2p_border_thickness,\n"
|
||||
" max(v2p_corner_radius-v2p_border_thickness, 0));\n"
|
||||
" border_sdf_t = smoothstep(0, 2*v2p_softness, border_sdf_s);\n"
|
||||
" }\n"
|
||||
" if(border_sdf_t < 0.001f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_t = 1;\n"
|
||||
" if(v2p_corner_radius > 0 || v2p_softness > 0.75f)\n"
|
||||
" {\n"
|
||||
" float corner_sdf_s = rect_sdf(v2p_sdf_sample_pos,\n"
|
||||
" v2p_rect_half_size_px - vec2(v2p_softness*2.f, v2p_softness*2.f),\n"
|
||||
" v2p_corner_radius);\n"
|
||||
" corner_sdf_t = 1-smoothstep(0, 2*v2p_softness, corner_sdf_s);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: form+return final color\n"
|
||||
" final_color = albedo_sample;\n"
|
||||
" final_color *= v2p_tint;\n"
|
||||
" final_color.a *= u_opacity;\n"
|
||||
" final_color.a *= corner_sdf_t;\n"
|
||||
" final_color.a *= border_sdf_t;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_ogl_blur_vshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"uniform vec4 rect;\n"
|
||||
"uniform vec4 corner_radii_px;\n"
|
||||
"uniform vec2 viewport_size;\n"
|
||||
"\n"
|
||||
"out vec2 texcoord;\n"
|
||||
"out vec2 sdf_sample_pos;\n"
|
||||
"out vec2 rect_half_size;\n"
|
||||
"out float corner_radius;\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec2 vertex_positions_scrn[] = vec2[](rect.xw,\n"
|
||||
" rect.xy,\n"
|
||||
" rect.zw,\n"
|
||||
" rect.zy);\n"
|
||||
" float corner_radii[] = float[](corner_radii_px.y,\n"
|
||||
" corner_radii_px.x,\n"
|
||||
" corner_radii_px.w,\n"
|
||||
" corner_radii_px.z);\n"
|
||||
" vec2 cornercoords_pct = vec2((gl_VertexID >> 1) != 0 ? 1.f : 0.f,\n"
|
||||
" (gl_VertexID & 1) != 0 ? 0.f : 1.f);\n"
|
||||
" \n"
|
||||
" vec2 vertex_position_pct = vertex_positions_scrn[gl_VertexID] / viewport_size;\n"
|
||||
" vec2 vertex_position_scr = 2.f * vertex_position_pct - 1.f;\n"
|
||||
" \n"
|
||||
" vec2 rect_half_size_local = vec2((rect.z-rect.x)/2, (rect.w-rect.y)/2);\n"
|
||||
" \n"
|
||||
" gl_Position = vec4(vertex_position_scr.x, -vertex_position_scr.y, 0.f, 1.f);\n"
|
||||
" texcoord = vec2(vertex_position_pct.x, 1-vertex_position_pct.y);\n"
|
||||
" sdf_sample_pos = (2.f * cornercoords_pct - 1.f) * rect_half_size_local;\n"
|
||||
" rect_half_size = rect_half_size_local - 2.f;\n"
|
||||
" corner_radius = corner_radii[gl_VertexID];\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_ogl_blur_pshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"uniform sampler2D tex;\n"
|
||||
"uniform vec4 kernel[32];\n"
|
||||
"uniform int blur_count;\n"
|
||||
"uniform vec2 direction;\n"
|
||||
"\n"
|
||||
"in vec2 texcoord;\n"
|
||||
"in vec2 sdf_sample_pos;\n"
|
||||
"in vec2 rect_half_size;\n"
|
||||
"in float corner_radius;\n"
|
||||
"\n"
|
||||
"out vec4 final_color;\n"
|
||||
"\n"
|
||||
"float rect_sdf(vec2 sample_pos, vec2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" // rjf: blend weighted texture samples into color\n"
|
||||
" vec3 color = kernel[0].x * texture(tex, texcoord).rgb;\n"
|
||||
" for(int i = 1; i < blur_count; i += 1)\n"
|
||||
" {\n"
|
||||
" float weight = kernel[i].x;\n"
|
||||
" float offset = kernel[i].y;\n"
|
||||
" color += weight * texture(tex, texcoord - offset * direction).rgb;\n"
|
||||
" color += weight * texture(tex, texcoord + offset * direction).rgb;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_s = rect_sdf(sdf_sample_pos, rect_half_size, corner_radius);\n"
|
||||
" float corner_sdf_t = smoothstep(0, 2, corner_sdf_s);\n"
|
||||
" \n"
|
||||
" // rjf: weight output color by sdf\n"
|
||||
" // this is doing alpha testing, leave blurring only where mostly opaque pixels are\n"
|
||||
" if(corner_sdf_t < 0.9f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" final_color = vec4(color, 1.f);\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
#endif // RENDER_OPENGL_META_H
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef RENDER_OPENGL_META_H
|
||||
#define RENDER_OPENGL_META_H
|
||||
|
||||
typedef enum R_OGL_ShaderKind
|
||||
{
|
||||
R_OGL_ShaderKind_Rect,
|
||||
R_OGL_ShaderKind_Blur,
|
||||
R_OGL_ShaderKind_COUNT,
|
||||
} R_OGL_ShaderKind;
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern String8 r_ogl_shader_kind_name_table[2];
|
||||
extern String8 * r_ogl_shader_kind_vshad_src_table[2];
|
||||
extern String8 * r_ogl_shader_kind_pshad_src_table[2];
|
||||
extern R_OGL_AttributeArray r_ogl_shader_kind_input_attributes_table[2];
|
||||
extern R_OGL_AttributeArray r_ogl_shader_kind_output_attributes_table[2];
|
||||
read_only global String8 r_ogl_rect_vshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"in vec4 c2v_dst_rect;\n"
|
||||
"in vec4 c2v_src_rect;\n"
|
||||
"in vec4 c2v_colors_0;\n"
|
||||
"in vec4 c2v_colors_1;\n"
|
||||
"in vec4 c2v_colors_2;\n"
|
||||
"in vec4 c2v_colors_3;\n"
|
||||
"in vec4 c2v_corner_radii;\n"
|
||||
"in vec4 c2v_style; // x: border_thickness_px, y: softness_px, z: omit_texture, w: shear\n"
|
||||
"\n"
|
||||
"out vec2 v2p_sdf_sample_pos;\n"
|
||||
"out vec2 v2p_texcoord_pct;\n"
|
||||
"out vec2 v2p_rect_half_size_px;\n"
|
||||
"out vec4 v2p_tint;\n"
|
||||
"out float v2p_corner_radius;\n"
|
||||
"out float v2p_border_thickness;\n"
|
||||
"out float v2p_softness;\n"
|
||||
"out float v2p_omit_texture;\n"
|
||||
"\n"
|
||||
"uniform mat3 u_xform;\n"
|
||||
"uniform sampler2D u_tex_color;\n"
|
||||
"uniform vec2 u_viewport_size_px;\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" // rjf: constants\n"
|
||||
" vec2 vertices[] = vec2[](vec2(-1, -1), vec2(-1, +1), vec2(+1, -1), vec2(+1, +1));\n"
|
||||
" \n"
|
||||
" // rjf: unpack shears\n"
|
||||
" float shears[] = float[](0, 0, c2v_style.w, c2v_style.w);\n"
|
||||
" \n"
|
||||
" // rjf: find dst position\n"
|
||||
" vec2 dst_half_size = (c2v_dst_rect.zw - c2v_dst_rect.xy) / 2;\n"
|
||||
" vec2 dst_center = (c2v_dst_rect.zw + c2v_dst_rect.xy) / 2;\n"
|
||||
" vec2 dst_position = vertices[gl_VertexID] * dst_half_size + dst_center;\n"
|
||||
" dst_position.y += shears[gl_VertexID];\n"
|
||||
" dst_position = (u_xform * vec3(dst_position.x, dst_position.y, 1)).xy;\n"
|
||||
" \n"
|
||||
" // rjf: find src position\n"
|
||||
" vec2 src_half_size = (c2v_src_rect.zw - c2v_src_rect.xy) / 2;\n"
|
||||
" vec2 src_center = (c2v_src_rect.zw + c2v_src_rect.xy) / 2;\n"
|
||||
" vec2 src_position = vertices[gl_VertexID] * src_half_size + src_center;\n"
|
||||
" \n"
|
||||
" // rjf: find color\n"
|
||||
" vec4 colors[] = vec4[](c2v_colors_0, c2v_colors_1, c2v_colors_2, c2v_colors_3);\n"
|
||||
" vec4 color = colors[gl_VertexID];\n"
|
||||
" \n"
|
||||
" // rjf: find corner radius\n"
|
||||
" float corner_radii[] = float[](c2v_corner_radii.x, c2v_corner_radii.y, c2v_corner_radii.z, c2v_corner_radii.w);\n"
|
||||
" float corner_radius = corner_radii[gl_VertexID];\n"
|
||||
" \n"
|
||||
" // rjf: fill outputs\n"
|
||||
" vec2 dst_verts_pct = vec2(((gl_VertexID >> 1) != 1) ? 1.f : 0.f,\n"
|
||||
" ((gl_VertexID & 1) != 0) ? 0.f : 1.f);\n"
|
||||
" ivec2 u_tex_color_size_i = textureSize(u_tex_color, 0);\n"
|
||||
" vec2 u_tex_color_size = vec2(float(u_tex_color_size_i.x), float(u_tex_color_size_i.y));\n"
|
||||
" {\n"
|
||||
" gl_Position = vec4(2 * dst_position.x / u_viewport_size_px.x - 1,\n"
|
||||
" 2 * (1 - dst_position.y / u_viewport_size_px.y) - 1,\n"
|
||||
" 0.0, 1.0);\n"
|
||||
" v2p_sdf_sample_pos = (2.f * dst_verts_pct - 1.f) * dst_half_size;\n"
|
||||
" v2p_texcoord_pct = src_position / u_tex_color_size;\n"
|
||||
" v2p_rect_half_size_px = dst_half_size;\n"
|
||||
" v2p_tint = color;\n"
|
||||
" v2p_corner_radius = corner_radius;\n"
|
||||
" v2p_border_thickness = c2v_style.x;\n"
|
||||
" v2p_softness = c2v_style.y;\n"
|
||||
" v2p_omit_texture = c2v_style.z;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_ogl_rect_pshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"in vec2 v2p_sdf_sample_pos;\n"
|
||||
"in vec2 v2p_texcoord_pct;\n"
|
||||
"in vec2 v2p_rect_half_size_px;\n"
|
||||
"in vec4 v2p_tint;\n"
|
||||
"in float v2p_corner_radius;\n"
|
||||
"in float v2p_border_thickness;\n"
|
||||
"in float v2p_softness;\n"
|
||||
"in float v2p_omit_texture;\n"
|
||||
"\n"
|
||||
"out vec4 final_color;\n"
|
||||
"\n"
|
||||
"uniform float u_opacity;\n"
|
||||
"uniform sampler2D u_tex_color;\n"
|
||||
"uniform mat4 u_texture_sample_channel_map;\n"
|
||||
"\n"
|
||||
"float rect_sdf(vec2 sample_pos, vec2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float linear_from_srgb_f32(float x)\n"
|
||||
"{\n"
|
||||
" return x < 0.0404482362771082 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 linear_from_srgba(vec4 v)\n"
|
||||
"{\n"
|
||||
" vec4 result = vec4(linear_from_srgb_f32(v.x),\n"
|
||||
" linear_from_srgb_f32(v.y),\n"
|
||||
" linear_from_srgb_f32(v.z),\n"
|
||||
" v.w);\n"
|
||||
" return result;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" // rjf: sample texture\n"
|
||||
" vec4 albedo_sample = vec4(1, 1, 1, 1);\n"
|
||||
" if(v2p_omit_texture < 1)\n"
|
||||
" {\n"
|
||||
" albedo_sample = u_texture_sample_channel_map * texture(u_tex_color, v2p_texcoord_pct);\n"
|
||||
" albedo_sample = linear_from_srgba(albedo_sample);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for borders\n"
|
||||
" float border_sdf_t = 1;\n"
|
||||
" if(v2p_border_thickness > 0)\n"
|
||||
" {\n"
|
||||
" float border_sdf_s = rect_sdf(v2p_sdf_sample_pos,\n"
|
||||
" v2p_rect_half_size_px - vec2(v2p_softness*2.f, v2p_softness*2.f) - v2p_border_thickness,\n"
|
||||
" max(v2p_corner_radius-v2p_border_thickness, 0));\n"
|
||||
" border_sdf_t = smoothstep(0, 2*v2p_softness, border_sdf_s);\n"
|
||||
" }\n"
|
||||
" if(border_sdf_t < 0.001f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_t = 1;\n"
|
||||
" if(v2p_corner_radius > 0 || v2p_softness > 0.75f)\n"
|
||||
" {\n"
|
||||
" float corner_sdf_s = rect_sdf(v2p_sdf_sample_pos,\n"
|
||||
" v2p_rect_half_size_px - vec2(v2p_softness*2.f, v2p_softness*2.f),\n"
|
||||
" v2p_corner_radius);\n"
|
||||
" corner_sdf_t = 1-smoothstep(0, 2*v2p_softness, corner_sdf_s);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: form+return final color\n"
|
||||
" final_color = albedo_sample;\n"
|
||||
" final_color *= v2p_tint;\n"
|
||||
" final_color.a *= u_opacity;\n"
|
||||
" final_color.a *= corner_sdf_t;\n"
|
||||
" final_color.a *= border_sdf_t;\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_ogl_blur_vshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"uniform vec4 rect;\n"
|
||||
"uniform vec4 corner_radii_px;\n"
|
||||
"uniform vec2 viewport_size;\n"
|
||||
"uniform uint blur_count;\n"
|
||||
"\n"
|
||||
"out vec2 texcoord;\n"
|
||||
"out vec2 sdf_sample_pos;\n"
|
||||
"out vec2 rect_half_size;\n"
|
||||
"out float corner_radius;\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec2 vertex_positions_scrn[] = vec2[](rect.xw,\n"
|
||||
" rect.xy,\n"
|
||||
" rect.zw,\n"
|
||||
" rect.zy);\n"
|
||||
" float corner_radii[] = float[](corner_radii_px.y,\n"
|
||||
" corner_radii_px.x,\n"
|
||||
" corner_radii_px.w,\n"
|
||||
" corner_radii_px.z);\n"
|
||||
" vec2 cornercoords_pct = vec2((gl_VertexID >> 1) != 0 ? 1.f : 0.f,\n"
|
||||
" (gl_VertexID & 1) != 0 ? 0.f : 1.f);\n"
|
||||
" \n"
|
||||
" vec2 vertex_position_pct = vertex_positions_scrn[gl_VertexID] / viewport_size;\n"
|
||||
" vec2 vertex_position_scr = 2.f * vertex_position_pct - 1.f;\n"
|
||||
" \n"
|
||||
" vec2 rect_half_size_local = vec2((rect.z-rect.x)/2, (rect.w-rect.y)/2);\n"
|
||||
" \n"
|
||||
" gl_Position = vec4(vertex_position_scr.x, -vertex_position_scr.y, 0.f, 1.f);\n"
|
||||
" texcoord = vec2(vertex_position_pct.x, 1-vertex_position_pct.y);\n"
|
||||
" sdf_sample_pos = (2.f * cornercoords_pct - 1.f) * rect_half_size_local;\n"
|
||||
" rect_half_size = rect_half_size_local - 2.f;\n"
|
||||
" corner_radius = corner_radii[gl_VertexID];\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
read_only global String8 r_ogl_blur_pshad_src =
|
||||
str8_lit_comp(
|
||||
""
|
||||
"\n"
|
||||
"#version 330 core\n"
|
||||
"\n"
|
||||
"uniform sampler2D tex;\n"
|
||||
"uniform vec4 kernel[32];\n"
|
||||
"uniform int blur_count;\n"
|
||||
"uniform vec2 direction;\n"
|
||||
"\n"
|
||||
"in vec2 texcoord;\n"
|
||||
"in vec2 sdf_sample_pos;\n"
|
||||
"in vec2 rect_half_size;\n"
|
||||
"in float corner_radius;\n"
|
||||
"\n"
|
||||
"out vec4 final_color;\n"
|
||||
"\n"
|
||||
"float rect_sdf(vec2 sample_pos, vec2 rect_half_size, float r)\n"
|
||||
"{\n"
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" // rjf: blend weighted texture samples into color\n"
|
||||
" vec3 color = kernel[0].x * texture(tex, texcoord).rgb;\n"
|
||||
" for(int i = 1; i < blur_count; i += 1)\n"
|
||||
" {\n"
|
||||
" float weight = kernel[i].x;\n"
|
||||
" float offset = kernel[i].y;\n"
|
||||
" color += weight * texture(tex, texcoord - offset * direction).rgb;\n"
|
||||
" color += weight * texture(tex, texcoord + offset * direction).rgb;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_s = rect_sdf(sdf_sample_pos, rect_half_size, corner_radius);\n"
|
||||
" float corner_sdf_t = smoothstep(0, 2, corner_sdf_s);\n"
|
||||
" \n"
|
||||
" // rjf: weight output color by sdf\n"
|
||||
" // this is doing alpha testing, leave blurring only where mostly opaque pixels are\n"
|
||||
" if(corner_sdf_t < 0.9f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" final_color = vec4(color, 1.f);\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
#endif // RENDER_OPENGL_META_H
|
||||
|
||||
Reference in New Issue
Block a user