@@ -25,10 +25,13 @@ use crate::{
25
25
light:: {
26
26
LightTile , LightTiling , LightTilingDescriptor , LightTilingInvocation , SpotLightCalculation ,
27
27
} ,
28
- math:: { hex_to_vec4, scaled_f32_to_u8, ConstTexture , CpuTexture2d , GpuRng , NonAtomicSlab } ,
28
+ math:: {
29
+ hex_to_vec4, scaled_f32_to_u8, ConstTexture , CpuTexture2d , CpuTexture2dArray , GpuRng ,
30
+ IsVector , NonAtomicSlab ,
31
+ } ,
29
32
pbr:: Material ,
30
33
prelude:: Transform ,
31
- stage:: { Renderlet , Stage , Vertex } ,
34
+ stage:: { Renderlet , RenderletPbrVertexInfo , Stage , Vertex } ,
32
35
} ;
33
36
34
37
use super :: * ;
@@ -736,6 +739,17 @@ fn pedestal() {
736
739
. join ( "pedestal.glb" ) ,
737
740
)
738
741
. unwrap ( ) ;
742
+ let materials = doc. materials . get_vec ( ) ;
743
+ log:: info!( "materials: {materials:#?}" ) ;
744
+ doc. materials . set_item (
745
+ 0 ,
746
+ Material {
747
+ albedo_factor : Vec4 :: ONE ,
748
+ roughness_factor : 1.0 ,
749
+ metallic_factor : 0.0 ,
750
+ ..Default :: default ( )
751
+ } ,
752
+ ) ;
739
753
let camera = doc. cameras . first ( ) . unwrap ( ) ;
740
754
camera. camera . modify ( |cam| {
741
755
cam. set_projection ( Mat4 :: perspective_rh (
@@ -747,9 +761,10 @@ fn pedestal() {
747
761
} ) ;
748
762
749
763
let color = {
750
- let mut c = hex_to_vec4 ( 0xEEDF7AFF ) ;
751
- linear_xfer_vec4 ( & mut c) ;
752
- c
764
+ // let mut c = hex_to_vec4(0xEEDF7AFF);
765
+ // linear_xfer_vec4(&mut c);
766
+ // c
767
+ Vec4 :: ONE
753
768
} ;
754
769
let position = Vec3 :: new ( 0.0 , 1.0 , 0.0 ) ;
755
770
let transform = stage. new_nested_transform ( ) ;
@@ -790,14 +805,89 @@ fn pedestal() {
790
805
..Default :: default ( )
791
806
} )
792
807
. build ( ) ;
808
+ {
809
+ log:: info!( "adding spot light" ) ;
810
+ let spot_desc = SpotLightDescriptor {
811
+ position,
812
+ direction : Vec3 :: NEG_Y ,
813
+ color,
814
+ intensity : 5.0 ,
815
+ ..Default :: default ( )
816
+ } ;
817
+ let spot = stage. new_analytical_light ( spot_desc, None ) ;
818
+ snapshot ( & ctx, & stage, "light/pedestal/spot.png" ) ;
793
819
794
- let light_descriptor = PointLightDescriptor {
795
- position : Vec3 :: ZERO ,
796
- color,
797
- intensity : 10.0 ,
798
- } ;
799
- let _light = stage. new_analytical_light ( light_descriptor, Some ( transform) ) ;
800
- snapshot ( & ctx, & stage, "light/pedestal/point.png" ) ;
820
+ let geometry_slab =
821
+ futures_lite:: future:: block_on ( stage. geometry . slab_allocator ( ) . read ( ..) ) . unwrap ( ) ;
822
+
823
+ let renderlet = doc. renderlets_iter ( ) . next ( ) . unwrap ( ) ;
824
+ log:: info!( "renderlet: {renderlet:#?}" ) ;
825
+ let mut info = RenderletPbrVertexInfo :: default ( ) ;
826
+
827
+ for vertex_index in 0 ..renderlet. get ( ) . vertices_array . len ( ) {
828
+ crate :: stage:: renderlet_vertex (
829
+ renderlet. id ( ) ,
830
+ vertex_index as u32 ,
831
+ & geometry_slab,
832
+ & mut Default :: default ( ) ,
833
+ & mut Default :: default ( ) ,
834
+ & mut Default :: default ( ) ,
835
+ & mut Default :: default ( ) ,
836
+ & mut Default :: default ( ) ,
837
+ & mut Default :: default ( ) ,
838
+ & mut Default :: default ( ) ,
839
+ & mut Default :: default ( ) ,
840
+ & mut Default :: default ( ) ,
841
+ & mut info,
842
+ ) ;
843
+
844
+ if info. out_pos . y == 0.0 {
845
+ break ;
846
+ }
847
+ }
848
+ log:: info!( "info: {info:#?}" ) ;
849
+
850
+ let texture = ConstTexture :: new ( Vec4 :: ONE ) ;
851
+ let material_slab =
852
+ futures_lite:: future:: block_on ( stage. materials . slab_allocator ( ) . read ( ..) ) . unwrap ( ) ;
853
+ let lighting_slab =
854
+ futures_lite:: future:: block_on ( stage. lighting . slab_allocator ( ) . read ( ..) ) . unwrap ( ) ;
855
+ let mut fragment = Vec4 :: ZERO ;
856
+ crate :: pbr:: fragment_impl (
857
+ & texture,
858
+ & ( ) ,
859
+ & texture,
860
+ & ( ) ,
861
+ & texture,
862
+ & ( ) ,
863
+ & texture,
864
+ & ( ) ,
865
+ & texture,
866
+ & ( ) ,
867
+ & geometry_slab,
868
+ & material_slab,
869
+ & lighting_slab,
870
+ info. renderlet_id ,
871
+ info. out_color ,
872
+ info. out_uv0 ,
873
+ info. out_uv1 ,
874
+ info. out_norm ,
875
+ info. out_tangent ,
876
+ info. out_bitangent ,
877
+ info. out_pos ,
878
+ & mut fragment,
879
+ ) ;
880
+
881
+ log:: info!( "fragment: {fragment}" ) ;
882
+ }
883
+
884
+ // let light_descriptor = PointLightDescriptor {
885
+ // position: Vec3::ZERO,
886
+ // color,
887
+ // intensity: 10.0,
888
+ // };
889
+ // let _light = stage.new_analytical_light(light_descriptor, Some(transform));
890
+ // snapshot(&ctx, &stage, "light/pedestal/point.png");
801
891
802
892
// light.transform.modify(|t| t.translation = position);
803
893
0 commit comments