summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-07-10 15:16:57 +0200
committerGitHub <noreply@github.com>2019-07-10 15:16:57 +0200
commit351163ce9530acd201c99be5b1082198c5449ef2 (patch)
tree7107d46b5c27e232ef2eca3e5a8e42754a6eaeb1
parent9496e29326ec483a77b1246874623f09d74b9363 (diff)
parentd5cb280313201f1596765a5c168812dd84439e36 (diff)
Merge pull request #30487 from szamq/master
Fix get_data layer argument when texture is TEXTURE_TYPE_2D_ARRAY
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index c4cfd1e765..994ed25f01 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -1144,8 +1144,12 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
shaders.copy.set_conditional(CopyShaderGLES3::USE_TEXTURE2DARRAY, texture->type == VS::TEXTURE_TYPE_2D_ARRAY);
shaders.copy.bind();
- // calculate the normalized z coordinate for the layer
- float layer = (float)p_layer / (float)texture->alloc_depth;
+ float layer;
+ if (texture->type == VS::TEXTURE_TYPE_2D_ARRAY)
+ layer = (float)p_layer;
+ else
+ // calculate the normalized z coordinate for the layer
+ layer = (float)p_layer / (float)texture->alloc_depth;
shaders.copy.set_uniform(CopyShaderGLES3::LAYER, layer);