@@ -235,30 +235,66 @@ vs_output vs_main_multi( vs_input_multi input, vs_instance_input instance_input
235
235
vs_output output;
236
236
237
237
float4x4 wvp = mul( world_matrix, vp_matrix );
238
+ float4x4 wm = world_matrix;
238
239
239
- output.position = mul( input.position, wvp );
240
- output.world_pos = mul( input.position, world_matrix );
240
+ if:(INSTANCED)
241
+ {
242
+ float4x4 instance_world_mat;
243
+ unpack_vb_instance_mat(
244
+ instance_world_mat,
245
+ instance_input.world_matrix_0,
246
+ instance_input.world_matrix_1,
247
+ instance_input.world_matrix_2,
248
+ instance_input.world_matrix_3
249
+ );
250
+
251
+ wvp = mul( instance_world_mat, vp_matrix );
252
+ wm = instance_world_mat;
253
+
254
+ output.colour = instance_input.user_data2;
255
+ }
241
256
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]);
257
+ if:(SKINNED)
258
+ {
259
+ float4 sp = skin_pos(input.position, input.blend_weights, input.blend_indices);
260
+
261
+ output.tangent = input.tangent.xyz;
262
+ output.bitangent = input.bitangent.xyz;
263
+ output.normal = input.normal.xyz;
264
+
265
+ skin_tbn(output.tangent, output.bitangent, output.normal, input.blend_weights, input.blend_indices);
266
+
267
+ output.position = mul( sp, vp_matrix );
268
+ output.world_pos = sp;
269
+ }
270
+
271
+ if:(!SKINNED)
272
+ {
273
+ output.position = mul( input.position, wvp );
274
+ output.world_pos = mul( input.position, wm );
275
+
276
+ float3x3 wrm = to_3x3(wm);
277
+ wrm[0] = normalize(wrm[0]);
278
+ wrm[1] = normalize(wrm[1]);
279
+ wrm[2] = normalize(wrm[2]);
280
+
281
+ output.normal = mul( input.normal.xyz, wrm );
282
+ output.tangent = mul( input.tangent.xyz, wrm );
283
+ output.bitangent = mul( input.bitangent.xyz, wrm );
284
+
285
+ output.texcoord = float4(input.texcoord.x, 1.0 - input.texcoord.y,
286
+ input.texcoord.z, 1.0 - input.texcoord.w );
287
+ }
246
288
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
289
if:(UV_SCALE)
257
290
{
258
291
output.texcoord *= float4(m_uv_scale.x, m_uv_scale.y, m_uv_scale.x, m_uv_scale.y);
259
292
}
260
293
261
- output.colour = m_albedo;
294
+ if:(!INSTANCED)
295
+ {
296
+ output.colour = m_albedo;
297
+ }
262
298
263
299
return output;
264
300
}
@@ -612,21 +648,31 @@ pmfx:
612
648
"permutations":
613
649
{
614
650
"SKINNED": [31, [0,1]],
615
- "INSTANCED": [30, [0,1]]
616
- }
617
- },
618
-
619
- "forward_lit_uv_scale":
620
- {
621
- "inherit" : "forward_lit",
622
- "constants":
623
- {
624
- "uv_scale": { "type": "float2", "widget": "slider", "min": 0, "max": 100, "default": 1.0 }
651
+ "INSTANCED": [30, [0,1]],
652
+ "UV_SCALE": [1, [0,1]],
653
+ "SSS": [2, [0,1]],
654
+ "SDF_SHADOW": [3, [0,1]]
625
655
},
626
656
627
- "defines": ["UV_SCALE"]
657
+ "constants":
658
+ {
659
+ "permutation(SSS)":
660
+ {
661
+ "sss_scale": { "type": "float", "widget": "slider", "min": 0, "max": 500, "default": 1.0 }
662
+ },
663
+
664
+ "permutation(SDF_SHADOW)":
665
+ {
666
+ "surface_offset": { "type": "float", "widget": "slider", "min": 0, "max": 1, "default": 1.0 }
667
+ },
668
+
669
+ "permutation(UV_SCALE)":
670
+ {
671
+ "uv_scale": { "type": "float2", "widget": "slider", "min": 0, "max": 100, "default": 1.0 }
672
+ }
673
+ }
628
674
},
629
-
675
+
630
676
"forward_lit_sdf_shadow":
631
677
{
632
678
"inherit": "forward_lit",
0 commit comments