*/}}
Ver código fonte

gles integer texture shader stuff

YimingWu 3 meses atrás
pai
commit
e27357ba1a
2 arquivos alterados com 19 adições e 1 exclusões
  1. 7 1
      la_tns_kernel.c
  2. 12 0
      resources/la_tns_shaders.cpp

+ 7 - 1
la_tns_kernel.c

@@ -388,7 +388,13 @@ char* tnsEnsureShaderCommoms(char* Content, char* Library, char* Material){
     c=strSub(c1,"#with LA_SHADER_LIB_FXAA",LA_SHADER_LIB_FXAA); free(c1);
     c1=strSub(c,"#with TNS_SHADER_MATERIAL",Material?Material:""); free(c);
     c=strSub(c1,"#with TNS_SHADER_LIBRARY",Library?Library:""); free(c1);
-    return c;
+#ifdef LA_USE_GLES
+    const char uint_texture_selection[] = "#define GLES_UINT_TEXTURE";
+#else
+    const char uint_texture_selection[] = "";
+#endif
+    c1=strSub(c,"#with TNS_GLES_UINT_TEXTURE",uint_texture_selection); free(c);
+    return c1;
 }
 int tnsNewVertexShader(char *Content){
     int status = 0;

+ 12 - 0
resources/la_tns_shaders.cpp

@@ -701,6 +701,7 @@ layout(location = 2) out vec3 outGPos;
 
 #with TNS_SHADER_COLOR_COMMON
 #with TNS_SHADER_LIBRARY
+#with TNS_GLES_UINT_TEXTURE
 
 vec3 ConvertColorSpace(vec3 color){
     if(InputColorSpace!=OutputColorSpace){
@@ -726,6 +727,13 @@ vec3 ConvertColorSpace(vec3 color){
     }
     return color;
 }
+
+#ifdef GLES_UINT_TEXTURE
+vec4 cunpack(uint d){
+    return vec4(float(d&0xFFu)/255.,float((d>>8u)&0xFFu)/255.,float((d>>16u)&0xFFu)/255.,float((d>>24u)&0xFFu)/255.);
+}
+#endif
+
 void main(){
     vec4 color=vec4(1,0,1,1);
     if(TextureMode==0){ color = fColor; if(UseHalftone>0.) color.a=HalftoneSingle(color.a,htsize,rad(7.),0.); }
@@ -740,7 +748,11 @@ void main(){
         color/=float(SampleAmount);
         if(MultiplyColor!=0){color*=fColor;}
     }else if(TextureMode==4){
+#ifdef GLES_UINT_TEXTURE
+		color=cunpack(texture(TexColorUI,fUV.st).r);
+#else
 		color=vec4(texture(TexColorUI,fUV.st))/vec4(65535.);
+#endif
         if(MultiplyColor!=0){color*=fColor;}
 	}else if(TextureMode==101){ // YUYV
 		ivec2 tsize = textureSize(TexColor,0);