@@ -118,18 +118,9 @@ function uniforms_bind_render_target(rt: render_target_t, context: shader_contex
118118 for ( let j : i32 = 0 ; j < tus . length ; ++ j ) { // Set texture
119119 if ( sampler_id == tus [ j ] . name ) {
120120 let is_image : bool = tus [ j ] . image_uniform ;
121- let params_set : bool = false ;
122-
123- if ( rt . depth > 1 ) { // sampler3D
124- g4_set_tex_3d_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . LINEAR , tex_filter_t . ANISOTROPIC , mip_map_filter_t . LINEAR ) ;
125- params_set = true ;
126- }
127121
128122 if ( is_image ) {
129123 g4_set_image_tex ( context . _ . tex_units [ j ] , rt . _image ) ; // image2D/3D
130- // Multiple voxel volumes, always set params
131- g4_set_tex_3d_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . LINEAR , tex_filter_t . POINT , mip_map_filter_t . LINEAR ) ;
132- params_set = true ;
133124 }
134125 else if ( attach_depth ) {
135126 g4_set_tex_depth ( context . _ . tex_units [ j ] , rt . _image ) ; // sampler2D
@@ -138,33 +129,40 @@ function uniforms_bind_render_target(rt: render_target_t, context: shader_contex
138129 g4_set_tex ( context . _ . tex_units [ j ] , rt . _image ) ; // sampler2D
139130 }
140131
141- if ( ! params_set && rt . mipmaps == true && ! is_image ) {
132+ if ( rt . depth > 1 ) { // sampler3D
133+ g4_set_tex_3d_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . LINEAR , tex_filter_t . ANISOTROPIC , mip_map_filter_t . LINEAR ) ;
134+ continue ;
135+ }
136+
137+ if ( is_image ) {
138+ // Multiple voxel volumes, always set params
139+ g4_set_tex_3d_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . LINEAR , tex_filter_t . POINT , mip_map_filter_t . LINEAR ) ;
140+ continue ;
141+ }
142+
143+ if ( rt . mipmaps ) {
142144 g4_set_tex_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . LINEAR , tex_filter_t . LINEAR , mip_map_filter_t . LINEAR ) ;
143- params_set = true ;
145+ continue ;
144146 }
145147
146- if ( ! params_set ) {
147- if ( starts_with ( rt . name , "bloom" ) ) {
148- // Use bilinear filter for bloom mips to get correct blur
149- g4_set_tex_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . LINEAR , tex_filter_t . LINEAR , mip_map_filter_t . LINEAR ) ;
150- params_set = true ;
151- }
152- else if ( attach_depth ) {
153- g4_set_tex_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . POINT , tex_filter_t . POINT , mip_map_filter_t . NONE ) ;
154- params_set = true ;
155- }
148+ if ( starts_with ( rt . name , "bloom" ) ) {
149+ // Use bilinear filter for bloom mips to get correct blur
150+ g4_set_tex_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . LINEAR , tex_filter_t . LINEAR , mip_map_filter_t . LINEAR ) ;
151+ continue ;
156152 }
157153
158- if ( ! params_set ) {
159- // No filtering when sampling render targets
160- let oc : _shader_override_t = context . _ . override_context ;
161- let allow_params : bool = oc == null || oc . shared_sampler == null || oc . shared_sampler == sampler_id ;
162- if ( allow_params ) {
163- let addressing : tex_addressing_t = ( oc != null && oc . addressing == "repeat" ) ? tex_addressing_t . REPEAT : tex_addressing_t . CLAMP ;
164- let filter : tex_filter_t = ( oc != null && oc . filter == "point" ) ? tex_filter_t . POINT : tex_filter_t . LINEAR ;
165- g4_set_tex_params ( context . _ . tex_units [ j ] , addressing , addressing , filter , filter , mip_map_filter_t . NONE ) ;
166- }
167- params_set = true ;
154+ if ( attach_depth ) {
155+ g4_set_tex_params ( context . _ . tex_units [ j ] , tex_addressing_t . CLAMP , tex_addressing_t . CLAMP , tex_filter_t . POINT , tex_filter_t . POINT , mip_map_filter_t . NONE ) ;
156+ continue ;
157+ }
158+
159+ // No filtering when sampling render targets
160+ let oc : _shader_override_t = context . _ . override_context ;
161+ let allow_params : bool = oc == null || oc . shared_sampler == null || oc . shared_sampler == sampler_id ;
162+ if ( allow_params ) {
163+ let addressing : tex_addressing_t = ( oc != null && oc . addressing == "repeat" ) ? tex_addressing_t . REPEAT : tex_addressing_t . CLAMP ;
164+ let filter : tex_filter_t = ( oc != null && oc . filter == "point" ) ? tex_filter_t . POINT : tex_filter_t . LINEAR ;
165+ g4_set_tex_params ( context . _ . tex_units [ j ] , addressing , addressing , filter , filter , mip_map_filter_t . NONE ) ;
168166 }
169167 }
170168 }
0 commit comments