![](/img/trans.png)
[英]Android: How to use samplerExternalOES and sampler2D in same fragment shader
[英]Use 3D Texture for Fragment shader on Android
我需要在 Android 上的片段着色器中使用 3D 紋理,但出現編譯錯誤。 我使用 GLES3.0,我認為它應該支持 3D 紋理。 我的着色器如下所示:
#extension GL_OES_texture_3D : enable
precision mediump float;
uniform sampler3D u_Texture;
沒有#extension GL_OES_texture_3D: enable
我得到錯誤
L0003:保留關鍵字“sampler3D”
使用#extension GL_OES_texture_3D: enable
,我得到了錯誤
S0032:沒有為變量“u_Texture”定義默認精度
即使我使用uniform medium float sampler3D u_Texture
,我也得到了
期待,發現 sampler3D 錯誤。
希望得到您的幫助!
非常感謝。
YL
首先,您必須在着色器程序的第一行中通過版本限定符指定 glsl 版本:
#version 300 es
精度限定符是highp
、 mediump
或lowp
並且必須在類型之前指定。 類型是sampler3D
而不是float
。
宣言
uniform medium float sampler3D u_Texture
有 2 種類型( float
和sampler3D
),因此會導致語法錯誤。
它一定要是
#version 300 es
uniform medium sampler3D u_Texture;
或使用默認精度限定符
#version 300 es
precision mediump sampler3D;
uniform sampler3D u_Texture;
(當然precision mediump float;
也必須指定)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.