|
@@ -531,36 +531,36 @@ vec3 XYZ2Clay(vec3 xyz){
|
|
|
return xyz*mat;
|
|
|
}
|
|
|
|
|
|
-float htsize=HalftoneSize;
|
|
|
+#define htsize HalftoneSize
|
|
|
vec4 rgb2cmyk(vec3 rgb){
|
|
|
- vec4 cmyk; cmyk.w=1-max(max(rgb.r,rgb.g),rgb.b);
|
|
|
- float k1=1-cmyk.w;
|
|
|
+ vec4 cmyk; cmyk.w=1.-max(max(rgb.r,rgb.g),rgb.b);
|
|
|
+ float k1=1.-cmyk.w;
|
|
|
cmyk.r=(k1-rgb.r)/k1; cmyk.g=(k1-rgb.g)/k1; cmyk.b=(k1-rgb.b)/k1;
|
|
|
return cmyk;
|
|
|
}
|
|
|
vec3 cmyk2rgb(vec4 cmyk){
|
|
|
- vec3 rgb; float k1=1-cmyk.w;
|
|
|
- rgb.r=(1-cmyk.r)*k1; rgb.g=(1-cmyk.g)*k1; rgb.b=(1-cmyk.b)*k1;
|
|
|
+ vec3 rgb; float k1=1.-cmyk.w;
|
|
|
+ rgb.r=(1.-cmyk.r)*k1; rgb.g=(1.-cmyk.g)*k1; rgb.b=(1.-cmyk.b)*k1;
|
|
|
return rgb;
|
|
|
}
|
|
|
float rand(vec2 co){
|
|
|
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
|
|
|
}
|
|
|
float HalftoneSingle(float a,float ps,float theta,float sm){
|
|
|
- float psize=ps; vec2 ctr=vec2(psize/2,psize/2); vec2 pt=vec2(psize,psize);
|
|
|
+ float psize=ps; vec2 ctr=vec2(psize/2.,psize/2.); vec2 pt=vec2(psize,psize);
|
|
|
vec2 xy=gl_FragCoord.xy; xy=vec2(sin(theta)*xy.x-cos(theta)*xy.y,cos(theta)*xy.x+sin(theta)*xy.y);
|
|
|
- xy.x=xy.x+rand(xy)/1; xy.y=xy.y+rand(xy)/1; ivec2 xyi=ivec2(int(xy.x/psize),int(xy.y/psize));
|
|
|
+ xy.x=xy.x+rand(xy)/1.; xy.y=xy.y+rand(xy)/1.; ivec2 xyi=ivec2(int(xy.x/psize),int(xy.y/psize));
|
|
|
vec2 xyf=mod(xy,pt);
|
|
|
- float px1=(sm==1)?(3.0f/psize):(0.000001);
|
|
|
- float cmp=(pow(a,1)*psize/2*(1.414+px1)); float fac=distance(xyf,ctr)/cmp;
|
|
|
- return smoothstep(1+px1,1-px1,fac);
|
|
|
+ float px1=(sm==1.)?(3.0f/psize):(0.000001);
|
|
|
+ float cmp=(pow(a,1.)*psize/2.*(1.414+px1)); float fac=distance(xyf,ctr)/cmp;
|
|
|
+ return smoothstep(1.+px1,1.-px1,fac);
|
|
|
}
|
|
|
vec4 halftone(vec4 color){
|
|
|
vec4 cmyk=rgb2cmyk(color.rgb); float a=color.a*(gl_FragCoord.x/400.0f);
|
|
|
- cmyk.r=HalftoneSingle(cmyk.r,htsize,rad(15.0),1);
|
|
|
- cmyk.g=HalftoneSingle(cmyk.g,htsize,rad(75.0),1);
|
|
|
- cmyk.b=HalftoneSingle(cmyk.b,htsize,rad(0),1);
|
|
|
- cmyk.a=HalftoneSingle(cmyk.a,htsize,rad(45.0),1);
|
|
|
+ cmyk.r=HalftoneSingle(cmyk.r,htsize,rad(15.0),1.);
|
|
|
+ cmyk.g=HalftoneSingle(cmyk.g,htsize,rad(75.0),1.);
|
|
|
+ cmyk.b=HalftoneSingle(cmyk.b,htsize,rad(0.),1.);
|
|
|
+ cmyk.a=HalftoneSingle(cmyk.a,htsize,rad(45.0),1.);
|
|
|
color.rgb=cmyk2rgb(cmyk);
|
|
|
//color.a=HalftoneSingle(a,htsize,rad(30),0);
|
|
|
return color;
|
|
@@ -568,7 +568,8 @@ vec4 halftone(vec4 color){
|
|
|
)";
|
|
|
|
|
|
|
|
|
-extern "C" const char* TNS_VERTEX_SIMPLE_MATCAP = R"(#version 330
|
|
|
+extern "C" const char* TNS_VERTEX_SIMPLE_MATCAP = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
uniform mat4 mProjection;
|
|
|
uniform mat4 mModel;
|
|
|
uniform mat4 mView;
|
|
@@ -583,11 +584,13 @@ void main(){
|
|
|
fNormal = normalize(N);
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* TNS_FRAGMENT_SIMPLE_MATCAP = R"(#version 330
|
|
|
+extern "C" const char* TNS_FRAGMENT_SIMPLE_MATCAP = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
smooth in vec3 fNormal;
|
|
|
+out vec4 outColor;
|
|
|
float Interpolate(float between1,float between2,float value1,float value2,float key){
|
|
|
float i = (key-between1)/(between2-between1);
|
|
|
- return value1*(1-i)+value2*i;
|
|
|
+ return value1*(1.-i)+value2*i;
|
|
|
}
|
|
|
void main(){
|
|
|
float value = dot(vec3(0,0,1),fNormal);
|
|
@@ -595,10 +598,11 @@ void main(){
|
|
|
else if(value>=0.65 && value<0.85) value=Interpolate(0.65,0.85,0.15,0.75,value);
|
|
|
else if(value>=0.85 && value<0.95) value=0.75;
|
|
|
else if(value>=0.95) value=0.9;
|
|
|
- gl_FragColor = vec4(vec3(0.84, 0.41, 0.16)*value,1);
|
|
|
+ outColor = vec4(vec3(0.84, 0.41, 0.16)*value,1);
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* TNS_VERTEX_GRID = R"(#version 330
|
|
|
+extern "C" const char* TNS_VERTEX_GRID = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
|
|
|
uniform mat4 mProjection;
|
|
|
uniform mat4 mModel;
|
|
@@ -617,18 +621,19 @@ void main(){
|
|
|
uv = vUV;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* TNS_FRAGMENT_TRANSPARNT_GRID = R"(#version 330
|
|
|
-
|
|
|
+extern "C" const char* TNS_FRAGMENT_TRANSPARNT_GRID = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
in vec4 fColor;
|
|
|
in vec2 uv;
|
|
|
-
|
|
|
+out vec4 outColor;
|
|
|
void main(){
|
|
|
vec4 c = fColor;
|
|
|
- c.a = sin(uv.x)*sin(uv.y)>0?c.a:0;
|
|
|
- gl_FragColor = c;
|
|
|
+ c.a = sin(uv.x)*sin(uv.y)>0.?c.a:0.;
|
|
|
+ outColor = c;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_IMM_VERTEX_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_IMM_VERTEX_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
uniform mat4 mProjection;
|
|
|
uniform mat4 mModel;
|
|
|
uniform mat4 mView;
|
|
@@ -651,9 +656,10 @@ void main(){
|
|
|
fNormal= normalize((mModel * vec4(vNormal,0.)).xyz);
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_IMM_FRAGMENT_SHADER = R"(#version 330
|
|
|
-uniform sampler2D TexColor;\
|
|
|
-uniform sampler2DMS TexColorMS;\
|
|
|
+extern "C" const char* LA_IMM_FRAGMENT_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
+uniform highp sampler2D TexColor;\
|
|
|
+uniform highp sampler2DMS TexColorMS;\
|
|
|
uniform int TextureMode;
|
|
|
uniform int ColorMode;
|
|
|
uniform int MultiplyColor;
|
|
@@ -690,13 +696,13 @@ vec3 ConvertColorSpace(vec3 color){
|
|
|
if(InputColorSpace==0) color=to_linear_srgb(color);
|
|
|
else if(InputColorSpace==1) color=to_linear_clay(color);
|
|
|
}
|
|
|
- vec3 xyz; if(ColorMode==1){ color.y=pow(color.y,max(HCYGamma,1)); color=okhsl_to_linear_srgb(color); }
|
|
|
+ vec3 xyz; if(ColorMode==1){ color.y=pow(color.y,max(HCYGamma,1.)); color=okhsl_to_linear_srgb(color); }
|
|
|
if(InputColorSpace==1){ xyz=Clay2XYZ(color); }
|
|
|
if(InputColorSpace==0){ xyz=sRGB2XYZ(color); }
|
|
|
if(OutputColorSpace==0){ color=to_log_srgb(XYZ2sRGB(xyz)); }
|
|
|
if(OutputColorSpace==1){ color=to_log_clay(XYZ2Clay(xyz)); }
|
|
|
}else{
|
|
|
- if(ColorMode==1){ color.y=pow(color.y,max(HCYGamma,1)); color=okhsl_to_srgb(color); }
|
|
|
+ if(ColorMode==1){ color.y=pow(color.y,max(HCYGamma,1.)); color=okhsl_to_srgb(color); }
|
|
|
else if(ColorMode==0){ color=color; }
|
|
|
else{
|
|
|
if(OutputColorSpace==0){ color=to_log_srgb(color); }
|
|
@@ -704,38 +710,38 @@ vec3 ConvertColorSpace(vec3 color){
|
|
|
}
|
|
|
}
|
|
|
if(ShowStripes!=0){
|
|
|
- if(color.r>1.00001||color.g>1.00001||color.b>1.00001||color.r<0||color.g<0||color.b<0){ color=mix(color,vec3(0.5,0.5,0.5),(sin((gl_FragCoord.x+gl_FragCoord.y)/2)>0)?1:0.5); }
|
|
|
+ if(color.r>1.00001||color.g>1.00001||color.b>1.00001||color.r<0.||color.g<0.||color.b<0.){ color=mix(color,vec3(0.5,0.5,0.5),(sin((gl_FragCoord.x+gl_FragCoord.y)/2.)>0.)?1.:0.5); }
|
|
|
}
|
|
|
return color;
|
|
|
}
|
|
|
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); }
|
|
|
- else if(TextureMode==1){color = vec4(fColor.rgb,fColor.a*texture2D(TexColor,fUV.st).r);}
|
|
|
+ if(TextureMode==0){ color = fColor; if(UseHalftone>0.) color.a=HalftoneSingle(color.a,htsize,rad(7.),0.); }
|
|
|
+ else if(TextureMode==1){color = vec4(fColor.rgb,fColor.a*texture(TexColor,fUV.st).r);}
|
|
|
else if(TextureMode==2){
|
|
|
- color=texture2D(TexColor,fUV.st);
|
|
|
+ color=texture(TexColor,fUV.st);
|
|
|
if(MultiplyColor!=0){color*=fColor;}
|
|
|
}else if(TextureMode==3){
|
|
|
color=vec4(0,0,0,0);
|
|
|
ivec2 texSize = textureSize(TexColorMS);
|
|
|
- for(int i=0;i<SampleAmount;i++){ vec4 res=texelFetch(TexColorMS, ivec2(fUV * texSize),i); if(res[0]>-1e19) color+=res; };
|
|
|
- color/=SampleAmount;
|
|
|
+ for(int i=0;i<SampleAmount;i++){ vec4 res=texelFetch(TexColorMS, ivec2(fUV * vec2(texSize)),i); if(res[0]>-1e19) color+=res; };
|
|
|
+ color/=float(SampleAmount);
|
|
|
if(MultiplyColor!=0){color*=fColor;}
|
|
|
}
|
|
|
if(UseNormal!=0){
|
|
|
- color.a=HalftoneSingle(color.a,htsize,rad(7),0);
|
|
|
- if(color.a==0) discard;
|
|
|
+ color.a=HalftoneSingle(color.a,htsize,rad(7.),0.);
|
|
|
+ if(color.a==0.) discard;
|
|
|
float light_factor=dot(fNormal,vec3(0,0,1));
|
|
|
vec3 vd=uViewDir;
|
|
|
if(length(uViewDir)<0.5){ vd=fGPos-uViewPos; }
|
|
|
float view=dot(fNormal,vd);
|
|
|
float factor=abs(light_factor);
|
|
|
- if(light_factor*view>0){ factor=0; }
|
|
|
+ if(light_factor*view>0.){ factor=0.; }
|
|
|
color=vec4(color.rgb*mix(0.2,1.,factor),color.a);
|
|
|
- vec3 oNormal=fNormal; if(view<0){ oNormal=-fNormal; }
|
|
|
+ vec3 oNormal=fNormal; if(view<0.){ oNormal=-fNormal; }
|
|
|
outNormal = oNormal;
|
|
|
}
|
|
|
- color=vec4(ConvertColorSpace(color.rgb),color.a); color.a=clamp(color.a,0,1);
|
|
|
+ color=vec4(ConvertColorSpace(color.rgb),color.a); color.a=clamp(color.a,0.,1.);
|
|
|
if(Composing!=0){
|
|
|
if(color.rgb!=vec3(0,0,0)){
|
|
|
//vec3 cl=srgb_to_okhsl(color.rgb);
|
|
@@ -755,7 +761,8 @@ void main(){
|
|
|
outGPos = fGPos;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_OBJECT_FRAGMENT_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_OBJECT_FRAGMENT_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
uniform int UseNormal;
|
|
|
uniform float UseHalftone;
|
|
|
uniform float HalftoneSize;
|
|
@@ -797,7 +804,8 @@ void main(){
|
|
|
outColor = color; outGPos = fGPos;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_FLOOR_VERTEX_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_FLOOR_VERTEX_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
uniform mat4 mProjection;
|
|
|
uniform mat4 mModel;
|
|
|
uniform mat4 mView;
|
|
@@ -811,18 +819,20 @@ void main(){
|
|
|
fColor=vColor;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_FLOOR_FRAGMENT_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_FLOOR_FRAGMENT_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
uniform vec3 uViewPos;
|
|
|
uniform float uFar;
|
|
|
in vec4 fColor;
|
|
|
in vec3 fGPos;
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
void main(){
|
|
|
- float fac=1-pow(clamp(length(uViewPos-fGPos)/uFar,0,1),0.4);
|
|
|
+ float fac=1.-pow(clamp(length(uViewPos-fGPos)/uFar,0.,1.),0.4);
|
|
|
outColor=vec4(fColor.rgb,fColor.a*fac);
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_RAY_VERTEX_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_RAY_VERTEX_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
in vec3 vUV;
|
|
|
in vec4 vVertex;
|
|
|
out vec3 fViewDir;
|
|
@@ -875,27 +885,30 @@ vec4 fxaa(in sampler2D tex, vec2 uv, vec2 texsize) {
|
|
|
return vec4(texture(tex, offuv).rgb,colm4.a);
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_RAY_FRAGMENT_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_RAY_FRAGMENT_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
uniform vec3 uViewDir;
|
|
|
uniform vec3 uViewPos;
|
|
|
uniform float uFOV;
|
|
|
in vec3 fViewDir;
|
|
|
-uniform sampler2D TexColor;
|
|
|
-uniform sampler2D TexNormal;
|
|
|
-uniform sampler2D TexGPos;
|
|
|
+uniform highp sampler2D TexColor;
|
|
|
+uniform highp sampler2D TexNormal;
|
|
|
+uniform highp sampler2D TexGPos;
|
|
|
#with LA_SHADER_LIB_FXAA
|
|
|
+out vec4 outColor;
|
|
|
void main(){
|
|
|
float d=dot(uViewDir,normalize(fViewDir));
|
|
|
float target=cos(uFOV/2.);
|
|
|
vec4 color=vec4(1.,1.,1.,1.); float mul=0.;
|
|
|
//if(d<(target+0.005)&&d>target) mul=1.0;
|
|
|
- vec2 uv=gl_FragCoord.xy/textureSize(TexColor,0);
|
|
|
- vec4 buffer_color=fxaa(TexColor,uv,textureSize(TexColor,0));
|
|
|
- //vec4 buffer_color=texture2D(TexColor,uv);
|
|
|
- gl_FragColor = mul*color+buffer_color;
|
|
|
+ vec2 uv=gl_FragCoord.xy/vec2(textureSize(TexColor,0));
|
|
|
+ vec4 buffer_color=fxaa(TexColor,uv,vec2(textureSize(TexColor,0)));
|
|
|
+ //vec4 buffer_color=texture(TexColor,uv);
|
|
|
+ outColor = mul*color+buffer_color;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_SCENE_VERTEX_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_SCENE_VERTEX_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
uniform mat4 mProjection;
|
|
|
uniform mat4 mModel;
|
|
|
uniform mat4 mView;
|
|
@@ -916,9 +929,10 @@ void main(){
|
|
|
fGPos= mShadow * mModel * vVertex;\
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_SCENE_FRAGMENT_SHADER = R"(#version 330
|
|
|
-uniform sampler2D TexColor;
|
|
|
-uniform sampler2DMS TexColorMS;\
|
|
|
+extern "C" const char* LA_SCENE_FRAGMENT_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
+uniform highp sampler2D TexColor;
|
|
|
+uniform highp sampler2DMS TexColorMS;\
|
|
|
uniform int TextureMode;
|
|
|
uniform int SampleAmount;
|
|
|
uniform int MultiplyColor;
|
|
@@ -926,13 +940,14 @@ in vec4 fColor;
|
|
|
//in vec4 fNormal;
|
|
|
in vec2 fUV;
|
|
|
in vec4 fGPos;
|
|
|
+out vec4 outColor;
|
|
|
vec4 GetTexture(vec2 uv){
|
|
|
vec4 color=vec4(1,0,1,1);
|
|
|
- if(TextureMode==1 || TextureMode==2){ return texture2D(TexColor,uv); }
|
|
|
+ if(TextureMode==1 || TextureMode==2){ return texture(TexColor,uv); }
|
|
|
else if(TextureMode==3){
|
|
|
ivec2 texSize = textureSize(TexColorMS);
|
|
|
- for(int i=0;i<SampleAmount;i++) color+=texelFetch(TexColorMS, ivec2(fUV * texSize),i);
|
|
|
- color/=SampleAmount;
|
|
|
+ for(int i=0;i<SampleAmount;i++) color+=texelFetch(TexColorMS, ivec2(fUV * vec2(texSize)),i);
|
|
|
+ color/=float(SampleAmount);
|
|
|
if(MultiplyColor!=0){color*=fColor;}
|
|
|
return color;
|
|
|
}
|
|
@@ -947,10 +962,11 @@ float GetShadow(vec4 GPos){
|
|
|
return shadow;
|
|
|
}
|
|
|
void main(){
|
|
|
- gl_FragColor=GetShadow(fGPos)*fColor;
|
|
|
+ outColor=GetShadow(fGPos)*fColor;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_CASCADE_SHADOW_VERTEX_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_CASCADE_SHADOW_VERTEX_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
in vec4 vVertex;
|
|
|
uniform mat4 mModel;
|
|
|
uniform mat4 mShadow;
|
|
@@ -958,9 +974,11 @@ void main(){
|
|
|
gl_Position=mShadow*mModel*vVertex;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_CASCADE_SHADOW_FRAGMENT_SHADER = "#version 330\nvoid main(){gl_FragDepth = gl_FragCoord.z;}";
|
|
|
+extern "C" const char* LA_CASCADE_SHADOW_FRAGMENT_SHADER = "#version 310 es\n \
|
|
|
+precision highp float;\nvoid main(){gl_FragDepth = gl_FragCoord.z;}";
|
|
|
|
|
|
-extern "C" const char* LA_SELECTION_VERTEX_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_SELECTION_VERTEX_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
in vec4 vVertex;
|
|
|
in vec3 vColor;
|
|
|
uniform mat4 mProjection;
|
|
@@ -975,9 +993,11 @@ void main(){
|
|
|
fIdColor = vColor;
|
|
|
})";
|
|
|
|
|
|
-extern "C" const char* LA_SELECTION_FRAGMENT_SHADER = R"(#version 330
|
|
|
+extern "C" const char* LA_SELECTION_FRAGMENT_SHADER = R"(#version 310 es
|
|
|
+precision highp float;
|
|
|
flat in vec3 fIdColor;
|
|
|
+out vec4 outColor;
|
|
|
void main(){
|
|
|
- gl_FragColor=vec4(fIdColor,1.);
|
|
|
+ outColor=vec4(fIdColor,1.);
|
|
|
})";
|
|
|
|