@@ -56,12 +56,30 @@ struct vs_input_skinned
5656
5757struct vs_instance_input
5858{
59- float4 world_matrix_0 : TEXCOORD6;
60- float4 world_matrix_1 : TEXCOORD7;
61- float4 world_matrix_2 : TEXCOORD8;
62- float4 world_matrix_3 : TEXCOORD9;
63- float4 user_data : TEXCOORD10;
64- float4 user_data2 : TEXCOORD11;
59+ if:(INSTANCED)
60+ {
61+ float4 world_matrix_0 : TEXCOORD6;
62+ float4 world_matrix_1 : TEXCOORD7;
63+ float4 world_matrix_2 : TEXCOORD8;
64+ float4 world_matrix_3 : TEXCOORD9;
65+ float4 user_data : TEXCOORD10;
66+ float4 user_data2 : TEXCOORD11;
67+ }
68+ };
69+
70+ struct vs_input_multi
71+ {
72+ float4 position : POSITION;
73+ float4 normal : TEXCOORD0;
74+ float4 texcoord : TEXCOORD1;
75+ float4 tangent : TEXCOORD2;
76+ float4 bitangent : TEXCOORD3;
77+
78+ if:(SKINNED)
79+ {
80+ float4 blend_indices : TEXCOORD4;
81+ float4 blend_weights : TEXCOORD5;
82+ }
6583};
6684
6785struct ps_output
@@ -212,6 +230,39 @@ vs_output vs_main_instanced( vs_input input, vs_instance_input instance_input )
212230 return output;
213231}
214232
233+ vs_output vs_main_multi( vs_input_multi input, vs_instance_input instance_input )
234+ {
235+ vs_output output;
236+
237+ float4x4 wvp = mul( world_matrix, vp_matrix );
238+
239+ output.position = mul( input.position, wvp );
240+ output.world_pos = mul( input.position, world_matrix );
241+
242+ float3x3 world_rot_mat = to_3x3(world_matrix);
243+ world_rot_mat[0] = normalize(world_rot_mat[0]);
244+ world_rot_mat[1] = normalize(world_rot_mat[1]);
245+ world_rot_mat[2] = normalize(world_rot_mat[2]);
246+
247+ float3x3 rotation_matrix = world_rot_mat;
248+
249+ output.normal = mul( input.normal.xyz, rotation_matrix );
250+ output.tangent = mul( input.tangent.xyz, rotation_matrix );
251+ output.bitangent = mul( input.bitangent.xyz, rotation_matrix );
252+
253+ output.texcoord = float4(input.texcoord.x, 1.0f - input.texcoord.y,
254+ input.texcoord.z, 1.0f - input.texcoord.w );
255+
256+ if:(UV_SCALE)
257+ {
258+ output.texcoord *= float4(m_uv_scale.x, m_uv_scale.y, m_uv_scale.x, m_uv_scale.y);
259+ }
260+
261+ output.colour = m_albedo;
262+
263+ return output;
264+ }
265+
215266float3 transform_ts_normal( float3 t, float3 b, float3 n, float3 ts_normal )
216267{
217268 float3x3 tbn;
@@ -553,6 +604,18 @@ pmfx:
553604 }
554605 },
555606
607+ "forward_lit_multi":
608+ {
609+ "inherit" : "forward_lit",
610+ "vs" : "vs_main_multi",
611+
612+ "permutations":
613+ {
614+ "SKINNED": [31, [0,1]],
615+ "INSTANCED": [30, [0,1]]
616+ }
617+ },
618+
556619 "forward_lit_uv_scale":
557620 {
558621 "inherit" : "forward_lit",
@@ -583,6 +646,8 @@ pmfx:
583646 "vs": "vs_main_instanced",
584647 "ps": "ps_forward_lit",
585648
649+ "defines": ["INSTANCED"],
650+
586651 "inherit_constants": ["forward_lit"]
587652 },
588653
0 commit comments