diff --git a/crates/renderide/shaders/materials/billboardunlit.wgsl b/crates/renderide/shaders/materials/billboardunlit.wgsl index b4fbaac3d..de1704f1d 100644 --- a/crates/renderide/shaders/materials/billboardunlit.wgsl +++ b/crates/renderide/shaders/materials/billboardunlit.wgsl @@ -12,7 +12,6 @@ //#render_queue AlphaTest+200 //#texture_default _Tex white //#texture_default _OffsetTex black -//#texture_default _MaskTex white //#mat_default _Color vec4 1.0 1.0 1.0 1.0 //#mat_default _OffsetMagnitude vec4 0.1 0.1 0.0 0.0 //#mat_default _PointSize vec4 0.1 0.1 0.0 0.0 @@ -20,8 +19,8 @@ //#mat_default _Cutoff float 0.5 //#mat_default _Tex_LodBias float 0.0 //#mat_default _OffsetTex_LodBias float 0.0 -//#mat_default _MaskTex_LodBias float 0.0 +#import renderide::billboard::vertex as bv #import renderide::core::texture_sampling as ts #import renderide::core::uv as uvu #import renderide::core::math as rmath @@ -40,7 +39,6 @@ struct BillboardUnlitMaterial { _Color: vec4, _Tex_ST: vec4, _RightEye_ST: vec4, - _MaskTex_ST: vec4, _OffsetTex_ST: vec4, _OffsetMagnitude: vec4, _PointSize: vec4, @@ -49,7 +47,6 @@ struct BillboardUnlitMaterial { _RenderideVariantBits: u32, _Tex_LodBias: f32, _OffsetTex_LodBias: f32, - _MaskTex_LodBias: f32, _pad0: f32, } @@ -69,18 +66,12 @@ const BILLBOARDUNLIT_KW_VERTEX_HDRSRGBALPHA_COLOR: u32 = 1u << 12u; const BILLBOARDUNLIT_KW_VERTEX_LINEAR_COLOR: u32 = 1u << 13u; const BILLBOARDUNLIT_KW_VERTEX_SRGB_COLOR: u32 = 1u << 14u; const BILLBOARDUNLIT_KW_VERTEXCOLORS: u32 = 1u << 15u; -const BILLBOARDUNLIT_KW_RENDER_BUFFER: u32 = 1u << 16u; -const BILLBOARDUNLIT_KW_SIMPLE_LIT: u32 = 1u << 17u; -const BILLBOARDUNLIT_KW_UNLIT_MASK_TEXTURE_CLIP: u32 = 1u << 18u; -const BILLBOARDUNLIT_KW_UNLIT_MASK_TEXTURE_MUL: u32 = 1u << 19u; @group(1) @binding(0) var mat: BillboardUnlitMaterial; @group(1) @binding(1) var _Tex: texture_2d; @group(1) @binding(2) var _Tex_sampler: sampler; @group(1) @binding(3) var _OffsetTex: texture_2d; @group(1) @binding(4) var _OffsetTex_sampler: sampler; -@group(1) @binding(5) var _MaskTex: texture_2d; -@group(1) @binding(6) var _MaskTex_sampler: sampler; fn bb_kw(mask: u32) -> bool { return vb::enabled(mat._RenderideVariantBits, mask); @@ -94,14 +85,6 @@ fn kw_COLOR() -> bool { return bb_kw(BILLBOARDUNLIT_KW_COLOR); } -fn kw_UNLIT_MASK_TEXTURE_CLIP() -> bool { - return bb_kw(BILLBOARDUNLIT_KW_UNLIT_MASK_TEXTURE_CLIP); -} - -fn kw_UNLIT_MASK_TEXTURE_MUL() -> bool { - return bb_kw(BILLBOARDUNLIT_KW_UNLIT_MASK_TEXTURE_MUL); -} - fn kw_MUL_ALPHA_INTENSITY() -> bool { return bb_kw(BILLBOARDUNLIT_KW_MUL_ALPHA_INTENSITY); } @@ -122,10 +105,6 @@ fn kw_POINT_SIZE() -> bool { return bb_kw(BILLBOARDUNLIT_KW_POINT_SIZE); } -fn kw_RENDER_BUFFER() -> bool { - return bb_kw(BILLBOARDUNLIT_KW_RENDER_BUFFER); -} - fn kw_POLARUV() -> bool { return bb_kw(BILLBOARDUNLIT_KW_POLARUV); } @@ -154,174 +133,12 @@ fn kw_VERTEXCOLORS() -> bool { return bb_kw(BILLBOARDUNLIT_KW_VERTEXCOLORS); } -fn kw_SIMPLE_LIT() -> bool { - return bb_kw(BILLBOARDUNLIT_KW_SIMPLE_LIT); -} - struct VertexOutput { @builtin(position) clip_pos: vec4, @location(0) uv: vec2, @location(1) color: vec4, @location(2) @interpolate(flat) view_layer: u32, @location(3) fog_coord: f32, - @location(4) world_p: vec3, - @location(5) n: vec3, -} - -struct RenderBufferBillboardBasis { - right: vec3, - up: vec3, -} - -fn billboard_size(pointdata: vec3, model: mat4x4) -> vec2 { - if (kw_RENDER_BUFFER()) { - return max(abs(pointdata.xy), vec2(1e-6, 1e-6)) * mb::model_uniform_scale(model); - } - return mb::billboard_size(pointdata, mat._PointSize.xy, model, kw_POINT_SIZE()); -} - -fn rotate_render_buffer_axes(angle: f32, right: vec3, up: vec3) -> RenderBufferBillboardBasis { - let c = cos(angle); - let s = sin(angle); - return RenderBufferBillboardBasis(right * c - up * s, right * s + up * c); -} - -fn view_plane_basis(view_layer: u32, roll: f32, allow_roll: bool) -> RenderBufferBillboardBasis { - let view_up = rmath::safe_normalize(rg::view_to_world_y_coeffs_for_view(view_layer).xyz, vec3(0.0, 1.0, 0.0)); - let to_camera = rg::orthographic_view_dir_for_view(view_layer); - var right = rmath::safe_normalize(cross(view_up, to_camera), vec3(1.0, 0.0, 0.0)); - var up = rmath::safe_normalize(cross(to_camera, right), view_up); - if (allow_roll && abs(roll) > 1e-4) { - let rotated = rotate_render_buffer_axes(roll, right, up); - right = rotated.right; - up = rotated.up; - } - return RenderBufferBillboardBasis(right, up); -} - -fn facing_basis(center_world: vec3, view_layer: u32, roll: f32, allow_roll: bool) -> RenderBufferBillboardBasis { - let view_up = rmath::safe_normalize(rg::view_to_world_y_coeffs_for_view(view_layer).xyz, vec3(0.0, 1.0, 0.0)); - let to_camera = rg::view_dir_for_world_pos(center_world, view_layer); - var right = rmath::safe_normalize(cross(view_up, to_camera), vec3(1.0, 0.0, 0.0)); - var up = rmath::safe_normalize(cross(to_camera, right), view_up); - if (allow_roll && abs(roll) > 1e-4) { - let rotated = rotate_render_buffer_axes(roll, right, up); - right = rotated.right; - up = rotated.up; - } - return RenderBufferBillboardBasis(right, up); -} - -fn direction_stretch_particle_basis( - d: dt::PerDrawUniforms, - center_world: vec3, - point_forward_upz: vec4, - view_layer: u32, -) -> RenderBufferBillboardBasis { - let to_camera = rg::view_dir_for_world_pos(center_world, view_layer); - let velocity_world = mv::model_vector(d, point_forward_upz.xyz); - let velocity_in_plane = velocity_world - to_camera * dot(velocity_world, to_camera); - let view_up = rg::view_to_world_y_coeffs_for_view(view_layer).xyz; - let view_up_in_plane = view_up - to_camera * dot(view_up, to_camera); - var up = rmath::safe_normalize( - velocity_in_plane, - rmath::safe_normalize(view_up_in_plane, vec3(0.0, 1.0, 0.0)), - ); - let right = rmath::safe_normalize(cross(up, to_camera), vec3(1.0, 0.0, 0.0)); - up = rmath::safe_normalize(cross(to_camera, right), up); - return RenderBufferBillboardBasis(right, up); -} - -fn local_particle_basis( - d: dt::PerDrawUniforms, - pointdata: vec3, - point_forward_upz: vec4, - point_up_xy: vec2, -) -> RenderBufferBillboardBasis { - let raw_forward = rmath::safe_normalize(point_forward_upz.xyz, vec3(0.0, 0.0, 1.0)); - let raw_up = rmath::safe_normalize(vec3(point_up_xy, point_forward_upz.w), vec3(0.0, 1.0, 0.0)); - let world_forward = rmath::safe_normalize(mv::model_vector(d, raw_forward), vec3(0.0, 0.0, 1.0)); - let world_up = rmath::safe_normalize(mv::model_vector(d, raw_up), vec3(0.0, 1.0, 0.0)); - var right = rmath::safe_normalize(cross(world_forward, world_up), vec3(1.0, 0.0, 0.0)); - var up = rmath::safe_normalize(cross(right, world_forward), world_up); - if (abs(pointdata.z) > 1e-4) { - let rotated = rotate_render_buffer_axes(pointdata.z, right, up); - right = rotated.right; - up = rotated.up; - } - return RenderBufferBillboardBasis(right, up); -} - -fn render_buffer_billboard_basis( - d: dt::PerDrawUniforms, - center_world: vec3, - pointdata: vec3, - point_forward_upz: vec4, - point_up_xy: vec2, - view_layer: u32, -) -> RenderBufferBillboardBasis { - let alignment = pd::particle_alignment(d); - if (alignment == 1u) { - return facing_basis(center_world, view_layer, pointdata.z, false); - } - if (alignment == 2u || alignment == 3u) { - return local_particle_basis(d, pointdata, point_forward_upz, point_up_xy); - } - if (alignment == 4u) { - return direction_stretch_particle_basis(d, center_world, point_forward_upz, view_layer); - } - return view_plane_basis(view_layer, pointdata.z, true); -} - -fn ndc_xy(clip: vec4) -> vec2 { - return clip.xy / max(abs(clip.w), 1e-6); -} - -fn screen_clamped_billboard_size( - d: dt::PerDrawUniforms, - center_world: vec3, - axes: RenderBufferBillboardBasis, - size: vec2, - vp: mat4x4, -) -> vec2 { - let min_size = pd::particle_min_screen_size(d); - let max_size = pd::particle_max_screen_size(d); - if (min_size <= 0.0 && max_size <= 0.0) { - return size; - } - let viewport = max(rg::viewport_size(), vec2(1.0, 1.0)); - let center_ndc = ndc_xy(vp * vec4(center_world, 1.0)); - let right_ndc = ndc_xy(vp * vec4(center_world + axes.right * size.x, 1.0)); - let up_ndc = ndc_xy(vp * vec4(center_world + axes.up * size.y, 1.0)); - let right_pixels = length((right_ndc - center_ndc) * viewport * 0.5); - let up_pixels = length((up_ndc - center_ndc) * viewport * 0.5); - let screen_fraction = max(right_pixels, up_pixels) / max(min(viewport.x, viewport.y), 1.0); - if (screen_fraction <= 1e-6) { - return size; - } - var scale = 1.0; - if (min_size > 0.0 && screen_fraction < min_size) { - scale = max(scale, min_size / screen_fraction); - } - if (max_size > 0.0 && screen_fraction * scale > max_size) { - scale = max_size / screen_fraction; - } - return max(size * scale, vec2(1e-6, 1e-6)); -} - -fn render_buffer_billboard_unit_corner(vertex_index: u32) -> vec2 { - let corner = vertex_index % 4u; - return vec2( - select(0.0, 1.0, (corner & 1u) != 0u), - select(0.0, 1.0, (corner & 2u) != 0u), - ); -} - -fn billboard_corner_for_vertex(pos: vec3, uv: vec2, vertex_index: u32) -> vec2 { - if (kw_RENDER_BUFFER()) { - return render_buffer_billboard_unit_corner(vertex_index) * 2.0 - vec2(1.0, 1.0); - } - return mb::billboard_corner(pos, uv); } @vertex @@ -332,48 +149,41 @@ fn vs_main( @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, - @location(1) pointdata_in: vec4, + @location(1) pointdata: vec4, @location(2) uv: vec2, @location(3) color: vec4, @location(4) point_forward_upz: vec4, @location(5) point_up_xy: vec2, ) -> VertexOutput { let d = pd::get_draw(instance_index); - let pointdata = pointdata_in.xyz; #ifdef MULTIVIEW let layer = view_idx; #else let layer = 0u; #endif -#ifdef MULTIVIEW - let vp = mv::select_view_proj(d, view_idx); -#else - let vp = mv::select_view_proj(d, 0u); -#endif - let center_world = mv::world_position(d, pos).xyz; - let use_rotation = kw_POINT_ROTATION() && abs(pointdata.z) > 1e-4; - let fallback_axes = mb::billboard_axes(center_world, pointdata, layer, use_rotation); - var axes = RenderBufferBillboardBasis(fallback_axes.right, fallback_axes.up); - if (kw_RENDER_BUFFER()) { - axes = render_buffer_billboard_basis(d, center_world, pointdata, point_forward_upz, point_up_xy, layer); - } - let corner = billboard_corner_for_vertex(pos.xyz, uv, vertex_index); - let unclamped_size = billboard_size(pointdata, d.model); - var size = unclamped_size; - if (kw_RENDER_BUFFER()) { - size = screen_clamped_billboard_size(d, center_world, axes, unclamped_size, vp); - } - let world_p = center_world + axes.right * (corner.x * size.x) + axes.up * (corner.y * size.y); - + let vp = mv::select_view_proj(d, layer); var out: VertexOutput; + var world_p: vec3; + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, layer, pos, vertex_index, pointdata, point_forward_upz, point_up_xy, + ); + world_p = render_billboard_vertex.world_pos.xyz; + } else { + let center_world = mv::world_position(d, pos).xyz; + let use_rotation = kw_POINT_ROTATION() && abs(pointdata.z) > 1e-4; + let fallback_axes = mb::billboard_axes(center_world, pointdata.xyz, layer, use_rotation); + let axes = bv::RenderBufferBillboardBasis(fallback_axes.right, fallback_axes.up); + let corner = mb::billboard_corner(pos.xyz, uv); + let size = mb::billboard_size(pointdata.xyz, mat._PointSize.xy, d.model, kw_POINT_SIZE()); + world_p = center_world + axes.right * (corner.x * size.x) + axes.up * (corner.y * size.y); + } out.clip_pos = vp * vec4(world_p, 1.0); out.uv = uv; out.color = color; out.view_layer = layer; out.fog_coord = rfog::coord_from_world_pos(world_p, layer); - out.world_p = world_p; - out.n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); return out; } @@ -460,22 +270,7 @@ fn fs_main( col = vec4(1.0); } - let mask_clip = kw_UNLIT_MASK_TEXTURE_CLIP(); - let mask_mul = kw_UNLIT_MASK_TEXTURE_MUL(); - if (mask_mul || mask_clip) { - let uv_mask = uvu::apply_st(in.uv, mat._MaskTex_ST); - let mask_sample = ts::sample_tex_2d(_MaskTex, _MaskTex_sampler, uv_mask, mat._MaskTex_LodBias); - let mask_lum = ma::mask_luminance(mask_sample); - - if (mask_mul) { - col.a = col.a * mask_lum; - } - if (mask_clip && mask_lum <= mat._Cutoff) { - discard; - } - } - - if (kw_ALPHATEST() && !mask_clip && col.a < mat._Cutoff) { + if (kw_ALPHATEST() && col.a < mat._Cutoff) { discard; } @@ -491,12 +286,5 @@ fn fs_main( col = vec4(col.rgb, ma::alpha_intensity(col.a, col.rgb)); } - if (kw_SIMPLE_LIT()) { - let n = two_sided_geometric_normal(in.n, front_facing); - let base = clamp(col.rgb, vec3(0.0), vec3(1.0)); - let lit = dl::shade_clustered_diffuse(in.clip_pos.xy, in.world_p, n, base, in.view_layer); - col = vec4(lit, col.a); - } - return rg::retain_globals_additive(rfog::apply_rgba(col, in.fog_coord)); } diff --git a/crates/renderide/shaders/materials/blur.wgsl b/crates/renderide/shaders/materials/blur.wgsl index d28f5fa89..d32662d59 100644 --- a/crates/renderide/shaders/materials/blur.wgsl +++ b/crates/renderide/shaders/materials/blur.wgsl @@ -15,6 +15,7 @@ //#mat_default _NormalMap_LodBias float 0.0 //#mat_default _SpreadTex_LodBias float 0.0 +#import renderide::billboard::vertex as bv #import renderide::core::texture_sampling as ts #import renderide::core::uv as uvu #import renderide::post::filter_math as fm @@ -78,6 +79,7 @@ fn kw_SPREAD_TEX() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -85,12 +87,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fr::VertexOutput { #ifdef MULTIVIEW - return fr::vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fr::vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fr::billboard_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fr::vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } fn refraction_enabled() -> bool { diff --git a/crates/renderide/shaders/materials/channelmatrix.wgsl b/crates/renderide/shaders/materials/channelmatrix.wgsl index 9f5114a88..ace379ac0 100644 --- a/crates/renderide/shaders/materials/channelmatrix.wgsl +++ b/crates/renderide/shaders/materials/channelmatrix.wgsl @@ -10,6 +10,7 @@ //#mat_default _LevelsG vec4 0.0 0.0 1.0 0.0 //#mat_default _LevelsR vec4 0.0 1.0 0.0 0.0 +#import renderide::billboard::vertex as bv #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::material::variant_bits as vb @@ -40,6 +41,7 @@ fn kw_RECTCLIP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -47,12 +49,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/fresnel.wgsl b/crates/renderide/shaders/materials/fresnel.wgsl index 33822bb8e..943b4b6d7 100644 --- a/crates/renderide/shaders/materials/fresnel.wgsl +++ b/crates/renderide/shaders/materials/fresnel.wgsl @@ -16,6 +16,7 @@ //#mat_default _PolarPow float 1.0 //#mat_default _Cutoff float 0.5 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::pbs::normal as pnorm #import renderide::material::alpha as ma @@ -122,6 +123,7 @@ fn vertex_color_to_linear(color: vec4) -> vec4 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -130,12 +132,18 @@ fn vs_main( @location(2) uv: vec2, @location(3) color: vec4, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldColorVertexOutput { #ifdef MULTIVIEW - return mv::world_color_vertex_main(instance_index, view_idx, pos, n, t, uv, color); + let view_layer = view_idx; #else - return mv::world_color_vertex_main(instance_index, 0u, pos, n, t, uv, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv, color, vertex_index, uv1); + } else { + return mv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv, color); + } } //#pass type=forward a2c=cutout diff --git a/crates/renderide/shaders/materials/fresnellerp.wgsl b/crates/renderide/shaders/materials/fresnellerp.wgsl index 39d215840..dd365cccf 100644 --- a/crates/renderide/shaders/materials/fresnellerp.wgsl +++ b/crates/renderide/shaders/materials/fresnellerp.wgsl @@ -19,6 +19,7 @@ //#mat_default _NearColor0 vec4 1.0 1.0 1.0 1.0 //#mat_default _NearColor1 vec4 0.8 0.8 0.8 0.8 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::pbs::normal as pnorm #import renderide::material::fresnel as mf @@ -97,6 +98,7 @@ fn kw_TEXTURE() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -104,12 +106,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv); + } } fn compute_lerp(uv: vec2) -> f32 { diff --git a/crates/renderide/shaders/materials/furfx-2.0-10layer.wgsl b/crates/renderide/shaders/materials/furfx-2.0-10layer.wgsl index 6cf9219b6..8365c1f81 100644 --- a/crates/renderide/shaders/materials/furfx-2.0-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-2.0-10layer.wgsl @@ -28,13 +28,14 @@ #import renderide::fur::modern as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, t, uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, t, uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -42,17 +43,20 @@ fn vs_l_00( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -60,17 +64,20 @@ fn vs_l_01( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.1); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -78,17 +85,20 @@ fn vs_l_02( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.2); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -96,17 +106,20 @@ fn vs_l_03( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.3); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -114,17 +127,20 @@ fn vs_l_04( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.4); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -132,17 +148,20 @@ fn vs_l_05( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.5); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -150,17 +169,20 @@ fn vs_l_06( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.6); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -168,17 +190,20 @@ fn vs_l_07( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.7); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -186,17 +211,20 @@ fn vs_l_08( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.8); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -204,17 +232,20 @@ fn vs_l_09( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.9); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -222,12 +253,14 @@ fn vs_l_10( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 1.0); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-2.0-20layer.wgsl b/crates/renderide/shaders/materials/furfx-2.0-20layer.wgsl index 126e58d44..a53e0b0bc 100644 --- a/crates/renderide/shaders/materials/furfx-2.0-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-2.0-20layer.wgsl @@ -28,13 +28,14 @@ #import renderide::fur::modern as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, t, uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, t, uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -42,17 +43,20 @@ fn vs_l_00( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -60,17 +64,20 @@ fn vs_l_01( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -78,17 +85,20 @@ fn vs_l_02( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.1); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -96,17 +106,20 @@ fn vs_l_03( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.15); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -114,17 +127,20 @@ fn vs_l_04( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.2); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -132,17 +148,20 @@ fn vs_l_05( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.25); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -150,17 +169,20 @@ fn vs_l_06( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.3); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -168,17 +190,20 @@ fn vs_l_07( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.35); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -186,17 +211,20 @@ fn vs_l_08( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.4); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -204,17 +232,20 @@ fn vs_l_09( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.45); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -222,17 +253,20 @@ fn vs_l_10( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.5); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -240,17 +274,20 @@ fn vs_l_11( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.55); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -258,17 +295,20 @@ fn vs_l_12( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.6); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -276,17 +316,20 @@ fn vs_l_13( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.65); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -294,17 +337,20 @@ fn vs_l_14( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.7); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -312,17 +358,20 @@ fn vs_l_15( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.75); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -330,17 +379,20 @@ fn vs_l_16( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.8); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -348,17 +400,20 @@ fn vs_l_17( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.85); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -366,17 +421,20 @@ fn vs_l_18( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.9); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -384,17 +442,20 @@ fn vs_l_19( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.95); } @vertex fn vs_l_20( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -402,12 +463,14 @@ fn vs_l_20( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 1.0); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-3.0-10layer.wgsl b/crates/renderide/shaders/materials/furfx-3.0-10layer.wgsl index 7145fc52e..66af8816b 100644 --- a/crates/renderide/shaders/materials/furfx-3.0-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-3.0-10layer.wgsl @@ -28,13 +28,14 @@ #import renderide::fur::modern as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, t, uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, t, uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -42,17 +43,20 @@ fn vs_l_00( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -60,17 +64,20 @@ fn vs_l_01( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.1); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -78,17 +85,20 @@ fn vs_l_02( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.2); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -96,17 +106,20 @@ fn vs_l_03( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.3); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -114,17 +127,20 @@ fn vs_l_04( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.4); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -132,17 +148,20 @@ fn vs_l_05( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.5); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -150,17 +169,20 @@ fn vs_l_06( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.6); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -168,17 +190,20 @@ fn vs_l_07( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.7); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -186,17 +211,20 @@ fn vs_l_08( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.8); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -204,17 +232,20 @@ fn vs_l_09( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.9); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -222,12 +253,14 @@ fn vs_l_10( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 1.0); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-3.0-20layer.wgsl b/crates/renderide/shaders/materials/furfx-3.0-20layer.wgsl index 4795ae530..c59252eb9 100644 --- a/crates/renderide/shaders/materials/furfx-3.0-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-3.0-20layer.wgsl @@ -28,13 +28,14 @@ #import renderide::fur::modern as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, t, uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, t, uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -42,17 +43,20 @@ fn vs_l_00( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -60,17 +64,20 @@ fn vs_l_01( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -78,17 +85,20 @@ fn vs_l_02( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.1); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -96,17 +106,20 @@ fn vs_l_03( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.15); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -114,17 +127,20 @@ fn vs_l_04( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.2); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -132,17 +148,20 @@ fn vs_l_05( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.25); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -150,17 +169,20 @@ fn vs_l_06( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.3); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -168,17 +190,20 @@ fn vs_l_07( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.35); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -186,17 +211,20 @@ fn vs_l_08( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.4); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -204,17 +232,20 @@ fn vs_l_09( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.45); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -222,17 +253,20 @@ fn vs_l_10( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.5); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -240,17 +274,20 @@ fn vs_l_11( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.55); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -258,17 +295,20 @@ fn vs_l_12( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.6); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -276,17 +316,20 @@ fn vs_l_13( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.65); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -294,17 +337,20 @@ fn vs_l_14( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.7); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -312,17 +358,20 @@ fn vs_l_15( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.75); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -330,17 +379,20 @@ fn vs_l_16( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.8); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -348,17 +400,20 @@ fn vs_l_17( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.85); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -366,17 +421,20 @@ fn vs_l_18( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.9); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -384,17 +442,20 @@ fn vs_l_19( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.95); } @vertex fn vs_l_20( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -402,12 +463,14 @@ fn vs_l_20( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 1.0); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-3.0-shell-10layer.wgsl b/crates/renderide/shaders/materials/furfx-3.0-shell-10layer.wgsl index 2386f7316..9970a5a43 100644 --- a/crates/renderide/shaders/materials/furfx-3.0-shell-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-3.0-shell-10layer.wgsl @@ -27,13 +27,14 @@ #import renderide::fur::modern as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, t, uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, t, uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -41,17 +42,20 @@ fn vs_l_00( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.1); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,17 +63,20 @@ fn vs_l_01( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.2); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -77,17 +84,20 @@ fn vs_l_02( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.3); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -95,17 +105,20 @@ fn vs_l_03( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.4); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -113,17 +126,20 @@ fn vs_l_04( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.5); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -131,17 +147,20 @@ fn vs_l_05( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.6); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -149,17 +168,20 @@ fn vs_l_06( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.7); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -167,17 +189,20 @@ fn vs_l_07( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.8); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -185,17 +210,20 @@ fn vs_l_08( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.9); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -203,12 +231,14 @@ fn vs_l_09( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 1.0); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-3.0-shell-20layer.wgsl b/crates/renderide/shaders/materials/furfx-3.0-shell-20layer.wgsl index 2e384d66b..58cf4466a 100644 --- a/crates/renderide/shaders/materials/furfx-3.0-shell-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-3.0-shell-20layer.wgsl @@ -27,13 +27,14 @@ #import renderide::fur::modern as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, t, uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, t, uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -41,17 +42,20 @@ fn vs_l_00( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.05); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,17 +63,20 @@ fn vs_l_01( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.1); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -77,17 +84,20 @@ fn vs_l_02( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.15); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -95,17 +105,20 @@ fn vs_l_03( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.2); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -113,17 +126,20 @@ fn vs_l_04( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.25); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -131,17 +147,20 @@ fn vs_l_05( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.3); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -149,17 +168,20 @@ fn vs_l_06( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.35); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -167,17 +189,20 @@ fn vs_l_07( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.4); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -185,17 +210,20 @@ fn vs_l_08( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.45); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -203,17 +231,20 @@ fn vs_l_09( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.5); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -221,17 +252,20 @@ fn vs_l_10( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.55); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -239,17 +273,20 @@ fn vs_l_11( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.6); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -257,17 +294,20 @@ fn vs_l_12( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.65); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -275,17 +315,20 @@ fn vs_l_13( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.7); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -293,17 +336,20 @@ fn vs_l_14( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.75); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -311,17 +357,20 @@ fn vs_l_15( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.8); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -329,17 +378,20 @@ fn vs_l_16( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.85); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -347,17 +399,20 @@ fn vs_l_17( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.9); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -365,17 +420,20 @@ fn vs_l_18( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 0.95); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -383,12 +441,14 @@ fn vs_l_19( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, t, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, t, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, t, uv0, uv1, 1.0); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-10layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-10layer.wgsl index 130216f33..c4edba085 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-10layer.wgsl @@ -24,195 +24,228 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-20layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-20layer.wgsl index 8e9fe9d47..4b12dd7bb 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-20layer.wgsl @@ -24,348 +24,408 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-40layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-40layer.wgsl index 4c7324a4c..0e925c3e5 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-40layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-40layer.wgsl @@ -24,688 +24,808 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.075); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.075); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.075); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.125); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.125); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.125); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.175); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.175); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.175); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.225); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.225); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.225); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.275); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.275); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.275); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.325); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.325); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.325); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.375); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.375); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.375); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.425); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.425); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.425); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.475); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.475); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.475); } @vertex fn vs_l_20( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_21( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.525); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.525); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.525); } @vertex fn vs_l_22( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_23( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.575); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.575); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.575); } @vertex fn vs_l_24( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_25( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.625); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.625); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.625); } @vertex fn vs_l_26( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_27( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.675); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.675); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.675); } @vertex fn vs_l_28( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_29( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.725); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.725); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.725); } @vertex fn vs_l_30( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_31( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.775); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.775); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.775); } @vertex fn vs_l_32( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_33( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.825); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.825); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.825); } @vertex fn vs_l_34( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_35( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.875); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.875); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.875); } @vertex fn vs_l_36( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_37( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.925); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.925); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.925); } @vertex fn vs_l_38( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } @vertex fn vs_l_39( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.975); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.975); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.975); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-5layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-5layer.wgsl index 41fa000e7..317caaf04 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-5layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-5layer.wgsl @@ -24,93 +24,108 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-shell-10layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-shell-10layer.wgsl index 40a6b9880..de06ee139 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-shell-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-shell-10layer.wgsl @@ -24,178 +24,208 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-shell-20layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-shell-20layer.wgsl index 79a291666..f6f19a83e 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-shell-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-shell-20layer.wgsl @@ -24,331 +24,388 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-shell-40layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-shell-40layer.wgsl index f9c1f6b3c..566a5c0c5 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-shell-40layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-shell-40layer.wgsl @@ -24,671 +24,788 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.075); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.075); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.075); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.125); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.125); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.125); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.175); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.175); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.175); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.225); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.225); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.225); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.275); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.275); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.275); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.325); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.325); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.325); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.375); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.375); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.375); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.425); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.425); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.425); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.475); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.475); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.475); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_20( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.525); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.525); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.525); } @vertex fn vs_l_21( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_22( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.575); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.575); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.575); } @vertex fn vs_l_23( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_24( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.625); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.625); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.625); } @vertex fn vs_l_25( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_26( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.675); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.675); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.675); } @vertex fn vs_l_27( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_28( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.725); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.725); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.725); } @vertex fn vs_l_29( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_30( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.775); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.775); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.775); } @vertex fn vs_l_31( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_32( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.825); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.825); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.825); } @vertex fn vs_l_33( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_34( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.875); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.875); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.875); } @vertex fn vs_l_35( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_36( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.925); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.925); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.925); } @vertex fn vs_l_37( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } @vertex fn vs_l_38( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.975); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.975); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.975); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-advanced-shell-5layer.wgsl b/crates/renderide/shaders/materials/furfx-advanced-shell-5layer.wgsl index bd84c77c6..23438107d 100644 --- a/crates/renderide/shaders/materials/furfx-advanced-shell-5layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-advanced-shell-5layer.wgsl @@ -24,76 +24,88 @@ #import renderide::fur::classic_advanced as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-basic-10layer.wgsl b/crates/renderide/shaders/materials/furfx-basic-10layer.wgsl index cd3bee0d0..b9ac69f97 100644 --- a/crates/renderide/shaders/materials/furfx-basic-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-basic-10layer.wgsl @@ -20,195 +20,228 @@ #import renderide::fur::classic_basic as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-basic-20layer.wgsl b/crates/renderide/shaders/materials/furfx-basic-20layer.wgsl index 86142af88..abf5ba3fb 100644 --- a/crates/renderide/shaders/materials/furfx-basic-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-basic-20layer.wgsl @@ -20,348 +20,408 @@ #import renderide::fur::classic_basic as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-basic-40layer.wgsl b/crates/renderide/shaders/materials/furfx-basic-40layer.wgsl index 43cd26a83..7acf8bb3b 100644 --- a/crates/renderide/shaders/materials/furfx-basic-40layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-basic-40layer.wgsl @@ -20,688 +20,808 @@ #import renderide::fur::classic_basic as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.075); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.075); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.075); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.125); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.125); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.125); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.175); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.175); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.175); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.225); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.225); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.225); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.275); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.275); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.275); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.325); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.325); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.325); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.375); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.375); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.375); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.425); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.425); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.425); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.475); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.475); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.475); } @vertex fn vs_l_20( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_21( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.525); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.525); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.525); } @vertex fn vs_l_22( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_23( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.575); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.575); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.575); } @vertex fn vs_l_24( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_25( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.625); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.625); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.625); } @vertex fn vs_l_26( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_27( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.675); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.675); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.675); } @vertex fn vs_l_28( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_29( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.725); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.725); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.725); } @vertex fn vs_l_30( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_31( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.775); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.775); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.775); } @vertex fn vs_l_32( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_33( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.825); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.825); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.825); } @vertex fn vs_l_34( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_35( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.875); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.875); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.875); } @vertex fn vs_l_36( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_37( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.925); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.925); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.925); } @vertex fn vs_l_38( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } @vertex fn vs_l_39( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.975); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.975); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.975); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-basic-5layer.wgsl b/crates/renderide/shaders/materials/furfx-basic-5layer.wgsl index f29b1df12..3441b0a19 100644 --- a/crates/renderide/shaders/materials/furfx-basic-5layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-basic-5layer.wgsl @@ -20,93 +20,108 @@ #import renderide::fur::classic_basic as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-selfshadow-blend-10layer.wgsl b/crates/renderide/shaders/materials/furfx-selfshadow-blend-10layer.wgsl index 07fa1c40c..b964fb958 100644 --- a/crates/renderide/shaders/materials/furfx-selfshadow-blend-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-selfshadow-blend-10layer.wgsl @@ -25,195 +25,228 @@ #import renderide::fur::classic_selfshadow as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 1.0); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-selfshadow-blend-20layer.wgsl b/crates/renderide/shaders/materials/furfx-selfshadow-blend-20layer.wgsl index 8d2151f59..2e0d47b5b 100644 --- a/crates/renderide/shaders/materials/furfx-selfshadow-blend-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-selfshadow-blend-20layer.wgsl @@ -25,348 +25,408 @@ #import renderide::fur::classic_selfshadow as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward name=forward_alpha_blend_zwrite blend=alpha zwrite=on ztest=main color_mask=rgba offset=0,0 vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-selfshadow-noblend-10layer.wgsl b/crates/renderide/shaders/materials/furfx-selfshadow-noblend-10layer.wgsl index fd86889ca..813a84eb2 100644 --- a/crates/renderide/shaders/materials/furfx-selfshadow-noblend-10layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-selfshadow-noblend-10layer.wgsl @@ -25,195 +25,228 @@ #import renderide::fur::classic_selfshadow as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 1.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 1.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 1.0); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/furfx-selfshadow-noblend-20layer.wgsl b/crates/renderide/shaders/materials/furfx-selfshadow-noblend-20layer.wgsl index 889ccf88f..1414368b9 100644 --- a/crates/renderide/shaders/materials/furfx-selfshadow-noblend-20layer.wgsl +++ b/crates/renderide/shaders/materials/furfx-selfshadow-noblend-20layer.wgsl @@ -25,348 +25,408 @@ #import renderide::fur::classic_selfshadow as fur #import renderide::fur::common as furc -fn vertex_at(instance_index: u32, view_idx: u32, pos: vec4, n: vec4, uv0: vec2, fur_multiplier: f32) -> furc::VertexOutput { - return fur::vertex_main(instance_index, view_idx, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, fur_multiplier); +fn vertex_at(instance_index: u32, view_idx: u32, vertex_index: u32, pos: vec4, n: vec4, uv0: vec2, uv1: vec2, fur_multiplier: f32) -> furc::VertexOutput { + return fur::vertex_main(instance_index, view_idx, vertex_index, pos, n, vec4(1.0, 0.0, 0.0, 1.0), uv0, uv1, fur_multiplier); } @vertex fn vs_l_00( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.0); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.0); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.0); } @vertex fn vs_l_01( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.05); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.05); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.05); } @vertex fn vs_l_02( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.1); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.1); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.1); } @vertex fn vs_l_03( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.15); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.15); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.15); } @vertex fn vs_l_04( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.2); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.2); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.2); } @vertex fn vs_l_05( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.25); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.25); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.25); } @vertex fn vs_l_06( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.3); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.3); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.3); } @vertex fn vs_l_07( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.35); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.35); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.35); } @vertex fn vs_l_08( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.4); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.4); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.4); } @vertex fn vs_l_09( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.45); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.45); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.45); } @vertex fn vs_l_10( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.5); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.5); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.5); } @vertex fn vs_l_11( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.55); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.55); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.55); } @vertex fn vs_l_12( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.6); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.6); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.6); } @vertex fn vs_l_13( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.65); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.65); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.65); } @vertex fn vs_l_14( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.7); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.7); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.7); } @vertex fn vs_l_15( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.75); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.75); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.75); } @vertex fn vs_l_16( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.8); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.8); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.8); } @vertex fn vs_l_17( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.85); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.85); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.85); } @vertex fn vs_l_18( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.9); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.9); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.9); } @vertex fn vs_l_19( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, + @location(5) uv1: vec2, ) -> furc::VertexOutput { #ifdef MULTIVIEW - return vertex_at(instance_index, view_idx, pos, n, uv0, 0.95); + let view_layer = view_idx; #else - return vertex_at(instance_index, 0u, pos, n, uv0, 0.95); + let view_layer = 0u; #endif + return vertex_at(instance_index, view_layer, vertex_index, pos, n, uv0, uv1, 0.95); } //#pass type=forward a2c=cutout vs=vs_l_00 diff --git a/crates/renderide/shaders/materials/gamma.wgsl b/crates/renderide/shaders/materials/gamma.wgsl index 86072f4db..620ab35b2 100644 --- a/crates/renderide/shaders/materials/gamma.wgsl +++ b/crates/renderide/shaders/materials/gamma.wgsl @@ -6,6 +6,7 @@ //#render_queue Transparent+500 //#mat_default _Gamma float 2.2 +#import renderide::billboard::vertex as bv #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::material::variant_bits as vb @@ -32,6 +33,7 @@ fn kw_RECTCLIP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -39,12 +41,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter zwrite=material(on) ztest=material(main) cull=material(back) color_mask=material(rgba) stencil=material offset=material(0,0) diff --git a/crates/renderide/shaders/materials/getdepth.wgsl b/crates/renderide/shaders/materials/getdepth.wgsl index e50fc0b65..7e01efcda 100644 --- a/crates/renderide/shaders/materials/getdepth.wgsl +++ b/crates/renderide/shaders/materials/getdepth.wgsl @@ -12,6 +12,7 @@ //#mat_default _ClipMax float 1.0 //#mat_default _Multiply float 1.0 +#import renderide::billboard::vertex as bv #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::frame::scene_depth_sample as sds @@ -48,6 +49,7 @@ fn kw_RECTCLIP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -55,12 +57,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter zwrite=material(off) ztest=material(main) cull=material(back) color_mask=material(rgba) stencil=material offset=material(0,0) diff --git a/crates/renderide/shaders/materials/grayscale.wgsl b/crates/renderide/shaders/materials/grayscale.wgsl index f70e7e42f..19a150027 100644 --- a/crates/renderide/shaders/materials/grayscale.wgsl +++ b/crates/renderide/shaders/materials/grayscale.wgsl @@ -10,6 +10,7 @@ //#mat_default _RatioG float 0.59 //#mat_default _RatioR float 0.3 +#import renderide::billboard::vertex as bv #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::material::variant_bits as vb @@ -47,6 +48,7 @@ fn kw_RECTCLIP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -54,12 +56,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/hsv.wgsl b/crates/renderide/shaders/materials/hsv.wgsl index c6e5d0ef2..aedfd0670 100644 --- a/crates/renderide/shaders/materials/hsv.wgsl +++ b/crates/renderide/shaders/materials/hsv.wgsl @@ -5,6 +5,7 @@ //#mat_default _HSVMul vec4 1.0 1.0 1.0 1.0 //#mat_default _HSVOffset vec4 0.2 0.2 0.2 0.0 +#import renderide::billboard::vertex as bv #import renderide::post::filter_math as fm #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc @@ -34,6 +35,7 @@ fn kw_RECTCLIP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -41,12 +43,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/invert.wgsl b/crates/renderide/shaders/materials/invert.wgsl index 193446cbd..9e6c8e342 100644 --- a/crates/renderide/shaders/materials/invert.wgsl +++ b/crates/renderide/shaders/materials/invert.wgsl @@ -4,6 +4,7 @@ //#render_queue Transparent+500 //#mat_default _Lerp float 1.0 +#import renderide::billboard::vertex as bv #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::material::variant_bits as vb @@ -30,6 +31,7 @@ fn kw_RECTCLIP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -37,12 +39,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/lut.wgsl b/crates/renderide/shaders/materials/lut.wgsl index e4d5b6632..ffb383861 100644 --- a/crates/renderide/shaders/materials/lut.wgsl +++ b/crates/renderide/shaders/materials/lut.wgsl @@ -5,6 +5,7 @@ //#texture_default _LUT empty //#texture_default _SecondaryLUT empty +#import renderide::billboard::vertex as bv #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::core::texture_sampling as ts @@ -45,6 +46,7 @@ fn kw_SRGB() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -52,12 +54,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/matcap.wgsl b/crates/renderide/shaders/materials/matcap.wgsl index ad9a0957d..0d1b98ead 100644 --- a/crates/renderide/shaders/materials/matcap.wgsl +++ b/crates/renderide/shaders/materials/matcap.wgsl @@ -4,6 +4,7 @@ //#texture_default _MainTex white //#texture_default _NormalMap bump +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::draw::per_draw as pd #import renderide::core::math as rmath @@ -51,6 +52,7 @@ struct VertexOutput { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -58,13 +60,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) tangent: vec4, + @location(5) uv1: vec2, ) -> VertexOutput { + #ifdef MULTIVIEW + let view_layer = view_idx; + #else + let view_layer = 0u; + #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return billboard_vertex_main(instance_index, view_layer, pos, n, uv0, tangent, uv1, vertex_index); + } + let d = pd::get_draw(instance_index); -#ifdef MULTIVIEW - let view_layer = view_idx; -#else - let view_layer = 0u; -#endif let world_p = mv::world_position(d, pos); let world_n = rmath::safe_normalize(d.normal_matrix * n.xyz, vec3(0.0, 1.0, 0.0)); let tbn = pnorm::orthonormal_tbn(world_n, mv::world_tangent(d, tangent)); @@ -82,6 +89,39 @@ fn vs_main( return out; } +fn billboard_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + uv0: vec2, + tangent: vec4, + uv1: vec2, + vertex_index: u32, +) -> VertexOutput { + let d = pd::get_draw(instance_index); + + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_idx, pos, vertex_index, n, tangent, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + let vp = mv::select_view_proj(d, view_idx); + let basis = vb::from_view_projection(vp); + + var out: VertexOutput; + out.clip_pos = vp * world_p; + out.uv_normal = uvu::apply_st(uv0, mat._NormalMap_ST); + out.world_n = mv::world_normal_for_view(d, vec4(billboard_n, 0.0), view_idx).xyz; + out.world_t = mv::world_tangent_for_view(d, vec4(billboard_t, 0.0), view_idx).xyz; + out.world_b = rmath::safe_normalize(cross(out.world_n, out.world_t), vec3(0.0, 0.0, 1.0)); + out.view_x = basis.x; + out.view_y = basis.y; + return out; +} + //#pass type=forward blend=material_filter @fragment fn fs_main( diff --git a/crates/renderide/shaders/materials/overlayfresnel.wgsl b/crates/renderide/shaders/materials/overlayfresnel.wgsl index 11056bd3b..072d93e30 100644 --- a/crates/renderide/shaders/materials/overlayfresnel.wgsl +++ b/crates/renderide/shaders/materials/overlayfresnel.wgsl @@ -22,6 +22,7 @@ //#mat_default _GammaCurve float 2.2 //#mat_default _PolarPow float 1.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::fresnel as mf #import renderide::material::variant_bits as vb @@ -92,6 +93,7 @@ fn kw_TEXTURE() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -99,12 +101,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv); + } } fn sample_overlay_tex( diff --git a/crates/renderide/shaders/materials/overlayunlit.wgsl b/crates/renderide/shaders/materials/overlayunlit.wgsl index 9ba664957..5cdd4d6a5 100644 --- a/crates/renderide/shaders/materials/overlayunlit.wgsl +++ b/crates/renderide/shaders/materials/overlayunlit.wgsl @@ -14,6 +14,7 @@ //#mat_default _PolarPow float 1.0 //#mat_default _Cutoff float 0.5 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::variant_bits as vb #import renderide::material::vertex_color as vc @@ -88,19 +89,27 @@ fn kw_VERTEXCOLORS() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, - @location(1) _n: vec4, + @location(1) n: vec4, @location(2) uv: vec2, @location(3) color: vec4, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::UvColorVertexOutput { #ifdef MULTIVIEW - return mv::uv_color_vertex_main(instance_index, view_idx, pos, uv, color); + let view_layer = view_idx; #else - return mv::uv_color_vertex_main(instance_index, 0u, pos, uv, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::uv_color_vertex_main(instance_index, view_layer, pos, uv, color, n, t, vertex_index, uv1); + } else { + return mv::uv_color_vertex_main(instance_index, view_layer, pos, uv, color); + } } fn sample_layer( diff --git a/crates/renderide/shaders/materials/pbscolormask.wgsl b/crates/renderide/shaders/materials/pbscolormask.wgsl index e765b605b..5b0a1874c 100644 --- a/crates/renderide/shaders/materials/pbscolormask.wgsl +++ b/crates/renderide/shaders/materials/pbscolormask.wgsl @@ -23,6 +23,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::material::color as mcolor #import renderide::mesh::vertex as mv @@ -207,6 +208,7 @@ fn sample_surface(uv0: vec2, world_n: vec3, world_t: vec4) -> Sur @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -214,12 +216,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } /// Forward-base pass: ambient + directional lighting + emission. diff --git a/crates/renderide/shaders/materials/pbscolormaskspecular.wgsl b/crates/renderide/shaders/materials/pbscolormaskspecular.wgsl index cc7c84abf..4ea7241f0 100644 --- a/crates/renderide/shaders/materials/pbscolormaskspecular.wgsl +++ b/crates/renderide/shaders/materials/pbscolormaskspecular.wgsl @@ -20,6 +20,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::material::color as mcolor #import renderide::mesh::vertex as mv @@ -193,6 +194,7 @@ fn sample_surface(uv0: vec2, world_n: vec3, world_t: vec4) -> Sur @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -200,12 +202,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } /// Forward-base pass: ambient + directional lighting + emission. diff --git a/crates/renderide/shaders/materials/pbscolorsplat.wgsl b/crates/renderide/shaders/materials/pbscolorsplat.wgsl index b53c45817..51b5e9160 100644 --- a/crates/renderide/shaders/materials/pbscolorsplat.wgsl +++ b/crates/renderide/shaders/materials/pbscolorsplat.wgsl @@ -38,6 +38,7 @@ //#mat_default _Glossiness3 float 0.5 //#mat_default _HeightTransitionRange float 0.1 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::normal as pnorm @@ -237,6 +238,7 @@ fn sample_surface(uv0: vec2, world_n: vec3, world_t: vec4) -> Sur @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -244,12 +246,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward diff --git a/crates/renderide/shaders/materials/pbscolorsplatspecular.wgsl b/crates/renderide/shaders/materials/pbscolorsplatspecular.wgsl index 4cb836591..2ff460ec7 100644 --- a/crates/renderide/shaders/materials/pbscolorsplatspecular.wgsl +++ b/crates/renderide/shaders/materials/pbscolorsplatspecular.wgsl @@ -37,6 +37,7 @@ //#mat_default _SpecularColor3 vec4 0.5 0.5 0.5 0.5 //#mat_default _HeightTransitionRange float 0.1 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::normal as pnorm @@ -237,6 +238,7 @@ fn sample_surface(uv0: vec2, world_n: vec3, world_t: vec4) -> Sur @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -244,12 +246,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward diff --git a/crates/renderide/shaders/materials/pbsdualsided.wgsl b/crates/renderide/shaders/materials/pbsdualsided.wgsl index 9605b52f9..d919bd903 100644 --- a/crates/renderide/shaders/materials/pbsdualsided.wgsl +++ b/crates/renderide/shaders/materials/pbsdualsided.wgsl @@ -18,6 +18,7 @@ //#mat_default _AlphaClip float 0.5 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight @@ -147,6 +148,7 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -155,12 +157,18 @@ fn vs_main( @location(2) uv0: vec2, @location(3) color: vec4, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldColorVertexOutput { #ifdef MULTIVIEW - return mv::world_color_vertex_main(instance_index, view_idx, pos, n, t, uv0, color); + let view_layer = view_idx; #else - return mv::world_color_vertex_main(instance_index, 0u, pos, n, t, uv0, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color, vertex_index, uv1); + } else { + return mv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color); + } } //#pass type=forward name=forward_two_sided cull=material(off) offset=material(0,0) a2c=cutout diff --git a/crates/renderide/shaders/materials/pbsdualsidedspecular.wgsl b/crates/renderide/shaders/materials/pbsdualsidedspecular.wgsl index 21e1660dc..d46cf3da7 100644 --- a/crates/renderide/shaders/materials/pbsdualsidedspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsdualsidedspecular.wgsl @@ -17,6 +17,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _AlphaClip float 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight #import renderide::pbs::sampling as psamp @@ -152,6 +153,7 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -160,12 +162,18 @@ fn vs_main( @location(2) uv0: vec2, @location(3) color: vec4, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldColorVertexOutput { #ifdef MULTIVIEW - return mv::world_color_vertex_main(instance_index, view_idx, pos, n, t, uv0, color); + let view_layer = view_idx; #else - return mv::world_color_vertex_main(instance_index, 0u, pos, n, t, uv0, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color, vertex_index, uv1); + } else { + return mv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color); + } } //#pass type=forward name=forward_two_sided cull=material(off) offset=material(0,0) a2c=cutout diff --git a/crates/renderide/shaders/materials/pbsdualsidedtransparent.wgsl b/crates/renderide/shaders/materials/pbsdualsidedtransparent.wgsl index 241bb8cd2..3fc700788 100644 --- a/crates/renderide/shaders/materials/pbsdualsidedtransparent.wgsl +++ b/crates/renderide/shaders/materials/pbsdualsidedtransparent.wgsl @@ -18,6 +18,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight #import renderide::pbs::sampling as psamp @@ -151,6 +152,7 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -159,12 +161,18 @@ fn vs_main( @location(2) uv0: vec2, @location(3) color: vec4, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldColorVertexOutput { #ifdef MULTIVIEW - return mv::world_color_vertex_main(instance_index, view_idx, pos, n, t, uv0, color); + let view_layer = view_idx; #else - return mv::world_color_vertex_main(instance_index, 0u, pos, n, t, uv0, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color, vertex_index, uv1); + } else { + return mv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color); + } } fn shade( diff --git a/crates/renderide/shaders/materials/pbsdualsidedtransparentspecular.wgsl b/crates/renderide/shaders/materials/pbsdualsidedtransparentspecular.wgsl index bef5b2ab5..da9c27062 100644 --- a/crates/renderide/shaders/materials/pbsdualsidedtransparentspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsdualsidedtransparentspecular.wgsl @@ -20,6 +20,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight #import renderide::pbs::sampling as psamp @@ -167,6 +168,7 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -175,12 +177,18 @@ fn vs_main( @location(2) uv0: vec2, @location(3) color: vec4, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldColorVertexOutput { #ifdef MULTIVIEW - return mv::world_color_vertex_main(instance_index, view_idx, pos, n, t, uv0, color); + let view_layer = view_idx; #else - return mv::world_color_vertex_main(instance_index, 0u, pos, n, t, uv0, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color, vertex_index, uv1); + } else { + return mv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color); + } } fn shade( diff --git a/crates/renderide/shaders/materials/pbsintersect.wgsl b/crates/renderide/shaders/materials/pbsintersect.wgsl index 7945b7e7c..0bfb9295e 100644 --- a/crates/renderide/shaders/materials/pbsintersect.wgsl +++ b/crates/renderide/shaders/materials/pbsintersect.wgsl @@ -22,6 +22,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::families::intersect as pint @@ -71,6 +72,7 @@ fn pbs_kw(mask: u32) -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -78,12 +80,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_transparent blend=transparent_material zwrite=material(off) cull=material(off) color_mask=material(rgba) offset=material(0,0) diff --git a/crates/renderide/shaders/materials/pbsintersectspecular.wgsl b/crates/renderide/shaders/materials/pbsintersectspecular.wgsl index 2bbaa1aee..609a5894b 100644 --- a/crates/renderide/shaders/materials/pbsintersectspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsintersectspecular.wgsl @@ -19,6 +19,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::families::intersect as pint @@ -67,6 +68,7 @@ fn pbs_kw(mask: u32) -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -74,12 +76,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_transparent blend=transparent_material zwrite=material(off) cull=material(off) color_mask=material(rgba) offset=material(0,0) diff --git a/crates/renderide/shaders/materials/pbslerp.wgsl b/crates/renderide/shaders/materials/pbslerp.wgsl index a2e26baf2..220e65c9c 100644 --- a/crates/renderide/shaders/materials/pbslerp.wgsl +++ b/crates/renderide/shaders/materials/pbslerp.wgsl @@ -26,6 +26,7 @@ //#mat_default _Glossiness float 0.5 //#mat_default _Glossiness1 float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight @@ -138,6 +139,7 @@ fn compute_lerp_factor(uv_lerp: vec2) -> f32 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -145,12 +147,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward ztest=main a2c=cutout diff --git a/crates/renderide/shaders/materials/pbslerpspecular.wgsl b/crates/renderide/shaders/materials/pbslerpspecular.wgsl index 5fad69426..0a7ec19b8 100644 --- a/crates/renderide/shaders/materials/pbslerpspecular.wgsl +++ b/crates/renderide/shaders/materials/pbslerpspecular.wgsl @@ -23,6 +23,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _SpecularColor1 vec4 1.0 1.0 1.0 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight @@ -133,6 +134,7 @@ fn compute_lerp_factor(uv_lerp: vec2) -> f32 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -140,12 +142,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward ztest=main a2c=cutout diff --git a/crates/renderide/shaders/materials/pbsmetallic.wgsl b/crates/renderide/shaders/materials/pbsmetallic.wgsl index 1975914b7..0ac599f96 100644 --- a/crates/renderide/shaders/materials/pbsmetallic.wgsl +++ b/crates/renderide/shaders/materials/pbsmetallic.wgsl @@ -30,6 +30,7 @@ //#mat_default _Cutoff float 0.5 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::detail as pdet @@ -227,6 +228,7 @@ fn sample_surface(uv0: vec2, uv1: vec2, world_pos: vec3, world_n: @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -237,10 +239,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> mv::WorldUv2VertexOutput { #ifdef MULTIVIEW - return mv::world_uv2_vertex_main(instance_index, view_idx, pos, n, t, uv0, uv1); + let view_layer = view_idx; #else - return mv::world_uv2_vertex_main(instance_index, 0u, pos, n, t, uv0, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_uv2_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1, vertex_index); + } else { + return mv::world_uv2_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1); + } } //#pass type=forward a2c=cutout diff --git a/crates/renderide/shaders/materials/pbsmultiuv.wgsl b/crates/renderide/shaders/materials/pbsmultiuv.wgsl index c81501b47..96096bc5a 100644 --- a/crates/renderide/shaders/materials/pbsmultiuv.wgsl +++ b/crates/renderide/shaders/materials/pbsmultiuv.wgsl @@ -20,6 +20,7 @@ //#mat_default _AlphaClip float 0.5 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::normal as pnorm @@ -209,6 +210,7 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -221,10 +223,15 @@ fn vs_main( @location(7) uv3: vec2, ) -> mv::WorldUv4VertexOutput { #ifdef MULTIVIEW - return mv::world_uv4_vertex_main(instance_index, view_idx, pos, n, t, uv0, uv1, uv2, uv3); + let view_layer = view_idx; #else - return mv::world_uv4_vertex_main(instance_index, 0u, pos, n, t, uv0, uv1, uv2, uv3); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_uv4_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1, vertex_index); + } else { + return mv::world_uv4_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1, uv2, uv3); + } } /// Forward-base pass: clustered lighting (ambient + directional + local lights) + emission. diff --git a/crates/renderide/shaders/materials/pbsmultiuvspecular.wgsl b/crates/renderide/shaders/materials/pbsmultiuvspecular.wgsl index 441ff7a12..e324f42cb 100644 --- a/crates/renderide/shaders/materials/pbsmultiuvspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsmultiuvspecular.wgsl @@ -21,6 +21,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _AlphaClip float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::normal as pnorm @@ -203,6 +204,7 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -215,10 +217,15 @@ fn vs_main( @location(7) uv3: vec2, ) -> mv::WorldUv4VertexOutput { #ifdef MULTIVIEW - return mv::world_uv4_vertex_main(instance_index, view_idx, pos, n, t, uv0, uv1, uv2, uv3); + let view_layer = view_idx; #else - return mv::world_uv4_vertex_main(instance_index, 0u, pos, n, t, uv0, uv1, uv2, uv3); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_uv4_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1, vertex_index); + } else { + return mv::world_uv4_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1, uv2, uv3); + } } /// Forward-base pass: clustered lighting (ambient + directional + local lights) + emission. diff --git a/crates/renderide/shaders/materials/pbsrim.wgsl b/crates/renderide/shaders/materials/pbsrim.wgsl index 8f7348cad..5f8cd8961 100644 --- a/crates/renderide/shaders/materials/pbsrim.wgsl +++ b/crates/renderide/shaders/materials/pbsrim.wgsl @@ -20,6 +20,7 @@ //#mat_default _Glossiness float 0.5 //#mat_default _RimPower float 3.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::fresnel as mf #import renderide::material::variant_bits as vb @@ -93,6 +94,7 @@ fn metallic_roughness(uv: vec2) -> vec2 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -100,12 +102,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward diff --git a/crates/renderide/shaders/materials/pbsrimspecular.wgsl b/crates/renderide/shaders/materials/pbsrimspecular.wgsl index 704e4ca2d..3779732f7 100644 --- a/crates/renderide/shaders/materials/pbsrimspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsrimspecular.wgsl @@ -19,6 +19,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _RimPower float 3.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::fresnel as mf #import renderide::material::variant_bits as vb @@ -77,6 +78,7 @@ fn sample_normal_world(uv_main: vec2, world_n: vec3, world_t: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward diff --git a/crates/renderide/shaders/materials/pbsrimtransparent.wgsl b/crates/renderide/shaders/materials/pbsrimtransparent.wgsl index 4e43701be..2e12073ba 100644 --- a/crates/renderide/shaders/materials/pbsrimtransparent.wgsl +++ b/crates/renderide/shaders/materials/pbsrimtransparent.wgsl @@ -20,6 +20,7 @@ //#mat_default _Glossiness float 0.5 //#mat_default _RimPower float 3.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::fresnel as mf #import renderide::material::variant_bits as vb @@ -94,6 +95,7 @@ fn metallic_roughness(uv: vec2) -> vec2 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -101,12 +103,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_transparent_cull_back blend=transparent_material zwrite=material(off) cull=back color_mask=material(rgba) diff --git a/crates/renderide/shaders/materials/pbsrimtransparentspecular.wgsl b/crates/renderide/shaders/materials/pbsrimtransparentspecular.wgsl index 4ffe880cc..aa90d22f5 100644 --- a/crates/renderide/shaders/materials/pbsrimtransparentspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsrimtransparentspecular.wgsl @@ -22,6 +22,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _RimPower float 3.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::fresnel as mf #import renderide::material::variant_bits as vb @@ -77,6 +78,7 @@ fn sample_normal_world(uv_main: vec2, world_n: vec3, world_t: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_transparent_cull_back blend=transparent_material zwrite=material(off) cull=back color_mask=material(rgba) diff --git a/crates/renderide/shaders/materials/pbsrimtransparentzwrite.wgsl b/crates/renderide/shaders/materials/pbsrimtransparentzwrite.wgsl index d42eca709..36e995ce1 100644 --- a/crates/renderide/shaders/materials/pbsrimtransparentzwrite.wgsl +++ b/crates/renderide/shaders/materials/pbsrimtransparentzwrite.wgsl @@ -20,6 +20,7 @@ //#mat_default _Glossiness float 0.5 //#mat_default _RimPower float 3.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::fresnel as mf #import renderide::material::variant_bits as vb @@ -80,6 +81,7 @@ fn sample_normal_world(uv_main: vec2, world_n: vec3, world_t: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } /// Depth-only prepass: writes nothing to color (`write=none`) but populates depth so the alpha-blended diff --git a/crates/renderide/shaders/materials/pbsrimtransparentzwritespecular.wgsl b/crates/renderide/shaders/materials/pbsrimtransparentzwritespecular.wgsl index f173c3d54..cb96db323 100644 --- a/crates/renderide/shaders/materials/pbsrimtransparentzwritespecular.wgsl +++ b/crates/renderide/shaders/materials/pbsrimtransparentzwritespecular.wgsl @@ -20,6 +20,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _RimPower float 3.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::material::fresnel as mf #import renderide::material::variant_bits as vb @@ -80,6 +81,7 @@ fn sample_normal_world(uv_main: vec2, world_n: vec3, world_t: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=depth_prepass blend=off zwrite=on ztest=material_froox(main) color_mask=0 cull=material(back) offset=material(0,0) stencil=material diff --git a/crates/renderide/shaders/materials/pbsslice.wgsl b/crates/renderide/shaders/materials/pbsslice.wgsl index 45c8173de..6de40ed73 100644 --- a/crates/renderide/shaders/materials/pbsslice.wgsl +++ b/crates/renderide/shaders/materials/pbsslice.wgsl @@ -27,6 +27,7 @@ //#mat_default _AlphaClip float 0.5 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::material::variant_bits as vb #import renderide::pbs::families::slice as pslice @@ -106,6 +107,7 @@ fn sample_albedo_color(uv_main: vec2, edge_lerp: f32) -> vec4 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -113,12 +115,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldObjectVertexOutput { #ifdef MULTIVIEW - return mv::world_object_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_object_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward cull=material(off) offset=material(0,0) diff --git a/crates/renderide/shaders/materials/pbsslicespecular.wgsl b/crates/renderide/shaders/materials/pbsslicespecular.wgsl index 9bfd1ee78..f65120a3a 100644 --- a/crates/renderide/shaders/materials/pbsslicespecular.wgsl +++ b/crates/renderide/shaders/materials/pbsslicespecular.wgsl @@ -25,6 +25,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _AlphaClip float 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::material::variant_bits as vb #import renderide::pbs::families::slice as pslice @@ -106,6 +107,7 @@ fn sample_albedo_color(uv_main: vec2, edge_lerp: f32) -> vec4 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -113,12 +115,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldObjectVertexOutput { #ifdef MULTIVIEW - return mv::world_object_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_object_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward cull=material(off) offset=material(0,0) diff --git a/crates/renderide/shaders/materials/pbsslicetransparent.wgsl b/crates/renderide/shaders/materials/pbsslicetransparent.wgsl index 61df357e5..ff4b2523b 100644 --- a/crates/renderide/shaders/materials/pbsslicetransparent.wgsl +++ b/crates/renderide/shaders/materials/pbsslicetransparent.wgsl @@ -22,6 +22,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::material::variant_bits as vb #import renderide::pbs::families::slice as pslice @@ -100,6 +101,7 @@ fn sample_albedo_color(uv_main: vec2, edge_lerp: f32) -> vec4 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -107,12 +109,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldObjectVertexOutput { #ifdef MULTIVIEW - return mv::world_object_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_object_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_transparent blend=transparent_material zwrite=material(off) cull=material(off) color_mask=material(rgba) offset=material(0,0) diff --git a/crates/renderide/shaders/materials/pbsslicetransparentspecular.wgsl b/crates/renderide/shaders/materials/pbsslicetransparentspecular.wgsl index 99531a0b6..0d82f956c 100644 --- a/crates/renderide/shaders/materials/pbsslicetransparentspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsslicetransparentspecular.wgsl @@ -23,6 +23,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::material::variant_bits as vb #import renderide::pbs::families::slice as pslice @@ -99,6 +100,7 @@ fn sample_albedo_color(uv_main: vec2, edge_lerp: f32) -> vec4 { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -106,12 +108,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldObjectVertexOutput { #ifdef MULTIVIEW - return mv::world_object_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_object_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_object_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_transparent blend=transparent_material zwrite=material(off) cull=material(off) color_mask=material(rgba) offset=material(0,0) diff --git a/crates/renderide/shaders/materials/pbsspecular.wgsl b/crates/renderide/shaders/materials/pbsspecular.wgsl index 1a5f968a7..c651f6fd1 100644 --- a/crates/renderide/shaders/materials/pbsspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsspecular.wgsl @@ -31,6 +31,7 @@ //#mat_default _Cutoff float 0.5 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::material::variant_bits as vb #import renderide::pbs::detail as pdet @@ -227,6 +228,7 @@ fn sample_surface(uv0: vec2, uv1: vec2, world_pos: vec3, world_n: @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -237,10 +239,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> mv::WorldUv2VertexOutput { #ifdef MULTIVIEW - return mv::world_uv2_vertex_main(instance_index, view_idx, pos, n, t, uv0, uv1); + let view_layer = view_idx; #else - return mv::world_uv2_vertex_main(instance_index, 0u, pos, n, t, uv0, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_uv2_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1, vertex_index); + } else { + return mv::world_uv2_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1); + } } //#pass type=forward a2c=cutout diff --git a/crates/renderide/shaders/materials/pbsstencil.wgsl b/crates/renderide/shaders/materials/pbsstencil.wgsl index 7ebc88930..ee31eaf3c 100644 --- a/crates/renderide/shaders/materials/pbsstencil.wgsl +++ b/crates/renderide/shaders/materials/pbsstencil.wgsl @@ -20,6 +20,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight @@ -104,6 +105,7 @@ fn sample_normal_world(uv_main: vec2, world_n: vec3, world_t: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } fn shade( diff --git a/crates/renderide/shaders/materials/pbsstencilspecular.wgsl b/crates/renderide/shaders/materials/pbsstencilspecular.wgsl index f8cca976d..aab6782db 100644 --- a/crates/renderide/shaders/materials/pbsstencilspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsstencilspecular.wgsl @@ -15,6 +15,7 @@ //#mat_default _NormalScale float 1.0 //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 +#import renderide::billboard::vertex as bv #import renderide::mesh::vertex as mv #import renderide::material::variant_bits as vb #import renderide::pbs::lighting as plight @@ -76,6 +77,7 @@ fn sample_normal_world(uv_main: vec2, world_n: vec3, world_t: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldVertexOutput { #ifdef MULTIVIEW - return mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return mv::world_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } fn shade( diff --git a/crates/renderide/shaders/materials/pbstriplanar.wgsl b/crates/renderide/shaders/materials/pbstriplanar.wgsl index e6c9c3844..0a7f5bca1 100644 --- a/crates/renderide/shaders/materials/pbstriplanar.wgsl +++ b/crates/renderide/shaders/materials/pbstriplanar.wgsl @@ -24,6 +24,7 @@ //#mat_default _TriBlendPower float 4.0 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::pbs::families::triplanar as ptri #import renderide::pbs::lighting as plight @@ -190,17 +191,26 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, + @location(2) uv0: vec2, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> ptri::VertexOutput { #ifdef MULTIVIEW - return ptri::vertex_main(instance_index, view_idx, pos, n, kw_OBJECTSPACE()); + let view_layer = view_idx; #else - return ptri::vertex_main(instance_index, 0u, pos, n, kw_OBJECTSPACE()); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return ptri::billboard_vertex_main(instance_index, view_layer, pos, n, vertex_index, uv0, t, uv1, kw_OBJECTSPACE()); + } else { + return ptri::vertex_main(instance_index, view_layer, pos, n, kw_OBJECTSPACE()); + } } /// Forward-base pass: ambient + directional lighting + emission. diff --git a/crates/renderide/shaders/materials/pbstriplanarspecular.wgsl b/crates/renderide/shaders/materials/pbstriplanarspecular.wgsl index 0028e2ff7..72b4eb973 100644 --- a/crates/renderide/shaders/materials/pbstriplanarspecular.wgsl +++ b/crates/renderide/shaders/materials/pbstriplanarspecular.wgsl @@ -20,6 +20,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _TriBlendPower float 4.0 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::pbs::families::triplanar as ptri #import renderide::pbs::lighting as plight @@ -180,17 +181,26 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, + @location(2) uv0: vec2, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> ptri::VertexOutput { #ifdef MULTIVIEW - return ptri::vertex_main(instance_index, view_idx, pos, n, kw_OBJECTSPACE()); + let view_layer = view_idx; #else - return ptri::vertex_main(instance_index, 0u, pos, n, kw_OBJECTSPACE()); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return ptri::billboard_vertex_main(instance_index, view_layer, pos, n, vertex_index, uv0, t, uv1, kw_OBJECTSPACE()); + } else { + return ptri::vertex_main(instance_index, view_layer, pos, n, kw_OBJECTSPACE()); + } } /// Forward-base pass: ambient + directional lighting + emission. diff --git a/crates/renderide/shaders/materials/pbstriplanartransparent.wgsl b/crates/renderide/shaders/materials/pbstriplanartransparent.wgsl index aaeff94d7..6351dcbc2 100644 --- a/crates/renderide/shaders/materials/pbstriplanartransparent.wgsl +++ b/crates/renderide/shaders/materials/pbstriplanartransparent.wgsl @@ -15,6 +15,7 @@ //#mat_default _TriBlendPower float 4.0 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::pbs::families::triplanar as ptri #import renderide::pbs::lighting as plight @@ -149,17 +150,26 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, + @location(2) uv0: vec2, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> ptri::VertexOutput { #ifdef MULTIVIEW - return ptri::vertex_main(instance_index, view_idx, pos, n, kw_OBJECTSPACE()); + let view_layer = view_idx; #else - return ptri::vertex_main(instance_index, 0u, pos, n, kw_OBJECTSPACE()); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return ptri::billboard_vertex_main(instance_index, view_layer, pos, n, vertex_index, uv0, t, uv1, kw_OBJECTSPACE()); + } else { + return ptri::vertex_main(instance_index, view_layer, pos, n, kw_OBJECTSPACE()); + } } //#pass type=forward name=forward_transparent blend=transparent_material zwrite=material(off) cull=material(off) color_mask=material(rgba) diff --git a/crates/renderide/shaders/materials/pbstriplanartransparentspecular.wgsl b/crates/renderide/shaders/materials/pbstriplanartransparentspecular.wgsl index 25c05c58a..247c72eef 100644 --- a/crates/renderide/shaders/materials/pbstriplanartransparentspecular.wgsl +++ b/crates/renderide/shaders/materials/pbstriplanartransparentspecular.wgsl @@ -15,6 +15,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _TriBlendPower float 4.0 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::pbs::families::triplanar as ptri #import renderide::pbs::lighting as plight @@ -146,17 +147,26 @@ fn sample_surface( @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, + @location(2) uv0: vec2, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> ptri::VertexOutput { #ifdef MULTIVIEW - return ptri::vertex_main(instance_index, view_idx, pos, n, kw_OBJECTSPACE()); + let view_layer = view_idx; #else - return ptri::vertex_main(instance_index, 0u, pos, n, kw_OBJECTSPACE()); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return ptri::billboard_vertex_main(instance_index, view_layer, pos, n, vertex_index, uv0, t, uv1, kw_OBJECTSPACE()); + } else { + return ptri::vertex_main(instance_index, view_layer, pos, n, kw_OBJECTSPACE()); + } } //#pass type=forward name=forward_transparent blend=transparent_material zwrite=material(off) cull=material(off) color_mask=material(rgba) diff --git a/crates/renderide/shaders/materials/pbsvertexcolortransparent.wgsl b/crates/renderide/shaders/materials/pbsvertexcolortransparent.wgsl index 7a76fb1da..8a9b27eef 100644 --- a/crates/renderide/shaders/materials/pbsvertexcolortransparent.wgsl +++ b/crates/renderide/shaders/materials/pbsvertexcolortransparent.wgsl @@ -19,6 +19,7 @@ //#mat_default _AlphaClip float 0.5 //#mat_default _Glossiness float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::core::math as rmath #import renderide::mesh::vertex as mv @@ -178,6 +179,7 @@ fn sample_surface(uv0: vec2, world_n: vec3, world_t: vec4, vertex @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -186,12 +188,18 @@ fn vs_main( @location(2) uv0: vec2, @location(3) color: vec4, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldColorVertexOutput { #ifdef MULTIVIEW - return mv::world_color_vertex_main(instance_index, view_idx, pos, n, t, uv0, color); + let view_layer = view_idx; #else - return mv::world_color_vertex_main(instance_index, 0u, pos, n, t, uv0, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color, vertex_index, uv1); + } else { + return mv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color); + } } //#pass type=forward name=forward_transparent_cull_back blend=transparent_material zwrite=material(off) cull=back color_mask=material(rgba) diff --git a/crates/renderide/shaders/materials/pbsvertexcolortransparentspecular.wgsl b/crates/renderide/shaders/materials/pbsvertexcolortransparentspecular.wgsl index 61af43721..bc338b9c2 100644 --- a/crates/renderide/shaders/materials/pbsvertexcolortransparentspecular.wgsl +++ b/crates/renderide/shaders/materials/pbsvertexcolortransparentspecular.wgsl @@ -20,6 +20,7 @@ //#mat_default _SpecularColor vec4 1.0 1.0 1.0 0.5 //#mat_default _AlphaClip float 0.5 +#import renderide::billboard::vertex as bv #import renderide::material::variant_bits as vb #import renderide::mesh::vertex as mv #import renderide::pbs::lighting as plight @@ -176,6 +177,7 @@ fn sample_surface(uv0: vec2, world_n: vec3, world_t: vec4, vertex @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -184,12 +186,18 @@ fn vs_main( @location(2) uv0: vec2, @location(3) color: vec4, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> mv::WorldColorVertexOutput { #ifdef MULTIVIEW - return mv::world_color_vertex_main(instance_index, view_idx, pos, n, t, uv0, color); + let view_layer = view_idx; #else - return mv::world_color_vertex_main(instance_index, 0u, pos, n, t, uv0, color); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return bv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color, vertex_index, uv1); + } else { + return mv::world_color_vertex_main(instance_index, view_layer, pos, n, t, uv0, color); + } } //#pass type=forward name=forward_transparent_cull_back blend=transparent_material zwrite=material(off) cull=back color_mask=material(rgba) diff --git a/crates/renderide/shaders/materials/pbsvoronoicrystal.wgsl b/crates/renderide/shaders/materials/pbsvoronoicrystal.wgsl index 089fb94f2..e74bf5341 100644 --- a/crates/renderide/shaders/materials/pbsvoronoicrystal.wgsl +++ b/crates/renderide/shaders/materials/pbsvoronoicrystal.wgsl @@ -22,12 +22,14 @@ //#mat_default _EdgeMetallic float 0.1 //#mat_default _EdgeThickness float 0.1 +#import renderide::billboard::vertex as bv #import renderide::draw::per_draw as pd #import renderide::mesh::vertex as mv #import renderide::pbs::normal as pnorm #import renderide::pbs::lighting as plight #import renderide::pbs::sampling as psamp #import renderide::pbs::surface as psurf +#import renderide::core::math as rmath #import renderide::core::uv as uvu #import renderide::core::normal_decode as nd #import renderide::material::voronoi as vor @@ -48,6 +50,7 @@ struct PbsVoronoiCrystalMaterial { _AnimationOffset: f32, _Glossiness: f32, _Metallic: f32, + _RenderideVariantBits: u32, } @group(1) @binding(0) var mat: PbsVoronoiCrystalMaterial; @@ -73,6 +76,7 @@ struct VertexOutput { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -80,16 +84,23 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> VertexOutput { +#ifdef MULTIVIEW + let view_layer = view_idx; +#else + let view_layer = 0u; +#endif + + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return billboard_vertex_main(instance_index, view_layer, pos, n, vertex_index, uv0, t, uv1); + } + let d = pd::get_draw(instance_index); let world_p = mv::world_position(d, pos); let wn = mv::world_normal(d, n); let wt = mv::world_tangent(d, t); -#ifdef MULTIVIEW - let vp = mv::select_view_proj(d, view_idx); -#else - let vp = mv::select_view_proj(d, 0u); -#endif + let vp = mv::select_view_proj(d, view_layer); var out: VertexOutput; out.clip_pos = vp * world_p; out.world_pos = world_p.xyz; @@ -97,11 +108,39 @@ fn vs_main( out.world_t = wt; out.uv = uv0; out.uv_normal = uvu::apply_st(uv0, mat._NormalMap_ST); -#ifdef MULTIVIEW + out.view_layer = mv::packed_view_layer(instance_index, view_layer); + return out; +} + +fn billboard_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + vertex_index: u32, + uv0: vec2, + tangent: vec4, + uv1: vec2, +) -> VertexOutput { + let d = pd::get_draw(instance_index); + + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_idx, pos, vertex_index, n, tangent, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + let vp = mv::select_view_proj(d, view_idx); + + var out: VertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(d, vec4(billboard_n, 0.0), view_idx).xyz; + out.world_t = mv::world_tangent_for_view(d, vec4(billboard_t, 0.0), view_idx); + out.uv = uv0; + out.uv_normal = uvu::apply_st(uv0, mat._NormalMap_ST); out.view_layer = mv::packed_view_layer(instance_index, view_idx); -#else - out.view_layer = mv::packed_view_layer(instance_index, 0u); -#endif return out; } diff --git a/crates/renderide/shaders/materials/pixelate.wgsl b/crates/renderide/shaders/materials/pixelate.wgsl index 85bc4fdbf..7f3662974 100644 --- a/crates/renderide/shaders/materials/pixelate.wgsl +++ b/crates/renderide/shaders/materials/pixelate.wgsl @@ -10,6 +10,7 @@ //#texture_default _ResolutionTex white //#mat_default _Resolution vec4 100.0 100.0 0.0 0.0 +#import renderide::billboard::vertex as bv #import renderide::post::filter_math as fm #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc @@ -48,6 +49,7 @@ fn kw_RESOLUTION_TEX() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -55,12 +57,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/posterize.wgsl b/crates/renderide/shaders/materials/posterize.wgsl index 7f41fa808..f5e71e30a 100644 --- a/crates/renderide/shaders/materials/posterize.wgsl +++ b/crates/renderide/shaders/materials/posterize.wgsl @@ -6,6 +6,7 @@ //#render_queue Transparent+500 //#mat_default _Levels float 10.0 +#import renderide::billboard::vertex as bv #import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::material::variant_bits as vb @@ -32,6 +33,7 @@ fn kw_RECTCLIP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -39,12 +41,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::RectVertexOutput { #ifdef MULTIVIEW - return fv::rect_vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fv::rect_vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::rect_vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/reflection.wgsl b/crates/renderide/shaders/materials/reflection.wgsl index 5f24b42dd..21fd98543 100644 --- a/crates/renderide/shaders/materials/reflection.wgsl +++ b/crates/renderide/shaders/materials/reflection.wgsl @@ -14,6 +14,7 @@ //#mat_default _Color vec4 1.0 1.0 1.0 1.0 //#mat_default _Cutoff float 0.5 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::draw::per_draw as pd #import renderide::material::alpha as ma @@ -66,26 +67,37 @@ struct VertexOutput { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, - @location(1) _n: vec4, + @location(1) n: vec4, @location(2) uv: vec2, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> VertexOutput { - let d = pd::get_draw(instance_index); - let world_p = mv::world_position(d, pos); #ifdef MULTIVIEW - let vp = mv::select_view_proj(d, view_idx); + let view_layer = view_idx; #else - let vp = mv::select_view_proj(d, 0u); + let view_layer = 0u; #endif + let d = pd::get_draw(instance_index); + let vp = mv::select_view_proj(d, view_layer); + + var world_p: vec4; + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_layer, pos, vertex_index, n, t, uv1, + ); + world_p = render_billboard_vertex.world_pos; + } else { + world_p = mv::world_position(d, pos); + } let clip = vp * world_p; #ifdef MULTIVIEW - let view_layer = view_idx; let screen_y = (clip.y + clip.w) * 0.5; #else - let view_layer = 0u; let screen_y = (clip.w - clip.y) * 0.5; #endif var out: VertexOutput; diff --git a/crates/renderide/shaders/materials/refract.wgsl b/crates/renderide/shaders/materials/refract.wgsl index df3a625af..b3ea38dfb 100644 --- a/crates/renderide/shaders/materials/refract.wgsl +++ b/crates/renderide/shaders/materials/refract.wgsl @@ -9,6 +9,8 @@ //#mat_default _NormalMap_LodBias float 0.0 //#mat_default _RefractionStrength float 0.01 +#import renderide::billboard::vertex as bv +#import renderide::post::filter_vertex as fv #import renderide::post::filter_common as fc #import renderide::post::filter_refraction as fr #import renderide::frame::grab_pass as gp @@ -47,6 +49,7 @@ fn kw_NORMALMAP() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -54,12 +57,18 @@ fn vs_main( @location(1) n: vec4, @location(2) uv0: vec2, @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fr::VertexOutput { #ifdef MULTIVIEW - return fr::vertex_main(instance_index, view_idx, pos, n, t, uv0); + let view_layer = view_idx; #else - return fr::vertex_main(instance_index, 0u, pos, n, t, uv0); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fr::billboard_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fr::vertex_main(instance_index, view_layer, pos, n, t, uv0); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/threshold.wgsl b/crates/renderide/shaders/materials/threshold.wgsl index 8f31e2cea..fa2abccba 100644 --- a/crates/renderide/shaders/materials/threshold.wgsl +++ b/crates/renderide/shaders/materials/threshold.wgsl @@ -10,6 +10,7 @@ //#mat_default _Threshold float 0.5 //#mat_default _Transition float 0.01 +#import renderide::billboard::vertex as bv #import renderide::post::filter_common as fc #import renderide::post::filter_vertex as fv #import renderide::material::variant_bits as vb @@ -32,16 +33,26 @@ fn threshold_kw(mask: u32) -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, + @location(1) n: vec4, + @location(2) uv0: vec2, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> fv::PositionRectVertexOutput { #ifdef MULTIVIEW - return fv::position_rect_vertex_main(instance_index, view_idx, pos); + let view_layer = view_idx; #else - return fv::position_rect_vertex_main(instance_index, 0u, pos); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return fv::billboard_position_rect_vertex_main(instance_index, view_layer, pos, n, t, uv0, vertex_index, uv1); + } else { + return fv::position_rect_vertex_main(instance_index, view_layer, pos); + } } //#pass type=forward name=forward_filter blend=material_filter diff --git a/crates/renderide/shaders/materials/unlit.wgsl b/crates/renderide/shaders/materials/unlit.wgsl index a2db8e7bb..9438a988b 100644 --- a/crates/renderide/shaders/materials/unlit.wgsl +++ b/crates/renderide/shaders/materials/unlit.wgsl @@ -21,6 +21,7 @@ //#mat_default _PolarPow float 1.0 //#mat_default _Cutoff float 0.5 +#import renderide::billboard::vertex as bv #import renderide::core::texture_sampling as ts #import renderide::frame::globals as rg #import renderide::material::alpha as ma @@ -79,16 +80,18 @@ struct VertexOutput { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, - @location(1) _n: vec4, + @location(1) n: vec4, @location(2) uv: vec2, @location(3) color: vec4, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> VertexOutput { let d = pd::get_draw(instance_index); - let world_p = mv::world_position(d, pos); #ifdef MULTIVIEW let view_layer = view_idx; #else @@ -96,6 +99,16 @@ fn vs_main( #endif let vp = mv::select_view_proj(d, view_layer); + var world_p: vec4; + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_layer, pos, vertex_index, n, t, uv1, + ); + world_p = render_billboard_vertex.world_pos; + } else { + world_p = mv::world_position(d, pos); + } + var out: VertexOutput; out.clip_pos = vp * world_p; out.uv = uv; diff --git a/crates/renderide/shaders/materials/unlitdistancelerp.wgsl b/crates/renderide/shaders/materials/unlitdistancelerp.wgsl index f61cb80ee..f2423d5b6 100644 --- a/crates/renderide/shaders/materials/unlitdistancelerp.wgsl +++ b/crates/renderide/shaders/materials/unlitdistancelerp.wgsl @@ -14,6 +14,7 @@ //#mat_default _Transition float 0.1 //#mat_default _Cutoff float 0.5 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::draw::per_draw as pd #import renderide::material::variant_bits as vb @@ -59,21 +60,34 @@ struct VertexOutput { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, - @location(1) _n: vec4, + @location(1) n: vec4, @location(2) uv: vec2, @location(3) color: vec4, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> VertexOutput { let d = pd::get_draw(instance_index); - let world_p = mv::world_position(d, pos); #ifdef MULTIVIEW - let vp = mv::select_view_proj(d, view_idx); + let view_layer = view_idx; #else - let vp = mv::select_view_proj(d, 0u); + let view_layer = 0u; #endif + let vp = mv::select_view_proj(d, view_layer); + + var world_p: vec4; + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_layer, pos, vertex_index, n, t, uv1, + ); + world_p = render_billboard_vertex.world_pos; + } else { + world_p = mv::world_position(d, pos); + } var out: VertexOutput; out.clip_pos = vp * world_p; diff --git a/crates/renderide/shaders/materials/wireframe.wgsl b/crates/renderide/shaders/materials/wireframe.wgsl index 16910779d..44caded23 100644 --- a/crates/renderide/shaders/materials/wireframe.wgsl +++ b/crates/renderide/shaders/materials/wireframe.wgsl @@ -10,6 +10,7 @@ //#mat_default _Exp float 1.0 //#mat_default _Thickness float 1.0 +#import renderide::billboard::vertex as bv #import renderide::core::texture_sampling as ts #import renderide::core::uv as uvu #import renderide::draw::per_draw as pd @@ -37,14 +38,6 @@ const WIREFRAME_KW_SCREENSPACE: u32 = 1u << 1u; @group(1) @binding(1) var _MainTex: texture_2d; @group(1) @binding(2) var _MainTex_sampler: sampler; -struct VertexOutput { - @builtin(position) clip_pos: vec4, - @location(0) world_pos: vec3, - @location(1) world_n: vec3, - @location(2) uv: vec2, - @location(3) @interpolate(flat) view_layer: u32, -} - fn wireframe_kw(mask: u32) -> bool { return vb::enabled(mat._RenderideVariantBits, mask); } @@ -60,32 +53,29 @@ fn kw_SCREENSPACE() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, -) -> VertexOutput { - let draw = pd::get_draw(instance_index); - let world_p = mv::world_position(draw, pos); + @location(4) t: vec4, + @location(5) uv1: vec2, +) -> wf::VertexOutput { #ifdef MULTIVIEW let layer = view_idx; #else let layer = 0u; #endif - let vp = mv::select_view_proj(draw, layer); - - var out: VertexOutput; - out.clip_pos = vp * world_p; - out.world_pos = world_p.xyz; - out.world_n = mv::world_normal(draw, n); - out.uv = uvu::apply_st(uv0, mat._MainTex_ST); - out.view_layer = (instance_index << 1u) | (layer & 1u); - return out; + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return wf::billboard_vs_main(instance_index, layer, vertex_index, pos, n, uv0, t, uv1, mat._MainTex_ST); + } else { + return wf::vs_main(instance_index, layer, pos, n, uv0, mat._MainTex_ST); + } } -fn wireframe_color(in: VertexOutput, edge: f32) -> vec4 { +fn wireframe_color(in: wf::VertexOutput, edge: f32) -> vec4 { var fill_color = mat._FillColor; var line_color = mat._LineColor; if (kw_FRESNEL()) { @@ -100,7 +90,7 @@ fn wireframe_color(in: VertexOutput, edge: f32) -> vec4 { //#pass type=forward blend=alpha zwrite=material(off) ztest=main cull=back color_mask=rgba offset=material(0,0) @fragment fn fs_main( - in: VertexOutput, + in: wf::VertexOutput, @builtin(barycentric) barycentric: vec3, ) -> @location(0) vec4 { let edge = wf::unity_edge_lerp(barycentric, in.world_pos, mat._Thickness, kw_SCREENSPACE()); diff --git a/crates/renderide/shaders/materials/wireframedoublesided.wgsl b/crates/renderide/shaders/materials/wireframedoublesided.wgsl index bf5b4cc2f..9e986889d 100644 --- a/crates/renderide/shaders/materials/wireframedoublesided.wgsl +++ b/crates/renderide/shaders/materials/wireframedoublesided.wgsl @@ -14,6 +14,7 @@ //#mat_default _Exp float 1.0 //#mat_default _Thickness float 1.0 +#import renderide::billboard::vertex as bv #import renderide::core::texture_sampling as ts #import renderide::core::uv as uvu #import renderide::draw::per_draw as pd @@ -45,14 +46,6 @@ const WIREFRAME_KW_SCREENSPACE: u32 = 1u << 1u; @group(1) @binding(1) var _MainTex: texture_2d; @group(1) @binding(2) var _MainTex_sampler: sampler; -struct VertexOutput { - @builtin(position) clip_pos: vec4, - @location(0) world_pos: vec3, - @location(1) world_n: vec3, - @location(2) uv: vec2, - @location(3) @interpolate(flat) view_layer: u32, -} - fn wireframe_kw(mask: u32) -> bool { return vb::enabled(mat._RenderideVariantBits, mask); } @@ -68,32 +61,29 @@ fn kw_SCREENSPACE() -> bool { @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, @location(1) n: vec4, @location(2) uv0: vec2, -) -> VertexOutput { - let draw = pd::get_draw(instance_index); - let world_p = mv::world_position(draw, pos); + @location(4) t: vec4, + @location(5) uv1: vec2, +) -> wf::VertexOutput { #ifdef MULTIVIEW let layer = view_idx; #else let layer = 0u; #endif - let vp = mv::select_view_proj(draw, layer); - - var out: VertexOutput; - out.clip_pos = vp * world_p; - out.world_pos = world_p.xyz; - out.world_n = mv::world_normal(draw, n); - out.uv = uvu::apply_st(uv0, mat._MainTex_ST); - out.view_layer = (instance_index << 1u) | (layer & 1u); - return out; + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + return wf::billboard_vs_main(instance_index, layer, vertex_index, pos, n, uv0, t, uv1, mat._MainTex_ST); + } else { + return wf::vs_main(instance_index, layer, pos, n, uv0, mat._MainTex_ST); + } } -fn pass_color(in: VertexOutput, edge: f32, inner: bool) -> vec4 { +fn pass_color(in: wf::VertexOutput, edge: f32, inner: bool) -> vec4 { var fill_color = mat._FillColor; var line_color = mat._LineColor; if (inner) { @@ -115,7 +105,7 @@ fn pass_color(in: VertexOutput, edge: f32, inner: bool) -> vec4 { return mix(fill_color, line_color, edge); } -fn fragment_wire(in: VertexOutput, barycentric: vec3, inner: bool) -> vec4 { +fn fragment_wire(in: wf::VertexOutput, barycentric: vec3, inner: bool) -> vec4 { let edge = wf::unity_edge_lerp(barycentric, in.world_pos, mat._Thickness, kw_SCREENSPACE()); let tex = ts::sample_tex_2d(_MainTex, _MainTex_sampler, in.uv, mat._MainTex_LodBias); return rg::retain_globals_additive(pass_color(in, edge, inner) * tex); @@ -124,7 +114,7 @@ fn fragment_wire(in: VertexOutput, barycentric: vec3, inner: bool) -> vec4< //#pass type=forward name=inner blend=alpha zwrite=material(off) ztest=main cull=front color_mask=rgba offset=material(0,0) @fragment fn fs_inner( - in: VertexOutput, + in: wf::VertexOutput, @builtin(barycentric) barycentric: vec3, ) -> @location(0) vec4 { return fragment_wire(in, barycentric, true); @@ -133,7 +123,7 @@ fn fs_inner( //#pass type=forward name=outer blend=alpha zwrite=material(off) ztest=main cull=back color_mask=rgba offset=material(0,0) @fragment fn fs_outer( - in: VertexOutput, + in: wf::VertexOutput, @builtin(barycentric) barycentric: vec3, ) -> @location(0) vec4 { return fragment_wire(in, barycentric, false); diff --git a/crates/renderide/shaders/materials/wireframeunlittransition.wgsl b/crates/renderide/shaders/materials/wireframeunlittransition.wgsl index deaf39592..c50f9fca5 100644 --- a/crates/renderide/shaders/materials/wireframeunlittransition.wgsl +++ b/crates/renderide/shaders/materials/wireframeunlittransition.wgsl @@ -14,6 +14,7 @@ //#mat_default _WireTransitionExp float 1.0 //#mat_default _WirePlaneOffset float 0.0 +#import renderide::billboard::vertex as bv #import renderide::core::math as rmath #import renderide::core::texture_sampling as ts #import renderide::core::uv as uvu @@ -34,6 +35,7 @@ struct WireframeUnlitTransitionMaterial { _WireTransitionRange: f32, _WireTransitionExp: f32, _WirePlaneOffset: f32, + _RenderideVariantBits: u32, _MainTex_LodBias: f32, } @@ -66,20 +68,32 @@ fn transition_lerp(distance: f32, offset: f32, range: f32, exponent: f32, invert @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @location(0) pos: vec4, + @location(1) n: vec4, @location(2) uv0: vec2, + @location(4) t: vec4, + @location(5) uv1: vec2, ) -> VertexOutput { - let draw = pd::get_draw(instance_index); - let world_p = mv::world_position(draw, pos); #ifdef MULTIVIEW let layer = view_idx; #else let layer = 0u; #endif + let draw = pd::get_draw(instance_index); let vp = mv::select_view_proj(draw, layer); + var world_p: vec4; + if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits)) { + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + draw, layer, pos, vertex_index, n, t, uv1, + ); + world_p = render_billboard_vertex.world_pos; + } else { + world_p = mv::world_position(draw, pos); + } var out: VertexOutput; out.clip_pos = vp * world_p; diff --git a/crates/renderide/shaders/materials/xstoon2.0-cutout.wgsl b/crates/renderide/shaders/materials/xstoon2.0-cutout.wgsl index bda1e6869..913558873 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-cutout.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-cutout.wgsl @@ -38,6 +38,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -48,6 +49,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,10 +61,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward a2c=cutout diff --git a/crates/renderide/shaders/materials/xstoon2.0-cutouta2c-outlined.wgsl b/crates/renderide/shaders/materials/xstoon2.0-cutouta2c-outlined.wgsl index 32b8ce7f5..58ed7401d 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-cutouta2c-outlined.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-cutouta2c-outlined.wgsl @@ -39,6 +39,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -50,6 +51,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -61,15 +63,21 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } @vertex fn vs_outline( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -81,10 +89,15 @@ fn vs_outline( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xo::vertex_outline(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xo::vertex_outline(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xo::vertex_outline(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward name=outline cull=front vs=vs_outline a2c=true diff --git a/crates/renderide/shaders/materials/xstoon2.0-cutouta2c.wgsl b/crates/renderide/shaders/materials/xstoon2.0-cutouta2c.wgsl index 8608f78dd..0a2e6ae7c 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-cutouta2c.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-cutouta2c.wgsl @@ -38,6 +38,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -48,6 +49,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,10 +61,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward a2c=true diff --git a/crates/renderide/shaders/materials/xstoon2.0-cutouta2cmasked.wgsl b/crates/renderide/shaders/materials/xstoon2.0-cutouta2cmasked.wgsl index 7116df512..20f7bebfa 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-cutouta2cmasked.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-cutouta2cmasked.wgsl @@ -38,6 +38,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -48,6 +49,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,10 +61,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward a2c=true diff --git a/crates/renderide/shaders/materials/xstoon2.0-dithered-outlined.wgsl b/crates/renderide/shaders/materials/xstoon2.0-dithered-outlined.wgsl index cb5d20afe..2087fedab 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-dithered-outlined.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-dithered-outlined.wgsl @@ -39,6 +39,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -50,6 +51,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -61,15 +63,21 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } @vertex fn vs_outline( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -81,10 +89,15 @@ fn vs_outline( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xo::vertex_outline(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xo::vertex_outline(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xo::vertex_outline(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward name=outline cull=front vs=vs_outline diff --git a/crates/renderide/shaders/materials/xstoon2.0-dithered.wgsl b/crates/renderide/shaders/materials/xstoon2.0-dithered.wgsl index b71c2ae67..a88bfb4a4 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-dithered.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-dithered.wgsl @@ -38,6 +38,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -48,6 +49,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,10 +61,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward diff --git a/crates/renderide/shaders/materials/xstoon2.0-fade.wgsl b/crates/renderide/shaders/materials/xstoon2.0-fade.wgsl index cd804bef7..22b94b3ba 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-fade.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-fade.wgsl @@ -38,6 +38,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -48,6 +49,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,10 +61,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward name=forward_alpha_blend blend=alpha zwrite=off ztest=main color_mask=rgba offset=0,0 diff --git a/crates/renderide/shaders/materials/xstoon2.0-outlined.wgsl b/crates/renderide/shaders/materials/xstoon2.0-outlined.wgsl index d8d59f43c..072e47b9c 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-outlined.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-outlined.wgsl @@ -43,6 +43,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -54,6 +55,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -65,15 +67,21 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } @vertex fn vs_outline( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -85,10 +93,15 @@ fn vs_outline( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xo::vertex_outline(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xo::vertex_outline(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xo::vertex_outline(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward name=outline cull=front vs=vs_outline a2c=cutout diff --git a/crates/renderide/shaders/materials/xstoon2.0-transparent.wgsl b/crates/renderide/shaders/materials/xstoon2.0-transparent.wgsl index ac91e7c87..4453d003d 100644 --- a/crates/renderide/shaders/materials/xstoon2.0-transparent.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0-transparent.wgsl @@ -38,6 +38,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -48,6 +49,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,10 +61,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward name=forward_premultiplied_transparent blend=premul zwrite=off ztest=main color_mask=rgba offset=0,0 diff --git a/crates/renderide/shaders/materials/xstoon2.0.wgsl b/crates/renderide/shaders/materials/xstoon2.0.wgsl index e07d6ddad..927a9cd5d 100644 --- a/crates/renderide/shaders/materials/xstoon2.0.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0.wgsl @@ -37,6 +37,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -46,6 +47,7 @@ const XIEE_ALPHA_MODE: u32 = 0u; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -57,10 +59,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward a2c=cutout diff --git a/crates/renderide/shaders/materials/xstoon2.0_outlined.wgsl b/crates/renderide/shaders/materials/xstoon2.0_outlined.wgsl index 11ecb96c6..aee1d10bc 100644 --- a/crates/renderide/shaders/materials/xstoon2.0_outlined.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0_outlined.wgsl @@ -43,6 +43,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb #import renderide::xiexe::toon2::variant_bits as xvb @@ -53,6 +54,7 @@ const XIEE_ALPHA_MODE: u32 = 0u; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -64,15 +66,21 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } @vertex fn vs_outline( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -84,10 +92,15 @@ fn vs_outline( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xo::vertex_outline(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xo::vertex_outline(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xo::vertex_outline(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward name=outline cull=front vs=vs_outline a2c=cutout diff --git a/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride.wgsl b/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride.wgsl index f98885750..ce8833121 100644 --- a/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride.wgsl @@ -37,6 +37,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::mesh::wireframe as wf #import renderide::xiexe::toon2 as xs #import renderide::xiexe::toon2::base as xb @@ -48,6 +49,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -59,10 +61,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward cull=material(back) diff --git a/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride_a2c.wgsl b/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride_a2c.wgsl index 725e967a3..142a531dc 100644 --- a/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride_a2c.wgsl +++ b/crates/renderide/shaders/materials/xstoon2.0_wireframeoverride_a2c.wgsl @@ -38,6 +38,7 @@ //#mat_default _SSPower float 1.0 //#mat_default _SSScale float 1.0 +#import renderide::billboard::vertex as bv #import renderide::frame::globals as rg #import renderide::mesh::wireframe as wf #import renderide::xiexe::toon2 as xs @@ -50,6 +51,7 @@ const XIEE_KEYWORD_LAYOUT: u32 = xvb::XTOON_KEYWORD_LAYOUT_STATIC_VERTEXLIGHT; @vertex fn vs_main( @builtin(instance_index) instance_index: u32, + @builtin(vertex_index) vertex_index: u32, #ifdef MULTIVIEW @builtin(view_index) view_idx: u32, #endif @@ -61,10 +63,15 @@ fn vs_main( @location(5) uv1: vec2, ) -> xb::VertexOutput { #ifdef MULTIVIEW - return xs::vertex_main(instance_index, view_idx, pos, n, uv0, color, tangent, uv1); + let view_layer = view_idx; #else - return xs::vertex_main(instance_index, 0u, pos, n, uv0, color, tangent, uv1); + let view_layer = 0u; #endif + if (bv::kw_RENDER_BUFFER(xb::mat._RenderideVariantBits)) { + return xs::billboard_vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1, vertex_index); + } else { + return xs::vertex_main(instance_index, view_layer, pos, n, uv0, color, tangent, uv1); + } } //#pass type=forward cull=material(back) a2c=true diff --git a/crates/renderide/shaders/modules/billboard/vertex.wgsl b/crates/renderide/shaders/modules/billboard/vertex.wgsl new file mode 100644 index 000000000..83991fde4 --- /dev/null +++ b/crates/renderide/shaders/modules/billboard/vertex.wgsl @@ -0,0 +1,395 @@ +//! Vertex generation methods for billboard materials + +#define_import_path renderide::billboard::vertex + +#import renderide::core::math as rmath +#import renderide::frame::globals as rg +#import renderide::draw::per_draw as pd +#import renderide::draw::types as dt +#import renderide::material::variant_bits as vb +#import renderide::mesh::billboard as mb +#import renderide::mesh::vertex as mv + +const BILLBOARD_KW_RENDER_BUFFER: u32 = 1u << 24u; + +struct RenderBufferBillboardBasis { + right: vec3, + up: vec3, +} + +struct RenderBufferBillboardVertex { + world_pos: vec4, + axes: RenderBufferBillboardBasis, + corner: vec2, + size: vec2, +} + +fn kw_RENDER_BUFFER(variant_bits: u32) -> bool { + return vb::enabled(variant_bits, BILLBOARD_KW_RENDER_BUFFER); +} + +fn render_buffer_billboard_vertex( + draw: dt::PerDrawUniforms, + view_layer: u32, + pos: vec4, + vertex_index: u32, + pointdata: vec4, + point_forward_upz: vec4, + point_up_xy: vec2, +) -> RenderBufferBillboardVertex { + let center_world = mv::world_position(draw, pos).xyz; + let axes = render_buffer_billboard_basis(draw, center_world, pointdata, point_forward_upz, point_up_xy, view_layer); + let corner = render_buffer_billboard_corner_for_vertex(vertex_index); + let unclamped_size = render_buffer_billboard_size(pointdata.xy, draw.model); + let vp = mv::select_view_proj(draw, view_layer); + let size = screen_clamped_billboard_size(draw, center_world, axes, unclamped_size, vp); + var vertex = RenderBufferBillboardVertex(vec4(0.0), axes, corner, size); + vertex.world_pos = vec4(billboard_center_world_to_world_pos(center_world, vertex), 1.0); + return vertex; +} + +fn billboard_center_world_to_world_pos(center_world: vec3, vertex: RenderBufferBillboardVertex) -> vec3 { + let axes = vertex.axes; + let corner = vertex.corner; + let size = vertex.size; + return center_world + axes.right * (corner.x * size.x) + axes.up * (corner.y * size.y); +} + +fn rotate_render_buffer_axes(angle: f32, right: vec3, up: vec3) -> RenderBufferBillboardBasis { + let c = cos(angle); + let s = sin(angle); + return RenderBufferBillboardBasis(right * c - up * s, right * s + up * c); +} + +fn view_plane_basis(view_layer: u32, roll: f32) -> RenderBufferBillboardBasis { + let view_up = rmath::safe_normalize(rg::view_to_world_y_coeffs_for_view(view_layer).xyz, vec3(0.0, 1.0, 0.0)); + let to_camera = rg::orthographic_view_dir_for_view(view_layer); + var right = rmath::safe_normalize(cross(view_up, to_camera), vec3(1.0, 0.0, 0.0)); + var up = rmath::safe_normalize(cross(to_camera, right), view_up); + if (abs(roll) > 1e-4) { + let rotated = rotate_render_buffer_axes(roll, right, up); + right = rotated.right; + up = rotated.up; + } + return RenderBufferBillboardBasis(right, up); +} + +fn facing_basis(center_world: vec3, view_layer: u32, roll: f32) -> RenderBufferBillboardBasis { + let view_up = rmath::safe_normalize(rg::view_to_world_y_coeffs_for_view(view_layer).xyz, vec3(0.0, 1.0, 0.0)); + let to_camera = rg::view_dir_for_world_pos(center_world, view_layer); + var right = rmath::safe_normalize(cross(view_up, to_camera), vec3(1.0, 0.0, 0.0)); + var up = rmath::safe_normalize(cross(to_camera, right), view_up); + if (abs(roll) > 1e-4) { + let rotated = rotate_render_buffer_axes(roll, right, up); + right = rotated.right; + up = rotated.up; + } + return RenderBufferBillboardBasis(right, up); +} + +fn direction_stretch_particle_basis( + draw: dt::PerDrawUniforms, + center_world: vec3, + point_forward_upz: vec4, + view_layer: u32, +) -> RenderBufferBillboardBasis { + let to_camera = rg::view_dir_for_world_pos(center_world, view_layer); + let velocity_world = mv::model_vector(draw, point_forward_upz.xyz); + let velocity_in_plane = velocity_world - to_camera * dot(velocity_world, to_camera); + let view_up = rg::view_to_world_y_coeffs_for_view(view_layer).xyz; + let view_up_in_plane = view_up - to_camera * dot(view_up, to_camera); + var up = rmath::safe_normalize( + velocity_in_plane, + rmath::safe_normalize(view_up_in_plane, vec3(0.0, 1.0, 0.0)), + ); + let right = rmath::safe_normalize(cross(up, to_camera), vec3(1.0, 0.0, 0.0)); + up = rmath::safe_normalize(cross(to_camera, right), up); + return RenderBufferBillboardBasis(right, up); +} + +fn local_particle_basis( + draw: dt::PerDrawUniforms, + roll: f32, + point_forward_upz: vec4, + point_up_xy: vec2, +) -> RenderBufferBillboardBasis { + let raw_forward = rmath::safe_normalize(point_forward_upz.xyz, vec3(0.0, 0.0, 1.0)); + let raw_up = rmath::safe_normalize(vec3(point_up_xy, point_forward_upz.w), vec3(0.0, 1.0, 0.0)); + let world_forward = rmath::safe_normalize(mv::model_vector(draw, raw_forward), vec3(0.0, 0.0, 1.0)); + let world_up = rmath::safe_normalize(mv::model_vector(draw, raw_up), vec3(0.0, 1.0, 0.0)); + var right = rmath::safe_normalize(cross(world_forward, world_up), vec3(1.0, 0.0, 0.0)); + var up = rmath::safe_normalize(cross(right, world_forward), world_up); + if (abs(roll) > 1e-4) { + let rotated = rotate_render_buffer_axes(roll, right, up); + right = rotated.right; + up = rotated.up; + } + return RenderBufferBillboardBasis(right, up); +} + +fn render_buffer_billboard_basis( + draw: dt::PerDrawUniforms, + center_world: vec3, + pointdata: vec4, + point_forward_upz: vec4, + point_up_xy: vec2, + view_layer: u32, +) -> RenderBufferBillboardBasis { + let alignment = pd::particle_alignment(draw); + if (alignment == 1u) { + return facing_basis(center_world, view_layer, pointdata.z); + } + if (alignment == 2u || alignment == 3u) { + return local_particle_basis(draw, pointdata.z, point_forward_upz, point_up_xy); + } + if (alignment == 4u) { + return direction_stretch_particle_basis(draw, center_world, point_forward_upz, view_layer); + } + return view_plane_basis(view_layer, pointdata.z); +} + +fn ndc_xy(clip: vec4) -> vec2 { + return clip.xy / max(abs(clip.w), 1e-6); +} + +fn screen_clamped_billboard_size( + draw: dt::PerDrawUniforms, + center_world: vec3, + axes: RenderBufferBillboardBasis, + size: vec2, + vp: mat4x4, +) -> vec2 { + let min_size = pd::particle_min_screen_size(draw); + let max_size = pd::particle_max_screen_size(draw); + if (min_size <= 0.0 && max_size <= 0.0) { + return size; + } + let viewport = max(rg::viewport_size(), vec2(1.0, 1.0)); + let center_ndc = ndc_xy(vp * vec4(center_world, 1.0)); + let right_ndc = ndc_xy(vp * vec4(center_world + axes.right * size.x, 1.0)); + let up_ndc = ndc_xy(vp * vec4(center_world + axes.up * size.y, 1.0)); + let right_pixels = length((right_ndc - center_ndc) * viewport * 0.5); + let up_pixels = length((up_ndc - center_ndc) * viewport * 0.5); + let screen_fraction = max(right_pixels, up_pixels) / max(min(viewport.x, viewport.y), 1.0); + if (screen_fraction <= 1e-6) { + return size; + } + var scale = 1.0; + if (min_size > 0.0 && screen_fraction < min_size) { + scale = max(scale, min_size / screen_fraction); + } + if (max_size > 0.0 && screen_fraction * scale > max_size) { + scale = max_size / screen_fraction; + } + return max(size * scale, vec2(1e-6, 1e-6)); +} + +fn render_buffer_billboard_unit_corner(vertex_index: u32) -> vec2 { + let corner = vertex_index % 4u; + return vec2( + select(0.0, 1.0, (corner & 1u) != 0u), + select(0.0, 1.0, (corner & 2u) != 0u), + ); +} + +fn render_buffer_billboard_size(scale: vec2, model: mat4x4) -> vec2 { + return max(abs(scale), vec2(1e-6, 1e-6)) * mb::model_uniform_scale(model); +} + +fn render_buffer_billboard_corner_for_vertex(vertex_index: u32) -> vec2 { + return render_buffer_billboard_unit_corner(vertex_index) * 2.0 - vec2(1.0, 1.0); +} + +///////////////////////////////////////// +/// renderide::mesh::vertex overloads /// +///////////////////////////////////////// + +fn world_color_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + color: vec4, + vertex_index: u32, + uv1: vec2, +) -> mv::WorldColorVertexOutput { + let draw = pd::get_draw(instance_index); + let vp = mv::select_view_proj(draw, view_idx); + + let render_billboard_vertex = render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + + var out: mv::WorldColorVertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(draw, vec4(billboard_n, 0.0), view_idx); + out.world_t = mv::world_tangent_for_view(draw, vec4(billboard_t, 0.0), view_idx); + out.color = color * dt::particle_color(draw); + out.primary_uv = primary_uv; + out.view_layer = mv::packed_view_layer(instance_index, view_idx); + return out; +} + +fn world_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + vertex_index: u32, + uv1: vec2, +) -> mv::WorldVertexOutput { + let draw = pd::get_draw(instance_index); + let vp = mv::select_view_proj(draw, view_idx); + + let render_billboard_vertex = render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + + var out: mv::WorldVertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(draw, vec4(billboard_n, 0.0), view_idx); + out.world_t = mv::world_tangent_for_view(draw, vec4(billboard_t, 0.0), view_idx); + out.primary_uv = primary_uv; + out.view_layer = mv::packed_view_layer(instance_index, view_idx); + return out; +} + +fn world_uv2_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + secondary_uv: vec2, + vertex_index: u32, +) -> mv::WorldUv2VertexOutput { + let draw = pd::get_draw(instance_index); + let vp = mv::select_view_proj(draw, view_idx); + + let render_billboard_vertex = render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, secondary_uv, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + + var out: mv::WorldUv2VertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(draw, vec4(billboard_n, 0.0), view_idx); + out.world_t = mv::world_tangent_for_view(draw, vec4(billboard_t, 0.0), view_idx); + out.primary_uv = primary_uv; + // secondary_uv actually is overriden, and the generated billboard has no seccondary UV map anyway + out.secondary_uv = primary_uv; + out.view_layer = mv::packed_view_layer(instance_index, view_idx); + return out; +} + +fn world_uv4_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + secondary_uv: vec2, + vertex_index: u32, +) -> mv::WorldUv4VertexOutput { + let draw = pd::get_draw(instance_index); + let vp = mv::select_view_proj(draw, view_idx); + + let render_billboard_vertex = render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, secondary_uv, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + + var out: mv::WorldUv4VertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(draw, vec4(billboard_n, 0.0), view_idx); + out.world_t = mv::world_tangent_for_view(draw, vec4(billboard_t, 0.0), view_idx); + // secondary_uv actually is overriden, and the generated billboard has no seccondary UV map anyway + out.uv_a = primary_uv; + out.uv_b = primary_uv; + out.uv_c = primary_uv; + out.uv_d = primary_uv; + out.view_layer = mv::packed_view_layer(instance_index, view_idx); + return out; +} + +fn world_object_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + vertex_index: u32, + uv1: vec2, +) -> mv::WorldObjectVertexOutput { + let draw = pd::get_draw(instance_index); + let vp = mv::select_view_proj(draw, view_idx); + + let render_billboard_vertex = render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + + var out: mv::WorldObjectVertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.object_pos = pos.xyz; + out.world_n = mv::world_normal_for_view(draw, vec4(billboard_n, 0.0), view_idx); + out.world_t = mv::world_tangent_for_view(draw, vec4(billboard_t, 0.0), view_idx); + out.primary_uv = primary_uv; + out.view_layer = mv::packed_view_layer(instance_index, view_idx); + return out; +} + +fn uv_color_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + uv: vec2, + color: vec4, + n: vec4, + t: vec4, + vertex_index: u32, + uv1: vec2, +) -> mv::UvColorVertexOutput { + let draw = pd::get_draw(instance_index); + let vp = mv::select_view_proj(draw, view_idx); + + let render_billboard_vertex = render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + + var out: mv::UvColorVertexOutput; + out.clip_pos = vp * world_p; + out.uv = uv; + out.color = color * dt::particle_color(draw); + return out; +} diff --git a/crates/renderide/shaders/modules/fur/classic_advanced.wgsl b/crates/renderide/shaders/modules/fur/classic_advanced.wgsl index 692b7d5d7..17da9fbe6 100644 --- a/crates/renderide/shaders/modules/fur/classic_advanced.wgsl +++ b/crates/renderide/shaders/modules/fur/classic_advanced.wgsl @@ -32,6 +32,7 @@ struct ClassicAdvancedMaterial { _NoiseTex_LodBias: f32, _Cube_LodBias: f32, _Cube_StorageVInverted: f32, + _RenderideVariantBits: u32, } @group(1) @binding(0) var mat: ClassicAdvancedMaterial; @@ -45,19 +46,23 @@ struct ClassicAdvancedMaterial { fn vertex_main( instance_index: u32, view_idx: u32, + vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, + uv1: vec2, fur_multiplier: f32, ) -> furc::VertexOutput { return furc::fur_vertex_main( instance_index, view_idx, + vertex_index, pos, n, t, uv0, + uv1, mat._MainTex_ST, mat._NoiseTex_ST, fur_multiplier, @@ -65,6 +70,7 @@ fn vertex_main( mat._HairHardness, mat._ForceGlobal, mat._ForceLocal, + mat._RenderideVariantBits, ); } diff --git a/crates/renderide/shaders/modules/fur/classic_basic.wgsl b/crates/renderide/shaders/modules/fur/classic_basic.wgsl index 6ee1ea38d..10ad5e318 100644 --- a/crates/renderide/shaders/modules/fur/classic_basic.wgsl +++ b/crates/renderide/shaders/modules/fur/classic_basic.wgsl @@ -25,6 +25,7 @@ struct ClassicBasicMaterial { _SkinAlpha: f32, _MainTex_LodBias: f32, _NoiseTex_LodBias: f32, + _RenderideVariantBits: u32, } @group(1) @binding(0) var mat: ClassicBasicMaterial; @@ -36,19 +37,23 @@ struct ClassicBasicMaterial { fn vertex_main( instance_index: u32, view_idx: u32, + vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, + uv1: vec2, fur_multiplier: f32, ) -> furc::VertexOutput { return furc::fur_vertex_main( instance_index, view_idx, + vertex_index, pos, n, t, uv0, + uv1, mat._MainTex_ST, mat._NoiseTex_ST, fur_multiplier, @@ -56,6 +61,7 @@ fn vertex_main( mat._HairHardness, mat._ForceGlobal, mat._ForceLocal, + mat._RenderideVariantBits, ); } diff --git a/crates/renderide/shaders/modules/fur/classic_selfshadow.wgsl b/crates/renderide/shaders/modules/fur/classic_selfshadow.wgsl index e0fd7704d..c1f243e87 100644 --- a/crates/renderide/shaders/modules/fur/classic_selfshadow.wgsl +++ b/crates/renderide/shaders/modules/fur/classic_selfshadow.wgsl @@ -33,6 +33,7 @@ struct ClassicSelfShadowMaterial { _NoiseTex_LodBias: f32, _Cube_LodBias: f32, _Cube_StorageVInverted: f32, + _RenderideVariantBits: u32, } @group(1) @binding(0) var mat: ClassicSelfShadowMaterial; @@ -46,19 +47,23 @@ struct ClassicSelfShadowMaterial { fn vertex_main( instance_index: u32, view_idx: u32, + vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, + uv1: vec2, fur_multiplier: f32, ) -> furc::VertexOutput { return furc::fur_vertex_main( instance_index, view_idx, + vertex_index, pos, n, t, uv0, + uv1, mat._MainTex_ST, mat._NoiseTex_ST, fur_multiplier, @@ -66,6 +71,7 @@ fn vertex_main( mat._HairHardness, mat._ForceGlobal, mat._ForceLocal, + mat._RenderideVariantBits, ); } diff --git a/crates/renderide/shaders/modules/fur/common.wgsl b/crates/renderide/shaders/modules/fur/common.wgsl index 8a8eceb09..b730f8bcf 100644 --- a/crates/renderide/shaders/modules/fur/common.wgsl +++ b/crates/renderide/shaders/modules/fur/common.wgsl @@ -2,9 +2,11 @@ #define_import_path renderide::fur::common +#import renderide::billboard::vertex as bv #import renderide::draw::per_draw as pd #import renderide::frame::globals as rg #import renderide::mesh::vertex as mv +#import renderide::core::math as rmath #import renderide::core::uv as uvu struct VertexOutput { @@ -45,10 +47,12 @@ fn projected_local_force(force_local: vec4, view_idx: u32) -> vec3 { fn fur_vertex_main( instance_index: u32, view_idx: u32, + vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, + uv1: vec2, main_st: vec4, noise_st: vec4, fur_multiplier: f32, @@ -56,17 +60,38 @@ fn fur_vertex_main( hair_hardness: f32, force_global: vec4, force_local: vec4, + variant_bits: u32, ) -> VertexOutput { let draw = pd::get_draw(instance_index); - let world_n = mv::world_normal(draw, n); - let world_t = mv::world_tangent(draw, t); - let base_world_pos = mv::world_position(draw, pos).xyz; + var base_world_pos: vec3; + var world_n: vec3; + var world_t: vec4; + var billboard_vertex: bv::RenderBufferBillboardVertex; + if (bv::kw_RENDER_BUFFER(variant_bits)) { + billboard_vertex = bv::render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, uv1, + ); + base_world_pos = billboard_vertex.world_pos.xyz; + let axes = billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + world_n = mv::world_normal(draw, vec4(billboard_n, 0.0)); + world_t = mv::world_tangent(draw, vec4(billboard_t, 0.0)); + } else { + base_world_pos = mv::world_position(draw, pos).xyz; + world_n = mv::world_normal(draw, n); + world_t = mv::world_tangent(draw, t); + } + let shell_offset = n.xyz * fur_length * fur_multiplier * hair_hardness; let force_scale = fur_multiplier * fur_multiplier * fur_length; let local_force_offset = projected_local_force(force_local, view_idx) * force_scale; let shell_model_pos = pos.xyz + shell_offset + local_force_offset; let shell_pos = vec4(shell_model_pos, pos.w); - let shell_world_pos = mv::world_position(draw, shell_pos).xyz; + var shell_world_pos = mv::world_position(draw, shell_pos).xyz; + if (bv::kw_RENDER_BUFFER(variant_bits)) { + shell_world_pos = bv::billboard_center_world_to_world_pos(shell_world_pos, billboard_vertex); + } let global_force = clamp(force_global.xyz, vec3(-1.0), vec3(1.0)); let global_force_offset = global_force * force_scale; let world_p = shell_world_pos + global_force_offset; diff --git a/crates/renderide/shaders/modules/fur/modern.wgsl b/crates/renderide/shaders/modules/fur/modern.wgsl index c483e0d56..2f9eec767 100644 --- a/crates/renderide/shaders/modules/fur/modern.wgsl +++ b/crates/renderide/shaders/modules/fur/modern.wgsl @@ -40,6 +40,7 @@ struct ModernFurMaterial { _NoiseTex_LodBias: f32, _Cube_LodBias: f32, _Cube_StorageVInverted: f32, + _RenderideVariantBits: u32, } @group(1) @binding(0) var mat: ModernFurMaterial; @@ -55,19 +56,23 @@ struct ModernFurMaterial { fn vertex_main( instance_index: u32, view_idx: u32, + vertex_index: u32, pos: vec4, n: vec4, t: vec4, uv0: vec2, + uv1: vec2, fur_multiplier: f32, ) -> furc::VertexOutput { return furc::fur_vertex_main( instance_index, view_idx, + vertex_index, pos, n, t, uv0, + uv1, mat._MainTex_ST, mat._NoiseTex_ST, fur_multiplier, @@ -75,6 +80,7 @@ fn vertex_main( mat._HairHardness, mat._ForceGlobal, mat._ForceLocal, + mat._RenderideVariantBits, ); } diff --git a/crates/renderide/shaders/modules/mesh/wireframe.wgsl b/crates/renderide/shaders/modules/mesh/wireframe.wgsl index eb29f95dc..fb9f9703d 100644 --- a/crates/renderide/shaders/modules/mesh/wireframe.wgsl +++ b/crates/renderide/shaders/modules/mesh/wireframe.wgsl @@ -3,6 +3,14 @@ #define_import_path renderide::mesh::wireframe #import renderide::core::math as rmath +#import renderide::billboard::vertex as bv +#import renderide::core::texture_sampling as ts +#import renderide::core::uv as uvu +#import renderide::draw::per_draw as pd +#import renderide::frame::globals as rg +#import renderide::material::variant_bits as vb +#import renderide::mesh::vertex as mv +#import renderide::mesh::wireframe as wf const WIREFRAME_FALLBACK_DISTANCE: f32 = 1000000.0; const WIREFRAME_GRAM_DETERMINANT_RELATIVE_EPSILON: f32 = 1e-7; @@ -142,3 +150,63 @@ fn fresnel_factor(normal: vec3, view_dir: vec3, exponent: f32) -> f32 let v = rmath::safe_normalize(view_dir, vec3(0.0, 0.0, 1.0)); return pow(max(1.0 - abs(dot(n, v)), 0.0), max(exponent, 1e-4)); } + +struct VertexOutput { + @builtin(position) clip_pos: vec4, + @location(0) world_pos: vec3, + @location(1) world_n: vec3, + @location(2) uv: vec2, + @location(3) @interpolate(flat) view_layer: u32, +} + +fn vs_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + uv0: vec2, + maintex_st: vec4, +) -> VertexOutput { + let draw = pd::get_draw(instance_index); + let world_p = mv::world_position(draw, pos); + let vp = mv::select_view_proj(draw, view_idx); + + var out: VertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal(draw, n); + out.uv = uvu::apply_st(uv0, maintex_st); + out.view_layer = (instance_index << 1u) | (view_idx & 1u); + return out; +} + +fn billboard_vs_main( + instance_index: u32, + view_idx: u32, + vertex_index: u32, + pos: vec4, + n: vec4, + uv0: vec2, + t: vec4, + uv1: vec2, + maintex_st: vec4, +) -> VertexOutput { + let draw = pd::get_draw(instance_index); + let vp = mv::select_view_proj(draw, view_idx); + + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + draw, view_idx, pos, vertex_index, n, t, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + + var out: VertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(draw, vec4(billboard_n, 0.0), view_idx); + out.uv = uvu::apply_st(uv0, maintex_st); + out.view_layer = (instance_index << 1u) | (view_idx & 1u); + return out; +} diff --git a/crates/renderide/shaders/modules/pbs/families/triplanar.wgsl b/crates/renderide/shaders/modules/pbs/families/triplanar.wgsl index ef7b96cc5..dfc4d7ace 100644 --- a/crates/renderide/shaders/modules/pbs/families/triplanar.wgsl +++ b/crates/renderide/shaders/modules/pbs/families/triplanar.wgsl @@ -2,6 +2,8 @@ #define_import_path renderide::pbs::families::triplanar +#import renderide::billboard::vertex as bv +#import renderide::core::math as rmath #import renderide::core::normal_decode as nd #import renderide::core::texture_sampling as ts #import renderide::draw::per_draw as pd @@ -46,6 +48,40 @@ fn vertex_main( return out; } +fn billboard_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + vertex_index: u32, + uv0: vec2, + t: vec4, + uv1: vec2, + object_space_enabled: bool, +) -> VertexOutput { + let d = pd::get_draw(instance_index); + let vp = mv::select_view_proj(d, view_idx); + + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_idx, pos, vertex_index, n, t, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + let wn = mv::world_normal_for_view(d, vec4(billboard_n, 0.0), view_idx); + let object_n = normalize(billboard_n.xyz); + + var out: VertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = wn; + out.proj_pos = select(world_p.xyz, pos.xyz, object_space_enabled); + out.projection_n = select(wn, object_n, object_space_enabled); + out.view_layer = mv::packed_view_layer(instance_index, view_idx); + return out; +} + fn blend_rnm(n1_in: vec3, n2_in: vec3) -> vec3 { let n1 = vec3(n1_in.x, n1_in.y, n1_in.z + 1.0); let n2 = vec3(-n2_in.x, -n2_in.y, n2_in.z); diff --git a/crates/renderide/shaders/modules/post/filter_refraction.wgsl b/crates/renderide/shaders/modules/post/filter_refraction.wgsl index 73ff7db3d..29bc28795 100644 --- a/crates/renderide/shaders/modules/post/filter_refraction.wgsl +++ b/crates/renderide/shaders/modules/post/filter_refraction.wgsl @@ -53,6 +53,30 @@ fn vertex_main( return out; } +fn billboard_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + uv0: vec2, + vertex_index: u32, + uv1: vec2 +) -> VertexOutput { + let inner = fv::billboard_vertex_main(instance_index, view_idx, pos, n, t, uv0, vertex_index, uv1); + var out: VertexOutput; + out.clip_pos = inner.clip_pos; + out.primary_uv = inner.primary_uv; + out.world_pos = inner.world_pos; + out.world_n = inner.world_n; + out.view_layer = inner.view_layer; + out.view_n = inner.view_n; + out.obj_xy = pos.xy; + out.view_t = view_tangent_for_draw(instance_index, view_idx, inner.world_t); + out.clip_w = inner.clip_pos.w; + return out; +} + fn normal_offset( refraction_enabled: bool, normal_map_enabled: bool, diff --git a/crates/renderide/shaders/modules/post/filter_vertex.wgsl b/crates/renderide/shaders/modules/post/filter_vertex.wgsl index 355597766..8a5285745 100644 --- a/crates/renderide/shaders/modules/post/filter_vertex.wgsl +++ b/crates/renderide/shaders/modules/post/filter_vertex.wgsl @@ -2,6 +2,7 @@ #define_import_path renderide::post::filter_vertex +#import renderide::billboard::vertex as bv #import renderide::core::math as rmath #import renderide::mesh::vertex as mv #import renderide::draw::per_draw as pd @@ -57,6 +58,37 @@ fn vertex_main( return out; } +fn billboard_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + vertex_index: u32, + uv1: vec2 +) -> VertexOutput { + let d = pd::get_draw(instance_index); + let vp = mv::select_view_proj(d, view_idx); + + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_idx, pos, vertex_index, n, t, uv1, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + var out: VertexOutput; + out.clip_pos = vp * world_p; + out.primary_uv = primary_uv; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(d, vec4(billboard_n, 0.0), view_idx); + out.world_t = mv::world_tangent_for_view(d, vec4(billboard_t, 0.0), view_idx); + out.view_layer = view_idx; + out.view_n = vb::world_to_view_normal(out.world_n, vp); + return out; +} + fn rect_vertex_main( instance_index: u32, view_idx: u32, @@ -77,6 +109,28 @@ fn rect_vertex_main( return out; } +fn billboard_rect_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + vertex_index: u32, + uv1: vec2 +) -> RectVertexOutput { + let inner = billboard_vertex_main(instance_index, view_idx, pos, n, t, primary_uv, vertex_index, uv1); + var out: RectVertexOutput; + out.clip_pos = inner.clip_pos; + out.primary_uv = inner.primary_uv; + out.world_pos = inner.world_pos; + out.world_n = inner.world_n; + out.view_layer = inner.view_layer; + out.view_n = inner.view_n; + out.obj_xy = pos.xy; + return out; +} + fn position_rect_vertex_main( instance_index: u32, view_idx: u32, @@ -92,3 +146,21 @@ fn position_rect_vertex_main( out.view_layer = view_idx; return out; } + +fn billboard_position_rect_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + t: vec4, + primary_uv: vec2, + vertex_index: u32, + uv1: vec2 +) -> PositionRectVertexOutput { + let inner = billboard_vertex_main(instance_index, view_idx, pos, n, t, primary_uv, vertex_index, uv1); + var out: PositionRectVertexOutput; + out.clip_pos = inner.clip_pos; + out.obj_xy = pos.xy; + out.view_layer = view_idx; + return out; +} diff --git a/crates/renderide/shaders/modules/xiexe/toon2/main.wgsl b/crates/renderide/shaders/modules/xiexe/toon2/main.wgsl index 64ad6848c..d3732985e 100644 --- a/crates/renderide/shaders/modules/xiexe/toon2/main.wgsl +++ b/crates/renderide/shaders/modules/xiexe/toon2/main.wgsl @@ -35,6 +35,23 @@ fn vertex_main( return xsurf::vertex_main(instance_index, view_idx, pos, n, uv_primary, color, tangent, uv_secondary); } +/// Forward-pass vertex entry point for billboard rendering. +/// Thin wrapper around `surface::billboard_vertex_main` so +/// dispatcher shaders depend only on this aggregator namespace. +fn billboard_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + uv_primary: vec2, + color: vec4, + tangent: vec4, + uv_secondary: vec2, + vertex_index: u32, +) -> xb::VertexOutput { + return xsurf::billboard_vertex_main(instance_index, view_idx, pos, n, uv_primary, color, tangent, uv_secondary, vertex_index); +} + /// Forward (lit) fragment entry. Samples the surface (with the dual-sided back-face /// normal flip enabled), runs the alpha-mode dispatch, and shades through the cluster /// light walk. diff --git a/crates/renderide/shaders/modules/xiexe/toon2/surface.wgsl b/crates/renderide/shaders/modules/xiexe/toon2/surface.wgsl index 10458b72a..b183628b6 100644 --- a/crates/renderide/shaders/modules/xiexe/toon2/surface.wgsl +++ b/crates/renderide/shaders/modules/xiexe/toon2/surface.wgsl @@ -15,6 +15,8 @@ #import renderide::pbs::normal as pnorm #import renderide::core::normal_decode as nd #import renderide::core::uv as uvu +#import renderide::billboard::vertex as bv +#import renderide::core::math as rmath /// Forward-pass vertex transform. Builds the world-space TBN, applies the per-eye VP, /// and forwards UVs / vertex color unchanged. Outline extrusion lives in @@ -51,6 +53,46 @@ fn vertex_main( return out; } +/// Forward-pass vertex transform for billboard particle rendering. +/// Same structure as `vertex_main`, but using billboard point data +/// to generate quad vertices on the fly. +fn billboard_vertex_main( + instance_index: u32, + view_idx: u32, + pos: vec4, + n: vec4, + uv_primary: vec2, + color: vec4, + tangent: vec4, + uv_secondary: vec2, + vertex_index: u32, +) -> xb::VertexOutput { + let d = pd::get_draw(instance_index); + + let render_billboard_vertex = bv::render_buffer_billboard_vertex( + d, view_idx, pos, vertex_index, n, tangent, uv_secondary, + ); + let world_p = render_billboard_vertex.world_pos; + let axes = render_billboard_vertex.axes; + let billboard_t = axes.right; + let billboard_n = rmath::safe_normalize(cross(axes.right, axes.up), vec3(0.0, 0.0, 1.0)); + let vp = xb::view_projection_for_draw(d, view_idx); + + var out: xb::VertexOutput; + out.clip_pos = vp * world_p; + out.world_pos = world_p.xyz; + out.world_n = mv::world_normal_for_view(d, vec4(billboard_n, 0.0), view_idx).xyz; + out.world_t = mv::world_tangent_for_view(d, vec4(billboard_t, 0.0), view_idx).xyz; + out.world_b = rmath::safe_normalize(cross(out.world_n, out.world_t), vec3(0.0, 0.0, 1.0)); + out.uv_primary = uv_primary; + out.uv_secondary = uv_primary; + out.color = color; + out.obj_pos = xb::safe_normalize(pos.xyz, vec3(0.0, 0.0, 1.0)); + out.view_layer = mv::packed_view_layer(instance_index, view_idx); + return out; +} + + /// Builds a perturbed TBN from the interpolated geometry frame for a selected keyword layout. fn decode_normal_world_for_layout( uv_normal: vec2, diff --git a/crates/renderide/src/materials.rs b/crates/renderide/src/materials.rs index 3fdbfcfcc..6280cd57f 100644 --- a/crates/renderide/src/materials.rs +++ b/crates/renderide/src/materials.rs @@ -83,7 +83,6 @@ mod pipeline_kind; mod pipeline_property_resolver; pub(crate) mod raster_pipeline; mod registry; -mod render_buffer_shader; mod render_queue; mod render_state; mod router; @@ -162,9 +161,6 @@ pub(crate) use pipeline_property_resolver::PipelinePropertyResolver; /// Shader route table, optional material asset registry, and WGSL composition patches. pub(crate) use registry::{MaterialPipelineResolution, MaterialRegistry}; -pub(crate) use render_buffer_shader::{ - ensure_render_buffer_billboard_variant_bits, remap_variant_bits_for_billboard, -}; pub(crate) use router::{MaterialRouter, resolve_raster_pipeline}; /// Static shader feature flags (multiview, etc.) keyed into the pipeline cache. diff --git a/crates/renderide/src/materials/render_buffer_shader.rs b/crates/renderide/src/materials/render_buffer_shader.rs deleted file mode 100644 index 74dec25cc..000000000 --- a/crates/renderide/src/materials/render_buffer_shader.rs +++ /dev/null @@ -1,251 +0,0 @@ -//! Shader routing helpers for PhotonDust render-buffer draws. - -/// Billboard/Unlit variant bit for CPU-expanded PhotonDust render-buffer geometry. -/// -/// When set, `billboardunlit.wgsl` treats per-vertex point sizes as final particle sizes instead -/// of multiplying them by the material `_PointSize`. -pub(crate) const BILLBOARD_RENDER_BUFFER_ABSOLUTE_SIZE_BIT: u32 = 1u32 << 16; -/// Billboard/Unlit variant bit that enables per-particle color and alpha. -pub(crate) const BILLBOARD_RENDER_BUFFER_VERTEX_COLORS_BIT: u32 = 1u32 << 15; -/// Billboard/Unlit variant bit that enables texture sampling. -pub(crate) const BILLBOARD_RENDER_BUFFER_TEXTURE_BIT: u32 = 1u32 << 10; -/// Billboard/Unlit variant bit that enables base color. -pub(crate) const BILLBOARD_RENDER_BUFFER_COLOR_BIT: u32 = 1u32 << 1; -/// Billboard variant bit that enables simple lighting for non-unlit source materials. -pub(crate) const BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT: u32 = 1u32 << 17; - -const BILLBOARD_ALPHA_TEST_BIT: u32 = 1u32; - -pub(crate) fn remap_variant_bits_for_billboard(stem: &str, source_bits: u32) -> u32 { - if is_unlit_family_embedded_stem(stem) { - BILLBOARD_RENDER_BUFFER_VERTEX_COLORS_BIT - | remap_unlit_variant_bits_for_billboard(source_bits) - } else { - BILLBOARD_RENDER_BUFFER_TEXTURE_BIT - | BILLBOARD_RENDER_BUFFER_COLOR_BIT - | BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT - | map_billboard_vertex_color_variant_bits(stem, source_bits) - | map_billboard_alpha_clip_variant_bits(stem, source_bits) - } -} - -/// Enables render-buffer sizing and particle color semantics for synthetic billboard draws. -pub(crate) fn ensure_render_buffer_billboard_variant_bits(bits: u32) -> u32 { - bits | BILLBOARD_RENDER_BUFFER_ABSOLUTE_SIZE_BIT -} - -/// Returns whether `stem` names an embedded Unlit-family shader other than Billboard/Unlit. -fn is_unlit_family_embedded_stem(stem: &str) -> bool { - let lower = stem.to_ascii_lowercase(); - (lower.starts_with("unlit") || lower.contains("_unlit") || lower.contains("unlit_")) - && !lower.contains("billboard") -} - -/// Remaps Froox Unlit keyword bits to Billboard/Unlit keyword bits for material binding. -fn remap_unlit_variant_bits_for_billboard(unlit_bits: u32) -> u32 { - const PAIRS: &[(u32, u32)] = &[ - (0, 0), - (1, 1), - (2, 18), - (3, 19), - (4, 2), - (5, 3), - (6, 4), - (7, 8), - (8, 9), - (9, 10), - (11, 13), - (12, 14), - (13, 15), - ]; - let mut out = 0u32; - for &(from, to) in PAIRS { - if unlit_bits & (1u32 << from) != 0 { - out |= 1u32 << to; - } - } - out -} - -/// Remaps Froox AlphaClip or Cutoff keyword bits to Billboard/Unlit keyword bits -/// for material binding with non-Unlit materials. -fn map_billboard_alpha_clip_variant_bits(stem: &str, source_bits: u32) -> u32 { - let lower = stem.to_ascii_lowercase(); - if lower.starts_with("xstoon2.0-cutout") { - return BILLBOARD_ALPHA_TEST_BIT; - } - const ALPHA_CLIP_TWO: &[&str] = &["pbsmetallic", "pbsspecular"]; - if ALPHA_CLIP_TWO - .iter() - .any(|prefix| lower.starts_with(prefix)) - { - return ((source_bits >> 2) & 1) * BILLBOARD_ALPHA_TEST_BIT; - } - const ALPHA_CLIP_ONE: &[&str] = &[ - "pbsdisplace", - "pbsdualsided_", - "pbsdualsidedspecular_", - "pbslerp", - "pbsslice_", - "pbsslicespecular_", - "pbsvertexcolor", - "xstoon", - ]; - if ALPHA_CLIP_ONE - .iter() - .any(|prefix| lower.starts_with(prefix)) - { - return ((source_bits >> 1) & 1) * BILLBOARD_ALPHA_TEST_BIT; - } - const ALPHA_CLIP_ZERO: &[&str] = &["fresnel_", "pbsmultiuv", "reflection"]; - if ALPHA_CLIP_ZERO - .iter() - .any(|prefix| lower.starts_with(prefix)) - { - return (source_bits & 1) * BILLBOARD_ALPHA_TEST_BIT; - } - 0u32 -} - -/// Remaps Froox Vertex Colors keyword bits to Billboard/Unlit keyword bits -/// for material binding with non-Unlit materials. -fn map_billboard_vertex_color_variant_bits(stem: &str, source_bits: u32) -> u32 { - let lower = stem.to_ascii_lowercase(); - let source_bit: Option = if lower.starts_with("fresnel_") { - Some(10) - } else if lower.starts_with("pbsdualsidedtransparent") { - Some(5) - } else if lower.starts_with("pbsvertexcolor") || lower.starts_with("pbsdualsided") { - Some(6) - } else if lower.starts_with("xstoon") { - Some(8) - } else { - None - }; - - source_bit.map_or(0, |bit| { - ((source_bits >> bit) & 1) * BILLBOARD_RENDER_BUFFER_VERTEX_COLORS_BIT - }) -} - -#[cfg(test)] -mod tests { - use super::*; - - const BILLBOARD_UNLIT_MASK_TEXTURE_CLIP_BIT: u32 = 1u32 << 18; - const BILLBOARD_UNLIT_MASK_TEXTURE_MUL_BIT: u32 = 1u32 << 19; - - #[test] - fn detects_unlit_family_stems() { - assert!(is_unlit_family_embedded_stem("unlit_default")); - assert!(is_unlit_family_embedded_stem("ui_unlit_default")); - assert!(!is_unlit_family_embedded_stem("billboardunlit_default")); - } - - #[test] - fn remaps_unlit_texture_and_color_bits() { - let unlit = (1u32 << 1) | (1u32 << 9); - let billboard = remap_variant_bits_for_billboard("unlit_default", unlit); - - assert_eq!(billboard & (1u32 << 1), 1u32 << 1); - assert_eq!(billboard & (1u32 << 10), 1u32 << 10); - assert_eq!(billboard & (1u32 << 9), 0); - } - - #[test] - fn remaps_unlit_mask_bits_to_billboard_compatibility_bits() { - let unlit = (1u32 << 2) | (1u32 << 3); - let billboard = remap_unlit_variant_bits_for_billboard(unlit); - - assert_eq!( - billboard & BILLBOARD_UNLIT_MASK_TEXTURE_CLIP_BIT, - BILLBOARD_UNLIT_MASK_TEXTURE_CLIP_BIT - ); - assert_eq!( - billboard & BILLBOARD_UNLIT_MASK_TEXTURE_MUL_BIT, - BILLBOARD_UNLIT_MASK_TEXTURE_MUL_BIT - ); - assert_eq!(billboard & (1u32 << 2), 0); - assert_eq!(billboard & (1u32 << 3), 0); - } - - #[test] - fn remaps_pbs_alphaclip_bits() { - let pbs = (1u32 << 2) | (1u32 << 7); - let billboard = remap_variant_bits_for_billboard("pbsmetallic_default", pbs); - - assert_eq!( - billboard, - BILLBOARD_RENDER_BUFFER_COLOR_BIT - | BILLBOARD_RENDER_BUFFER_TEXTURE_BIT - | BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT - | 1u32 - ); - } - - #[test] - fn remaps_pbs_no_alphaclip_bits() { - let pbs = 1u32 << 7; - let billboard = remap_variant_bits_for_billboard("pbsmetallic_default", pbs); - - assert_eq!( - billboard, - BILLBOARD_RENDER_BUFFER_COLOR_BIT - | BILLBOARD_RENDER_BUFFER_TEXTURE_BIT - | BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT - ); - } - - #[test] - fn remaps_supported_non_unlit_vertex_color_bits_to_billboard_vertex_colors() { - for (stem, bit) in [ - ("fresnel_default", 10), - ("pbsdualsidedtransparent_default", 5), - ("pbsdualsidedspecular_default", 6), - ("pbsvertexcolortransparent_default", 6), - ("xstoon2.0_default", 8), - ] { - let billboard = remap_variant_bits_for_billboard(stem, 1u32 << bit); - - assert_eq!( - billboard & BILLBOARD_RENDER_BUFFER_VERTEX_COLORS_BIT, - BILLBOARD_RENDER_BUFFER_VERTEX_COLORS_BIT, - "{stem}" - ); - assert_eq!( - billboard & BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT, - BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT, - "{stem}" - ); - } - } - - #[test] - fn leaves_unsupported_non_unlit_vertex_color_bits_disabled() { - let billboard = remap_variant_bits_for_billboard("pbsmetallic_default", 1u32 << 7); - - assert_eq!(billboard & BILLBOARD_RENDER_BUFFER_VERTEX_COLORS_BIT, 0); - assert_eq!( - billboard & BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT, - BILLBOARD_RENDER_BUFFER_SIMPLE_LIT_BIT - ); - } - - #[test] - fn forces_cutout_for_xiexe_cutout_stems() { - let billboard = remap_variant_bits_for_billboard("xstoon2.0-cutout_default", 0); - - assert_eq!( - billboard & BILLBOARD_ALPHA_TEST_BIT, - BILLBOARD_ALPHA_TEST_BIT - ); - } - - #[test] - fn render_buffer_variant_bit_is_reserved() { - assert_eq!( - ensure_render_buffer_billboard_variant_bits(0), - BILLBOARD_RENDER_BUFFER_ABSOLUTE_SIZE_BIT - ); - } -} diff --git a/crates/renderide/src/materials/shader_specialization.rs b/crates/renderide/src/materials/shader_specialization.rs index 6de307439..ef054abdc 100644 --- a/crates/renderide/src/materials/shader_specialization.rs +++ b/crates/renderide/src/materials/shader_specialization.rs @@ -7,6 +7,7 @@ pub(crate) const STATIC_VARIANT_BITS_OVERRIDE: &str = "renderide_static_variant_ const STATIC_VARIANT_BITS_DISABLED: u32 = 0; const STATIC_VARIANT_BITS_ENABLED: u32 = 1; +const DEFAULT_VARIANT_BITS_ENABLED: u32 = 2; /// Pipeline-cache selector for material shader specialization constants. /// @@ -35,6 +36,14 @@ impl MaterialShaderSpecializationKey { } } + /// Returns a key that exposes the given variant bitmask as a default pipeline mask. + pub(crate) const fn from_default_variant_bits(bits: u32) -> Self { + Self { + static_variant_bits_mode: DEFAULT_VARIANT_BITS_ENABLED, + static_variant_bits: bits, + } + } + /// Returns a static key when variant bits are known, or the disabled key otherwise. pub(crate) const fn from_optional_variant_bits(bits: Option) -> Self { match bits { diff --git a/crates/renderide/src/particles/point.rs b/crates/renderide/src/particles/point.rs index 0a8411a28..8fed8a03f 100644 --- a/crates/renderide/src/particles/point.rs +++ b/crates/renderide/src/particles/point.rs @@ -190,8 +190,8 @@ fn build_billboard_mesh_input( /// Builds raw orientation streams consumed by Billboard/Unlit render-buffer alignment. pub(super) fn billboard_extra_streams(points: &[PointParticle]) -> GeneratedExtraStreams { let vertex_count = points.len() * BILLBOARD_VERTICES_PER_POINT; - let mut raw_tangent = vec![0u8; vertex_count * 16]; - let mut uv1 = vec![0u8; vertex_count * 8]; + let mut point_forward_upz = vec![0u8; vertex_count * 16]; + let mut point_up_xy = vec![0u8; vertex_count * 8]; for (point_index, point) in points.iter().enumerate() { let forward = point.rotation * Vec3::Z; let up = point.rotation * Vec3::Y; @@ -200,15 +200,15 @@ pub(super) fn billboard_extra_streams(points: &[PointParticle]) -> GeneratedExtr for corner_index in 0..BILLBOARD_VERTICES_PER_POINT { let vertex_index = point_index * BILLBOARD_VERTICES_PER_POINT + corner_index; let tangent_start = vertex_index * 16; - raw_tangent[tangent_start..tangent_start + 16] + point_forward_upz[tangent_start..tangent_start + 16] .copy_from_slice(bytemuck::cast_slice(&tangent)); let uv1_start = vertex_index * 8; - uv1[uv1_start..uv1_start + 8].copy_from_slice(bytemuck::cast_slice(&up_xy)); + point_up_xy[uv1_start..uv1_start + 8].copy_from_slice(bytemuck::cast_slice(&up_xy)); } } GeneratedExtraStreams { - raw_tangent: Some(raw_tangent), - uv1: Some(uv1), + point_forward_upz: Some(point_forward_upz), + point_up_xy: Some(point_up_xy), } } diff --git a/crates/renderide/src/particles/tests.rs b/crates/renderide/src/particles/tests.rs index 894d2668d..e08723f8f 100644 --- a/crates/renderide/src/particles/tests.rs +++ b/crates/renderide/src/particles/tests.rs @@ -368,15 +368,15 @@ fn billboard_extra_streams_pack_particle_orientation() { }]; let streams = billboard_extra_streams(&points); - let raw_tangent = streams.raw_tangent.as_deref().expect("raw tangent"); - let uv1 = streams.uv1.as_deref().expect("uv1"); - let tangent: &[f32] = bytemuck::cast_slice(&raw_tangent[..16]); - let up_xy: &[f32] = bytemuck::cast_slice(&uv1[..8]); + let point_forward_upz = streams.point_forward_upz.as_deref().expect("raw tangent"); + let point_up_xy = streams.point_up_xy.as_deref().expect("uv1"); + let tangent: &[f32] = bytemuck::cast_slice(&point_forward_upz[..16]); + let up_xy: &[f32] = bytemuck::cast_slice(&point_up_xy[..8]); assert_eq!(tangent, &[0.0, 0.0, 1.0, 0.0]); assert_eq!(up_xy, &[0.0, 1.0]); - assert_eq!(raw_tangent.len(), BILLBOARD_VERTICES_PER_POINT * 16); - assert_eq!(uv1.len(), BILLBOARD_VERTICES_PER_POINT * 8); + assert_eq!(point_forward_upz.len(), BILLBOARD_VERTICES_PER_POINT * 16); + assert_eq!(point_up_xy.len(), BILLBOARD_VERTICES_PER_POINT * 8); } #[test] diff --git a/crates/renderide/src/particles/upload.rs b/crates/renderide/src/particles/upload.rs index c179c7913..488d03d9d 100644 --- a/crates/renderide/src/particles/upload.rs +++ b/crates/renderide/src/particles/upload.rs @@ -16,9 +16,13 @@ use super::types::ParticleRenderBufferError; #[derive(Debug, Default)] pub(super) struct GeneratedExtraStreams { /// Raw tangent payload stream at shader location 4. - pub(super) raw_tangent: Option>, + /// Overloaded by particle system to hold the forward direction of the particle + /// and the Z component of its up direction. + pub(super) point_forward_upz: Option>, /// UV1 stream at shader location 5. - pub(super) uv1: Option>, + /// Overloaded by particle system to hold the XY components + /// of the up direction of the particle. + pub(super) point_up_xy: Option>, } pub(super) fn generated_vertex_stride() -> usize { @@ -96,8 +100,8 @@ pub(super) fn prepared_generated_derived_streams( normals: Some(normals), uv0: Some(uv0), color: Some(color), - raw_tangent: extra.raw_tangent, - uv1: extra.uv1, + raw_tangent: extra.point_forward_upz, + uv1: extra.point_up_xy, ..PreparedDerivedStreams::default() } } diff --git a/crates/renderide/src/passes/world_mesh_forward/material_batch.rs b/crates/renderide/src/passes/world_mesh_forward/material_batch.rs index ee2250a3e..ad84ddf1a 100644 --- a/crates/renderide/src/passes/world_mesh_forward/material_batch.rs +++ b/crates/renderide/src/passes/world_mesh_forward/material_batch.rs @@ -19,15 +19,13 @@ use crate::materials::ShaderPermutation; use crate::materials::embedded::{EmbeddedMaterialBindError, MaterialBindCacheKey}; use crate::materials::{ EmbeddedMaterialBindResources, EmbeddedMaterialBindShader, EmbeddedTexturePools, -}; -use crate::materials::{ MaterialBlendMode, MaterialPassRouting, MaterialPipelineDesc, MaterialPipelineResolution, MaterialPipelineSet, MaterialPipelineVariantSpec, MaterialRegistry, MaterialRenderState, MaterialShaderSpecializationKey, RasterFrontFace, RasterPipelineKind, RasterPrimitiveTopology, - ensure_render_buffer_billboard_variant_bits, remap_variant_bits_for_billboard, }; use crate::passes::WorldMeshForwardEncodeRefs; use crate::world_mesh::draw_prep::WorldMeshDrawItem; +use crate::world_mesh::materials::BILLBOARD_RENDER_BUFFER_BIT; /// Material boundary runs assigned to one packet-resolution worker. const MATERIAL_BATCH_PARALLEL_CHUNK_RUNS: usize = RELEVANCE_PACKET_MIN_ITEMS; @@ -461,7 +459,7 @@ impl<'a> MaterialDrawResolver<'a> { )); }; - let shader_variant_bits = self.resolve_embedded_shader_variant_bits(item, stem); + let shader_variant_bits = self.resolve_embedded_shader_variant_bits(item); let (bind_key, bind_group) = bind.embedded_material_bind_group_with_cache_key( EmbeddedMaterialBindShader { stem, @@ -481,29 +479,15 @@ impl<'a> MaterialDrawResolver<'a> { } /// Resolves source shader variant bits for a possibly rerouted embedded draw. - fn resolve_embedded_shader_variant_bits( - &self, - item: &WorldMeshDrawItem, - stem: &str, - ) -> Option { + fn resolve_embedded_shader_variant_bits(&self, item: &WorldMeshDrawItem) -> Option { let batch_key = &item.batch_key; let source_bits = self .registry .and_then(|registry| registry.variant_bits_for_shader_asset(batch_key.shader_asset_id)); - if !stem.starts_with("billboardunlit") { - return source_bits; - } - let mut bits = source_bits.unwrap_or(0); - if let Some(source_stem) = self - .registry - .and_then(|registry| registry.stem_for_shader_asset(batch_key.shader_asset_id)) - { - bits = remap_variant_bits_for_billboard(source_stem, bits); - } if batch_key.uses_render_buffer_billboard { - Some(ensure_render_buffer_billboard_variant_bits(bits)) + Some(source_bits.unwrap_or(0) | BILLBOARD_RENDER_BUFFER_BIT) } else { - source_bits.map(|_| bits) + source_bits } } diff --git a/crates/renderide/src/world_mesh/draw_prep/collect/candidate.rs b/crates/renderide/src/world_mesh/draw_prep/collect/candidate.rs index aa034f5b0..e73966534 100644 --- a/crates/renderide/src/world_mesh/draw_prep/collect/candidate.rs +++ b/crates/renderide/src/world_mesh/draw_prep/collect/candidate.rs @@ -95,11 +95,7 @@ pub(super) fn evaluate_draw_candidate( shader_perm: ctx.materials.shader_perm, }, ); - apply_render_buffer_mesh_pipeline_override( - &mut batch_key, - candidate.mesh_asset_id, - ctx.materials.shader_perm, - ); + apply_render_buffer_mesh_pipeline_override(&mut batch_key, candidate.mesh_asset_id); // Per-slot UI rect-mask CPU cull: the per-renderer cull above runs once per renderer (and // bypasses overlay anyway), so the actual rect-vs-viewport check has to live here, where // `_Rect` / `_RectClip` are finally known per material slot. Without this, every off-screen diff --git a/crates/renderide/src/world_mesh/materials.rs b/crates/renderide/src/world_mesh/materials.rs index 3ce2c5553..32979768d 100644 --- a/crates/renderide/src/world_mesh/materials.rs +++ b/crates/renderide/src/world_mesh/materials.rs @@ -12,6 +12,7 @@ pub use key::{MaterialDrawBatchKey, compute_batch_key_hash}; pub use transparent::TransparentMaterialClass; pub(crate) use resolve::{ - MaterialResolveCtx, apply_render_buffer_mesh_pipeline_override, batch_key_for_slot_cached, + BILLBOARD_RENDER_BUFFER_BIT, MaterialResolveCtx, apply_render_buffer_mesh_pipeline_override, + batch_key_for_slot_cached, }; pub(crate) use slot::normalized_material_slot; diff --git a/crates/renderide/src/world_mesh/materials/resolve.rs b/crates/renderide/src/world_mesh/materials/resolve.rs index f7f34354b..a85c9d71b 100644 --- a/crates/renderide/src/world_mesh/materials/resolve.rs +++ b/crates/renderide/src/world_mesh/materials/resolve.rs @@ -1,7 +1,5 @@ //! Material batch-key resolution for world-mesh draw prep. -use std::sync::Arc; - use crate::materials::ShaderPermutation; use crate::materials::host_data::{MaterialDictionary, MaterialPropertyLookupIds}; use crate::materials::{ @@ -19,6 +17,9 @@ use super::transparent::{ TransparentMaterialClass, TransparentMaterialClassInput, transparent_class_for_material, }; +/// Generic variant bit used by all shaders compatible with particle system rendering. +pub(crate) const BILLBOARD_RENDER_BUFFER_BIT: u32 = 1u32 << 24; + /// Read-only material-resolution context threaded through the cache refresh walker and the cached /// batch-key lookup. #[derive(Copy, Clone)] @@ -334,12 +335,6 @@ pub(crate) fn resolve_material_batch( } } -/// WGSL stem used for generated PhotonDust billboard mesh draws. -const RENDER_BUFFER_BILLBOARD_STEM: &str = "billboardunlit_default"; - -const RENDER_BUFFER_ORDERED_ALPHA_FALLBACK_BLEND: MaterialBlendMode = - MaterialBlendMode::UnityBlend { src: 5, dst: 10 }; - /// Routes generated PhotonDust billboard meshes through Billboard/Unlit. /// /// Point render-buffer uploads expand each particle into four co-located quad vertices. Ordinary @@ -348,67 +343,16 @@ const RENDER_BUFFER_ORDERED_ALPHA_FALLBACK_BLEND: MaterialBlendMode = pub(crate) fn apply_render_buffer_mesh_pipeline_override( batch_key: &mut MaterialDrawBatchKey, mesh_asset_id: i32, - shader_perm: ShaderPermutation, ) { if !crate::particles::is_generated_billboard_mesh_asset_id(mesh_asset_id) { return; } batch_key.uses_render_buffer_billboard = true; - if let RasterPipelineKind::EmbeddedStem(stem) = &batch_key.pipeline - && stem.as_ref().starts_with("billboardunlit") - { - batch_key.shader_specialization = MaterialShaderSpecializationKey::disabled(); - return; - } - let pipeline = RasterPipelineKind::EmbeddedStem(Arc::from(RENDER_BUFFER_BILLBOARD_STEM)); - let features = embedded_material_features(&pipeline, shader_perm); - batch_key.pipeline = pipeline; - batch_key.shader_specialization = MaterialShaderSpecializationKey::disabled(); - batch_key.embedded_needs_uv0 = features.needs_uv0; - batch_key.embedded_needs_color = features.needs_color; - batch_key.embedded_needs_uv1 = features.needs_uv1; - batch_key.embedded_needs_tangent = features.needs_tangent; - batch_key.embedded_tangent_fallback_mode = features.tangent_fallback_mode; - batch_key.embedded_raw_tangent_payload = features.raw_tangent_payload; - batch_key.embedded_raw_normal_payload = features.raw_normal_payload; - batch_key.embedded_needs_uv2 = features.needs_uv2; - batch_key.embedded_needs_uv3 = features.needs_uv3; - batch_key.embedded_needs_wide_low_uvs = features.needs_wide_low_uvs; - batch_key.embedded_needs_wide_high_uvs = features.needs_wide_high_uvs; - batch_key.embedded_needs_extended_vertex_streams = features.needs_extended_vertex_streams; - batch_key.embedded_requires_intersection_pass = features.requires_intersection_pass; - batch_key.embedded_uses_scene_depth_snapshot = features.uses_scene_depth_snapshot; - batch_key.embedded_uses_scene_color_snapshot = features.uses_scene_color_snapshot; - batch_key.scene_color_snapshot_mode = features.scene_color_snapshot_mode; - batch_key.alpha_blended = batch_key.alpha_blended - || features.uses_alpha_blending - || features.uses_scene_color_snapshot; - batch_key.transparent_class = transparent_class_for_material(TransparentMaterialClassInput { - render_queue: batch_key.render_queue, - render_state: batch_key.render_state, - blend_mode: batch_key.blend_mode, - alpha_blended: batch_key.alpha_blended, - uses_scene_color_snapshot: features.uses_scene_color_snapshot, - uses_blended_depth_write: features.uses_blended_depth_write, - uses_two_sided_transparency: features.uses_two_sided_transparency, - }); - batch_key.blend_mode = render_buffer_billboard_blend_mode_for_source( - batch_key.blend_mode, - batch_key.transparent_class, - ); -} - -fn render_buffer_billboard_blend_mode_for_source( - blend_mode: MaterialBlendMode, - transparent_class: TransparentMaterialClass, -) -> MaterialBlendMode { - if blend_mode == MaterialBlendMode::StemDefault - && transparent_class == TransparentMaterialClass::OrderedAlpha - { - RENDER_BUFFER_ORDERED_ALPHA_FALLBACK_BLEND - } else { - blend_mode - } + batch_key.shader_specialization = + MaterialShaderSpecializationKey::from_default_variant_bits(BILLBOARD_RENDER_BUFFER_BIT); + batch_key.embedded_raw_tangent_payload = true; + batch_key.embedded_raw_normal_payload = true; + batch_key.embedded_needs_uv1 = true; } /// Assembles a [`MaterialDrawBatchKey`] from a pre-resolved [`ResolvedMaterialBatch`] entry. @@ -469,6 +413,7 @@ mod ui_rect_clip_tests { UNITY_RENDER_QUEUE_GEOMETRY, UNITY_RENDER_QUEUE_OVERLAY, UNITY_RENDER_QUEUE_TRANSPARENT, }; use crate::shared::TrailTextureMode; + use std::sync::Arc; struct Fixture { registry: PropertyIdRegistry, @@ -757,7 +702,7 @@ mod ui_rect_clip_tests { } #[test] - fn generated_billboard_mesh_overrides_to_billboard_pipeline() { + fn generated_billboard_mesh_keeps_using_main_pipeline() { let mut store = MaterialPropertyStore::new(); store.set_shader_asset_for_material(7, 99); let dict = MaterialDictionary::new(&store); @@ -779,20 +724,16 @@ mod ui_rect_clip_tests { ); let mesh_asset_id = crate::particles::billboard_render_buffer_mesh_asset_id(3).unwrap(); - apply_render_buffer_mesh_pipeline_override( - &mut key, - mesh_asset_id, - ShaderPermutation::default(), - ); + apply_render_buffer_mesh_pipeline_override(&mut key, mesh_asset_id); let RasterPipelineKind::EmbeddedStem(stem) = &key.pipeline else { panic!("expected embedded billboard pipeline"); }; - assert_eq!(stem.as_ref(), "billboardunlit_default"); + assert_eq!(stem.as_ref(), "unlit_default"); assert!(key.uses_render_buffer_billboard); assert!(key.embedded_needs_uv0); + assert!(key.embedded_needs_uv1); assert!(key.embedded_needs_color); - assert!(key.embedded_needs_tangent); assert!(key.embedded_raw_tangent_payload); assert!(key.embedded_raw_normal_payload); } @@ -822,16 +763,12 @@ mod ui_rect_clip_tests { assert!(!key.uses_render_buffer_billboard); - apply_render_buffer_mesh_pipeline_override( - &mut key, - mesh_asset_id, - ShaderPermutation::default(), - ); + apply_render_buffer_mesh_pipeline_override(&mut key, mesh_asset_id); assert!(key.uses_render_buffer_billboard); assert_eq!( key.shader_specialization, - MaterialShaderSpecializationKey::disabled() + MaterialShaderSpecializationKey::from_default_variant_bits(BILLBOARD_RENDER_BUFFER_BIT) ); } @@ -869,91 +806,13 @@ mod ui_rect_clip_tests { ); let mesh_asset_id = crate::particles::billboard_render_buffer_mesh_asset_id(3).unwrap(); - apply_render_buffer_mesh_pipeline_override( - &mut key, - mesh_asset_id, - ShaderPermutation::default(), - ); + apply_render_buffer_mesh_pipeline_override(&mut key, mesh_asset_id); assert!(key.alpha_blended); assert_eq!(key.render_queue, UNITY_RENDER_QUEUE_TRANSPARENT); assert!(key.transparent_class.is_transparent()); } - #[test] - fn generated_billboard_mesh_uses_alpha_blend_for_stem_default_ordered_transparency() { - let registry = PropertyIdRegistry::new(); - let render_queue = registry.intern("_RenderQueue"); - let mut store = MaterialPropertyStore::new(); - store.set_shader_asset_for_material(7, 99); - store.set_material( - 7, - render_queue, - MaterialPropertyValue::Float(UNITY_RENDER_QUEUE_TRANSPARENT as f32), - ); - let dict = MaterialDictionary::new(&store); - let mut router = MaterialRouter::new(RasterPipelineKind::Null); - router.set_shader_pipeline( - 99, - RasterPipelineKind::EmbeddedStem(Arc::from("pbsvertexcolortransparent_default")), - ); - let ids = MaterialPipelinePropertyIds::new(®istry); - let resolved = - resolve_material_batch(7, None, &dict, &router, &ids, ShaderPermutation::default()); - let mut key = batch_key_from_resolved( - 7, - None, - false, - RasterFrontFace::Clockwise, - RasterPrimitiveTopology::TriangleList, - &resolved, - ); - let mesh_asset_id = crate::particles::billboard_render_buffer_mesh_asset_id(3).unwrap(); - - assert_eq!(key.blend_mode, MaterialBlendMode::StemDefault); - assert_eq!( - key.transparent_class, - TransparentMaterialClass::OrderedAlpha - ); - - apply_render_buffer_mesh_pipeline_override( - &mut key, - mesh_asset_id, - ShaderPermutation::default(), - ); - - assert_eq!(key.blend_mode, RENDER_BUFFER_ORDERED_ALPHA_FALLBACK_BLEND); - assert_eq!( - key.transparent_class, - TransparentMaterialClass::OrderedAlpha - ); - } - - #[test] - fn render_buffer_billboard_blend_fallback_keeps_explicit_and_non_ordered_modes() { - assert_eq!( - render_buffer_billboard_blend_mode_for_source( - MaterialBlendMode::UnityBlend { src: 1, dst: 1 }, - TransparentMaterialClass::OrderedAlpha, - ), - MaterialBlendMode::UnityBlend { src: 1, dst: 1 } - ); - assert_eq!( - render_buffer_billboard_blend_mode_for_source( - MaterialBlendMode::Opaque, - TransparentMaterialClass::OrderedAlpha, - ), - MaterialBlendMode::Opaque - ); - assert_eq!( - render_buffer_billboard_blend_mode_for_source( - MaterialBlendMode::StemDefault, - TransparentMaterialClass::DepthWritingTransparent, - ), - MaterialBlendMode::StemDefault - ); - } - #[test] fn generated_trail_mesh_does_not_get_billboard_pipeline_override() { let mut store = MaterialPropertyStore::new(); @@ -980,11 +839,7 @@ mod ui_rect_clip_tests { crate::particles::trail_render_buffer_mesh_asset_id(3, TrailTextureMode::Stretch) .unwrap(); - apply_render_buffer_mesh_pipeline_override( - &mut key, - mesh_asset_id, - ShaderPermutation::default(), - ); + apply_render_buffer_mesh_pipeline_override(&mut key, mesh_asset_id); assert_eq!(key.pipeline, original); assert!(!key.uses_render_buffer_billboard); diff --git a/crates/renderide/tests/shader_module_audit.rs b/crates/renderide/tests/shader_module_audit.rs index 376f9607b..2dfaecc9f 100644 --- a/crates/renderide/tests/shader_module_audit.rs +++ b/crates/renderide/tests/shader_module_audit.rs @@ -305,7 +305,7 @@ fn reflection_shader_samples_vr_mirror_side_by_side_layout() -> io::Result<()> { ); assert!( src.contains( - "#ifdef MULTIVIEW\n let view_layer = view_idx;\n let screen_y = (clip.y + clip.w) * 0.5;\n#else\n let view_layer = 0u;\n let screen_y = (clip.w - clip.y) * 0.5;\n#endif" + "#ifdef MULTIVIEW\n let screen_y = (clip.y + clip.w) * 0.5;\n#else\n let screen_y = (clip.w - clip.y) * 0.5;\n#endif" ), "Reflection must use the HMD screen-space Y convention only in multiview" ); @@ -446,32 +446,34 @@ fn billboard_render_buffer_uses_indexed_corner_separate_from_sample_uv() -> io:: "Billboard/Unlit must know the indexed vertex id for generated render-buffer quads" ); assert!( - src.contains("fn render_buffer_billboard_unit_corner(vertex_index: u32) -> vec2") - && src.contains("let corner = vertex_index % 4u;"), + src.contains("let render_billboard_vertex = bv::render_buffer_billboard_vertex(") + && src.contains("world_p = render_billboard_vertex.world_pos.xyz"), "Billboard/Unlit must derive generated render-buffer quad corners from vertex order" ); + + let module = module_source("billboard/vertex.wgsl")?; assert!( - src.contains( - "fn billboard_corner_for_vertex(pos: vec3, uv: vec2, vertex_index: u32) -> vec2" - ) && src.contains( + module.contains( + "fn render_buffer_billboard_corner_for_vertex(vertex_index: u32) -> vec2" + ) && module.contains( "return render_buffer_billboard_unit_corner(vertex_index) * 2.0 - vec2(1.0, 1.0);" - ) && src.contains("return mb::billboard_corner(pos, uv);"), + ) && src.contains("let corner = mb::billboard_corner(pos.xyz, uv);"), "Render-buffer billboards must not reuse framed atlas UVs as geometry corners" ); assert!( - src.contains("let corner = billboard_corner_for_vertex(pos.xyz, uv, vertex_index);") - && src.contains("out.uv = uv;"), + module.contains("let corner = render_buffer_billboard_corner_for_vertex(vertex_index);") + && module.contains("out.uv = uv;"), "Billboard/Unlit must keep atlas sampling UVs separate from generated geometry corners" ); assert!( src.contains("@location(4) point_forward_upz: vec4") && src.contains("@location(5) point_up_xy: vec2") - && src.contains("fn render_buffer_billboard_basis("), + && module.contains("fn render_buffer_billboard_basis("), "Render-buffer billboards must receive particle orientation streams for Unity alignment modes" ); assert!( - src.contains("pd::particle_alignment(d)") - && src.contains("fn screen_clamped_billboard_size("), + module.contains("pd::particle_alignment(draw)") + && module.contains("fn screen_clamped_billboard_size("), "Render-buffer billboards must apply renderer alignment and screen-size clamp metadata" ); @@ -497,22 +499,12 @@ fn billboard_render_buffer_variant_bits_keep_native_and_compatibility_layout() - ("BILLBOARDUNLIT_KW_VERTEX_LINEAR_COLOR", 13), ("BILLBOARDUNLIT_KW_VERTEX_SRGB_COLOR", 14), ("BILLBOARDUNLIT_KW_VERTEXCOLORS", 15), - ("BILLBOARDUNLIT_KW_RENDER_BUFFER", 16), ] { assert!( src.contains(&format!("const {constant_name}: u32 = 1u << {bit_index}u;")), "{constant_name} must keep Billboard/Unlit's native sorted keyword bit order" ); } - assert!( - src.contains("const BILLBOARDUNLIT_KW_SIMPLE_LIT: u32 = 1u << 17u;"), - "Non-Unlit shading support for render-buffer billboards must use compatibility bit after native Billboard/Unlit keywords" - ); - assert!( - src.contains("const BILLBOARDUNLIT_KW_UNLIT_MASK_TEXTURE_CLIP: u32 = 1u << 18u;") - && src.contains("const BILLBOARDUNLIT_KW_UNLIT_MASK_TEXTURE_MUL: u32 = 1u << 19u;"), - "Unlit mask support for render-buffer billboards must use compatibility bits after native Billboard/Unlit keywords" - ); Ok(()) } @@ -522,13 +514,9 @@ fn billboard_render_buffer_preserves_fragment_alpha_and_fog_behavior() -> io::Re let src = material_source("billboardunlit.wgsl")?; assert!( - src.contains("if (kw_ALPHATEST() && !mask_clip && col.a < mat._Cutoff)"), + src.contains("if (kw_ALPHATEST() && col.a < mat._Cutoff)"), "Billboard/Unlit alpha test must match Unity clip(col.a - _Cutoff) equality semantics" ); - assert!( - src.contains("if (mask_clip && mask_lum <= mat._Cutoff)"), - "Unlit mask compatibility for render-buffer billboards must preserve Unlit's mask discard threshold" - ); assert!( src.contains("#import renderide::frame::fog as rfog") && src.contains("out.fog_coord = rfog::coord_from_world_pos(world_p, layer);") @@ -541,22 +529,22 @@ fn billboard_render_buffer_preserves_fragment_alpha_and_fog_behavior() -> io::Re #[test] fn billboard_render_buffer_alignment_matches_unity_modes() -> io::Result<()> { - let src = material_source("billboardunlit.wgsl")?; + let module = module_source("billboard/vertex.wgsl")?; assert!( - src.contains("return facing_basis(center_world, view_layer, pointdata.z, false);"), - "Render-buffer Facing alignment must keep Unity-style roll disabled" + module.contains("return facing_basis(center_world, view_layer, pointdata.z);"), + "Render-buffer Facing alignment must keep Unity-style roll" ); assert!( - src.contains("fn direction_stretch_particle_basis(") - && src.contains("let velocity_world = mv::model_vector(d, point_forward_upz.xyz);") - && src.contains( + module.contains("fn direction_stretch_particle_basis(") + && module.contains("let velocity_world = mv::model_vector(draw, point_forward_upz.xyz);") + && module.contains( "let velocity_in_plane = velocity_world - to_camera * dot(velocity_world, to_camera);" ) - && src.contains("let view_up_in_plane = view_up - to_camera * dot(view_up, to_camera);") - && src.contains("up = rmath::safe_normalize(cross(to_camera, right), up);") - && src.contains( - "return direction_stretch_particle_basis(d, center_world, point_forward_upz, view_layer);" + && module.contains("let view_up_in_plane = view_up - to_camera * dot(view_up, to_camera);") + && module.contains("up = rmath::safe_normalize(cross(to_camera, right), up);") + && module.contains( + "return direction_stretch_particle_basis(draw, center_world, point_forward_upz, view_layer);" ), "Render-buffer Direction alignment must project velocity into the camera-facing stretch plane" ); @@ -564,22 +552,6 @@ fn billboard_render_buffer_alignment_matches_unity_modes() -> io::Result<()> { Ok(()) } -#[test] -fn billboard_render_buffer_supports_simple_lit_non_unlit_sources() -> io::Result<()> { - let src = material_source("billboardunlit.wgsl")?; - - assert!( - src.contains("if (kw_SIMPLE_LIT())") - && src.contains("out.world_p = world_p;") - && src.contains("out.n = rmath::safe_normalize(cross(axes.right, axes.up)") - && src.contains("let base = clamp(col.rgb, vec3(0.0), vec3(1.0));") - && src.contains("dl::shade_clustered_diffuse"), - "Billboard/Unlit must offer simple shading capabilities for non-Unlit source materials" - ); - - Ok(()) -} - #[test] fn mesh_particle_vertex_module_applies_alignment_and_color_metadata() -> io::Result<()> { let src = module_source("mesh/vertex.wgsl")?; diff --git a/crates/renderide/tests/shader_module_audit/pbs/fur_toon.rs b/crates/renderide/tests/shader_module_audit/pbs/fur_toon.rs index 8cc3ff611..162ac01be 100644 --- a/crates/renderide/tests/shader_module_audit/pbs/fur_toon.rs +++ b/crates/renderide/tests/shader_module_audit/pbs/fur_toon.rs @@ -332,7 +332,7 @@ fn classic_furfx_modules_keep_source_parity_details() -> io::Result<()> { let common = module_source("fur/common.wgsl")?; for required in [ "@location(9) base_world_pos: vec3,", - "let base_world_pos = mv::world_position(draw, pos).xyz;", + "base_world_pos = mv::world_position(draw, pos).xyz;", "out.shell_noise_uv = uv0 + shell_noise_offset;", "out.base_world_pos = base_world_pos;", "var color = tex_rgb;\n color = color - shadow_rgb * hair_coloring;\n color = color - vec3(pow(1.0 - fur_multiplier, 4.0) * hair_shading);\n color = color * tint_rgb;", @@ -375,6 +375,22 @@ fn classic_furfx_modules_keep_source_parity_details() -> io::Result<()> { Ok(()) } +#[test] +fn furfx_supports_billboard_rendering() -> io::Result<()> { + let common = module_source("fur/common.wgsl")?; + for required in [ + "if (bv::kw_RENDER_BUFFER(variant_bits))", + "billboard_vertex = bv::render_buffer_billboard_vertex(", + "base_world_pos = billboard_vertex.world_pos.xyz;", + ] { + assert!( + common.contains(required), + "fur/common.wgsl must be compatible with billboard rendering `{required}`" + ); + } + Ok(()) +} + #[test] fn furfx_shell_force_uses_projection_local_offset() -> io::Result<()> { let common = module_source("fur/common.wgsl")?; diff --git a/crates/renderide/tests/shader_module_audit/pbs/materials.rs b/crates/renderide/tests/shader_module_audit/pbs/materials.rs index 8714fd59b..17e802a92 100644 --- a/crates/renderide/tests/shader_module_audit/pbs/materials.rs +++ b/crates/renderide/tests/shader_module_audit/pbs/materials.rs @@ -361,8 +361,7 @@ fn pbs_metallic_uses_uvsec_for_detail_uvs() -> io::Result<()> { "_UVSec: f32", "@location(5) uv1: vec2", "pdet::detail_uv(uv0, uv1, mat._UVSec, mat._DetailAlbedoMap_ST)", - "mv::world_uv2_vertex_main(instance_index, view_idx, pos, n, t, uv0, uv1)", - "mv::world_uv2_vertex_main(instance_index, 0u, pos, n, t, uv0, uv1)", + "mv::world_uv2_vertex_main(instance_index, view_layer, pos, n, t, uv0, uv1)", ] { assert!( src.contains(required), @@ -499,3 +498,33 @@ fn pbs_standard_parallax_uses_tangent_space_view_dir() -> io::Result<()> { Ok(()) } + +#[test] +fn most_pbs_shaders_support_billboard_rendering() -> io::Result<()> { + for file_name in [ + "pbsmetallic.wgsl", + "pbsspecular.wgsl", + "pbscolormask.wgsl", + "pbscolorsplat.wgsl", + "pbsdualsided.wgsl", + "pbsintersect.wgsl", + "pbslerp.wgsl", + "pbsmultiuv.wgsl", + "pbsrim.wgsl", + "pbsslice.wgsl", + "pbsstencil.wgsl", + "pbstriplanar.wgsl", + "pbsvertexcolortransparent.wgsl", + ] { + let src = material_source(file_name)?; + assert!( + src.contains("#import renderide::billboard::vertex as bv"), + "{file_name} should import the billboard vertex module" + ); + assert!( + src.contains("if (bv::kw_RENDER_BUFFER(mat._RenderideVariantBits))"), + "{file_name} should use billboard vertex conversions if the variant bit is specified" + ); + } + Ok(()) +} diff --git a/crates/renderide/tests/shader_module_audit/tangent_basis.rs b/crates/renderide/tests/shader_module_audit/tangent_basis.rs index 5dea50c57..6ddab065b 100644 --- a/crates/renderide/tests/shader_module_audit/tangent_basis.rs +++ b/crates/renderide/tests/shader_module_audit/tangent_basis.rs @@ -92,8 +92,7 @@ fn fresnel_normal_mapped_shaders_use_normal_matrix_vertex_path() -> io::Result<( for file_name in ["fresnellerp.wgsl", "overlayfresnel.wgsl"] { let src = material_source(file_name)?; assert!( - src.contains("mv::world_vertex_main(instance_index, view_idx, pos, n, t, uv)") - && src.contains("mv::world_vertex_main(instance_index, 0u, pos, n, t, uv)"), + src.contains("mv::world_vertex_main(instance_index, view_layer, pos, n, t, uv)"), "{file_name} must use the standard world vertex helper so normals use the normal matrix" ); assert!(