renderer/common/sprite_batch: replace tex_aux array in shaders with plain samplers
SDL_gpu doesn't support sampler arrays
This commit is contained in:
parent
cbdff3ca41
commit
26959c4a1f
7 changed files with 25 additions and 10 deletions
|
@ -37,7 +37,9 @@ OUT(0) vec4 fragColor;
|
|||
UNIFORM(0) sampler2D tex;
|
||||
|
||||
// see NUM_SPRITE_AUX_TEXTURES in api.h.
|
||||
UNIFORM(64) sampler2D tex_aux[3];
|
||||
UNIFORM(64) sampler2D tex_aux0;
|
||||
UNIFORM(65) sampler2D tex_aux1;
|
||||
UNIFORM(66) sampler2D tex_aux2;
|
||||
|
||||
VARYING(0) vec2 texCoordRaw;
|
||||
VARYING(1) vec2 texCoord;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include "../lib/pbr.glslh"
|
||||
|
||||
#define tex_diffuse tex
|
||||
#define tex_ambient tex_aux[0]
|
||||
#define tex_normal tex_aux[1]
|
||||
#define tex_roughness tex_aux[2]
|
||||
#define tex_ambient tex_aux0
|
||||
#define tex_normal tex_aux1
|
||||
#define tex_roughness tex_aux2
|
||||
|
||||
UNIFORM(1) int light_count;
|
||||
UNIFORM(2) vec3 light_positions[PBR_MAX_LIGHTS];
|
||||
|
|
|
@ -26,12 +26,12 @@ void spriteMain(out vec4 fragColor) {
|
|||
vec2 base_noise_coord = gl_FragCoord.xy / r_viewport.zw;
|
||||
|
||||
vec2 clknoise_coord = vec2(1, 20) * base_noise_coord + noise_ofs + vec2(globaltime);
|
||||
float clk = fairy.a * texture(tex_aux[0], clknoise_coord).r;
|
||||
float clk = fairy.a * texture(tex_aux0, clknoise_coord).r;
|
||||
vec3 n = vec3(0.5, 0.7, 1.0) * clk;
|
||||
fairy.rgb = mix(fairy.rgb, lum(fairy.rgb) * n, p_cloak);
|
||||
|
||||
vec2 maskcoord = 4 * base_noise_coord + noise_ofs;
|
||||
float mask = texture(tex_aux[0], maskcoord).r;
|
||||
float mask = texture(tex_aux0, maskcoord).r;
|
||||
float m1 = 1 - smoothstep(p_summon, p_summon + 0.2, mask);
|
||||
float m2 = 1 - smoothstep(p_summon, p_summon + 0.1, mask);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
float sampleNoise(vec2 tc) {
|
||||
tc.y *= fwidth(tc.x) / fwidth(tc.y);
|
||||
return texture(tex_aux[0], tc).r;
|
||||
return texture(tex_aux0, tc).r;
|
||||
}
|
||||
|
||||
void spriteMain(out vec4 fragColor) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
float sampleNoise(vec2 tc) {
|
||||
tc.y *= fwidth(tc.x) / fwidth(tc.y);
|
||||
return texture(tex_aux[0], tc).r;
|
||||
return texture(tex_aux0, tc).r;
|
||||
}
|
||||
|
||||
void spriteMain(out vec4 fragColor) {
|
||||
|
|
|
@ -32,5 +32,5 @@ void spriteMain(out vec4 fragColor) {
|
|||
// The overlay coordinates are outside of [0,1] in the padding region, so we make sure there are no wrap around artifacts when a bit of text is distorted to this region.
|
||||
tc_overlay = clamp(tc_overlay, 0.01, 0.99);
|
||||
|
||||
fragColor *= clamp((texture(tex_aux[0], tc_overlay).r + 0.5) * 2.5 * t-0.5, 0.0, 1.0);
|
||||
fragColor *= clamp((texture(tex_aux0, tc_overlay).r + 0.5) * 2.5 * t-0.5, 0.0, 1.0);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "sprite_batch_internal.h"
|
||||
|
||||
#include "../api.h"
|
||||
#include "util.h"
|
||||
#include "util/glm.h"
|
||||
#include "resource/sprite.h"
|
||||
|
||||
|
@ -142,12 +143,24 @@ void r_flush_sprites(void) {
|
|||
_r_sprite_batch.frame_stats.flushes++;
|
||||
#endif
|
||||
|
||||
static const char *const tex_aux_names[] = {
|
||||
"tex_aux0",
|
||||
"tex_aux1",
|
||||
"tex_aux2",
|
||||
};
|
||||
|
||||
static_assert(ARRAY_SIZE(tex_aux_names) == ARRAY_SIZE(_r_sprite_batch.aux_textures));
|
||||
|
||||
r_state_push();
|
||||
r_mat_proj_push_premade(_r_sprite_batch.projection);
|
||||
|
||||
r_shader_ptr(NOT_NULL(_r_sprite_batch.shader));
|
||||
r_uniform_sampler("tex", _r_sprite_batch.primary_texture);
|
||||
r_uniform_sampler_array("tex_aux", 0, R_NUM_SPRITE_AUX_TEXTURES, _r_sprite_batch.aux_textures);
|
||||
|
||||
for(uint i = 0; i < ARRAY_SIZE(tex_aux_names); ++i) {
|
||||
r_uniform_sampler(tex_aux_names[i], _r_sprite_batch.aux_textures[i]);
|
||||
}
|
||||
|
||||
r_framebuffer(_r_sprite_batch.framebuffer);
|
||||
r_blend(_r_sprite_batch.blend);
|
||||
r_capabilities(_r_sprite_batch.capbits);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue