Add gain for weird Android effect in presentation

parent 13c19778
Pipeline #745 passed with stage
in 8 minutes and 51 seconds
......@@ -18,53 +18,85 @@
\ along with this program. If not, see http://www.gnu.org/licenses/.
: fold1 ( xt -- )
\G check if can fold by one literals; if so, does so, otherwise
\G compiles the primitive
lits# 1 u>= IF >r lits> r> execute >lits
ELSE peephole-compile, THEN ;
\G check if can fold one literal;
\G if so, does so, otherwise compiles the
\G primitive
lits# 1 u>= IF >r lits> r> execute >lits
ELSE peephole-compile, THEN ;
: 2lits> ( -- d ) lits> lits> swap ;
: >2lits ( d -- ) swap >lits >lits ;
: 3lits> ( -- t ) 2lits> lits> -rot ;
: >3lits ( -- t ) rot >lits >2lits ;
: fold2 ( xt -- )
\G check if can fold by two literals; if so, does so, otherwise
\G check if can fold two literals;
\G if so, does so, otherwise
\G compiles the primitive
lits# 2 u>= IF >r lits> lits> swap r> execute >lits
lits# 2 u>= IF
>r 2lits> r> execute >lits
ELSE peephole-compile, THEN ;
: fold1:2 ( xt -- )
\G check if can fold by one literals; if so, does so, otherwise
\G check if can fold one literal;
\G if so, does so (returning 2), otherwise
\G compiles the primitive
lits# 1 u>= IF >r lits> r> execute swap >lits >lits
ELSE peephole-compile, THEN ;
lits# 1 u>= IF
>r lits> r> execute >2lits
ELSE peephole-compile, THEN ;
: fold2:2 ( xt -- )
\G check if can fold by two literals; if so, does so, otherwise
\G compiles the primitive
lits# 2 u>= IF >r lits> lits> swap r> execute swap >lits >lits
ELSE peephole-compile, THEN ;
\G check if can fold two literals;
\G if so, does so (returning 2),
\G otherwise compiles the primitive
lits# 2 u>= IF
>r 2lits> r> execute >2lits
ELSE peephole-compile, THEN ;
: fold2:3 ( xt -- )
\G check if can fold by one literals; if so, does so, otherwise
\G check if can fold two literals;
\G if so, does so (returning 3), otherwise
\G compiles the primitive
lits# 2 u>= IF >r lits> lits> swap r> execute rot >lits swap >lits >lits
ELSE peephole-compile, THEN ;
lits# 2 u>= IF
>r 2lits> r> execute >3lits
ELSE peephole-compile, THEN ;
: fold3:3 ( xt -- )
\G check if can fold by two literals; if so, does so, otherwise
\G compiles the primitive
lits# 3 u>= IF >r lits> lits> swap lits> -rot r> execute rot >lits swap >lits >lits
ELSE peephole-compile, THEN ;
: fold1: ( "name" -- )
' dup (make-latest) ['] fold1 set-compiler vt, ;
: fold2: ( "name" -- )
' dup (make-latest) ['] fold2 set-compiler vt, ;
: fold1:2: ( "name" -- )
' dup (make-latest) ['] fold1:2 set-compiler vt, ;
: fold2:2: ( "name" -- )
' dup (make-latest) ['] fold2:2 set-compiler vt, ;
: fold2:3: ( "name" -- )
' dup (make-latest) ['] fold2:3 set-compiler vt, ;
: fold3:3: ( "name" -- )
' dup (make-latest) ['] fold3:3 set-compiler vt, ;
\G check if can fold three literals;
\G if so, does so (returning 3),
\G otherwise compiles the primitive
lits# 3 u>= IF
>r 3lits> r> execute >3lits
ELSE peephole-compile, THEN ;
: fold3:2 ( xt -- )
\G check if can fold three literals;
\G if so, does so (returning 2),
\G otherwise compiles the primitive
lits# 3 u>= IF
>r 3lits> r> execute >2lits
ELSE peephole-compile, THEN ;
: fold3:1 ( xt -- )
\G check if can fold three literals;
\G if so, does so (returning 1),
\G otherwise compiles the primitive
lits# 3 u>= IF
>r 3lits> r> execute >lits
ELSE peephole-compile, THEN ;
: folder ( xt "name" -- )
create , does> vt,
' dup (make-latest) @ set-optimizer ;
' fold1 folder fold1:
' fold2 folder fold2:
' fold1:2 folder fold1:2:
' fold2:2 folder fold2:2:
' fold2:3 folder fold2:3:
' fold3:3 folder fold3:3:
' fold3:2 folder fold3:2:
' fold3:1 folder fold3:1:
fold1: invert
fold1: abs
......@@ -129,3 +161,10 @@ fold2:3: over
fold2:3: tuck
fold3:3: rot
fold3:2: um/mod
fold3:2: fm/mod
fold3:2: sm/rem
fold3:2: */mod
fold3:1: */
......@@ -320,6 +320,7 @@ uniform vec2 u_TexScale2; // scale texture coordinates
uniform vec2 u_TexScale3; // scale texture coordinates
uniform sampler2D u_ColorTex; // Color palette (texture)
uniform float u_ColorMode; // Color mode
uniform float u_Gain; // gain for color, workaround for Android ???
attribute vec4 a_Position; // Per-vertex position information we will pass in.
attribute vec4 a_Normal; // Per-vertex normal information we will pass in.
......@@ -338,7 +339,7 @@ void main()
{
// pass through the extras
v_Extras = a_Extras;
v_Color = texture2D(u_ColorTex, vec2(v_Extras.y, u_ColorMode));
v_Color = texture2D(u_ColorTex, vec2(v_Extras.y, u_ColorMode))*u_Gain;
// Transform the vertex into eye space.
v_Position = vec3(u_MVMatrix * a_Position);
......@@ -440,6 +441,7 @@ void main() {
0 Value TexScale3
0 Value ColorTex
0 Value ColorMode
0 Value Gain
0 Value LightPos
0 Value Texture0
......@@ -504,7 +506,7 @@ void main() {
vec3 mid3 = vec3(mid, mid, mid);
col.rgb = (u_Saturate * (col.rgb - mid3)) + mid3;
}
if(u_Ambient != 1.0) {
if(u_Ambient < 0.9) {
// Will be used for attenuation.
float distance = length(u_LightPos - v_Position);
......@@ -758,6 +760,7 @@ require soil-texture.fs
[THEN]
1 sfloats buffer: color%
1 sfloats buffer: gain% 1.0e gain% sf!
1 sfloats buffer: ambient% 1.0e ambient% sf!
1 sfloats buffer: saturate% 1.0e saturate% sf!
3 sfloats buffer: lightpos-xyz
......@@ -777,6 +780,7 @@ require soil-texture.fs
dup "u_TexScale3" glGetUniformLocation to TexScale3
dup "u_ColorTex" glGetUniformLocation to ColorTex
dup "u_ColorMode" glGetUniformLocation to ColorMode
dup "u_Gain" glGetUniformLocation to Gain
\ Pixel shader
dup "u_LightPos" glGetUniformLocation to LightPos
dup "u_Texture0" glGetUniformLocation to Texture0
......@@ -828,9 +832,10 @@ color-w color-h * sfloats allocate throw to color-pal
Texture3 3 glUniform1i
ColorTex 4 glUniform1i
ColorMode 1 color% glUniform1fv
Ambient 1 ambient% glUniform1fv
Saturate 1 saturate% glUniform1fv
LightPos 1 lightpos-xyz glUniform3fv ;
Gain 1 gain% glUniform1fv
Ambient 1 ambient% glUniform1fv
Saturate 1 saturate% glUniform1fv
LightPos 1 lightpos-xyz glUniform3fv ;
: day-mode ( -- ) 0 to color-theme 0.5e ColorMode! ;
color-h 1 > [IF]
......
......@@ -318,7 +318,8 @@ also opengl
: !widgets ( -- )
top-widget .htop-resize
1e ambient% sf! set-uniforms ;
1e ambient% sf! [IFDEF] android 2e gain% sf! [THEN]
set-uniforms ;
[IFDEF] writeout-en
lsids ' .lsids s" ef2018/en" r/w create-file throw
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment