(flat) int for samplerindex

This commit is contained in:
saschawillems 2016-08-30 20:45:23 +02:00
parent 1461731a0e
commit 5dd928b7f4
5 changed files with 5 additions and 6 deletions

View file

@ -8,12 +8,11 @@ layout (set = 0, binding = 2) uniform sampler samplers[3];
layout (location = 0) in vec2 inUV; layout (location = 0) in vec2 inUV;
layout (location = 1) in float inLodBias; layout (location = 1) in float inLodBias;
layout (location = 2) in float inSamplerIndex; layout (location = 2) flat in int inSamplerIndex;
layout (location = 0) out vec4 outFragColor; layout (location = 0) out vec4 outFragColor;
void main() void main()
{ {
highp int samplerIndex = int(inSamplerIndex); outFragColor = texture(sampler2D(textureColor, samplers[inSamplerIndex]), inUV, inLodBias);
outFragColor = texture(sampler2D(textureColor, samplers[samplerIndex]), inUV, inLodBias);
} }

View file

@ -13,12 +13,12 @@ layout (binding = 0) uniform UBO
mat4 view; mat4 view;
mat4 model; mat4 model;
float lodBias; float lodBias;
float samplerIndex; int samplerIndex;
} ubo; } ubo;
layout (location = 0) out vec2 outUV; layout (location = 0) out vec2 outUV;
layout (location = 1) out float outLodBias; layout (location = 1) out float outLodBias;
layout (location = 2) out float outSamplerIndex; layout (location = 2) flat out int outSamplerIndex;
out gl_PerVertex out gl_PerVertex
{ {

View file

@ -67,7 +67,7 @@ public:
glm::mat4 view; glm::mat4 view;
glm::mat4 model; glm::mat4 model;
float lodBias = 0.0f; float lodBias = 0.0f;
float samplerIndex = 2.0f; uint32_t samplerIndex = 2;
} uboVS; } uboVS;
struct { struct {