Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnik-dmitry07 committed Apr 14, 2020
1 parent 0710624 commit 6ec1c21
Show file tree
Hide file tree
Showing 143 changed files with 9,583 additions and 376 deletions.
28 changes: 18 additions & 10 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="edu.ttp.gengame" >
package="edu.ttp.gengame">

<application
android:allowBackup="true"
android:appCategory="game"
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@drawable/ic_launcher"
android:isGame="true"
android:appCategory="game"
android:label="@string/app_name"
android:theme="@style/GdxTheme"
tools:ignore="UnusedAttribute"
tools:targetApi="o"
android:fullBackupContent="@xml/backup_descriptor">
tools:targetApi="o">
<activity android:name=".About"
android:parentActivityName=".AndroidLauncher">
<!-- The meta-data tag is required if you support API level 15 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".AndroidLauncher" />
</activity>
<activity
android:name="edu.ttp.gengame.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout">
android:name=".AndroidLauncher"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
</application>
</manifest>
</manifest>
31 changes: 31 additions & 0 deletions android/assets/shaders/bias.fragment
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright 2012 tsagrista
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

uniform sampler2D u_texture0;
uniform float u_bias;
varying vec2 v_texCoords;

void main()
{
vec4 tex = texture2D(u_texture0, v_texCoords);
float avg = (tex.r + tex.g + tex.b) / 3.0;
gl_FragColor = vec4(max(0.0, avg + u_bias)) * 50.0;
}
46 changes: 46 additions & 0 deletions android/assets/shaders/blur.fragment
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*******************************************************************************
* Copyright 2012 bmanuel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

#ifdef GL_ES
#define PRECISION mediump
precision PRECISION float;
#else
#define PRECISION
#endif

#ifndef RADIUS
#error Please define a RADIUS
#endif

#define KERNEL_SIZE (RADIUS * 2 + 1)

varying vec2 v_texCoord0;
uniform PRECISION sampler2D u_texture0;
uniform PRECISION vec2 SampleOffsets[KERNEL_SIZE];
uniform PRECISION float SampleWeights[KERNEL_SIZE];

void main()
{
vec4 c = vec4(0);

// Combine a number of weighted image filter taps.
for (int i = 0; i < KERNEL_SIZE; i++)
{
c += texture2D(u_texture0, v_texCoord0 + SampleOffsets[i]) * SampleWeights[i];
}

gl_FragColor = c;
}
32 changes: 32 additions & 0 deletions android/assets/shaders/blur.vertex
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright 2012 bmanuel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

#ifdef GL_ES
#define PRECISION mediump
precision PRECISION float;
#else
#define PRECISION
#endif

attribute vec4 a_position;
attribute vec2 a_texCoord0;
varying vec2 v_texCoord0;

void main()
{
v_texCoord0 = a_texCoord0;
gl_Position = a_position;
}
91 changes: 91 additions & 0 deletions android/assets/shaders/camerablur.fragment
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*******************************************************************************
* Copyright 2012 bmanuel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

#ifdef GL_ES
#define PRECISION mediump
precision PRECISION float;
#else
#define PRECISION
#endif


uniform PRECISION sampler2D u_texture0; // scene
uniform PRECISION sampler2D u_texture1; // depthmap
uniform PRECISION mat4 ctp;
uniform PRECISION float near, far;
uniform vec2 viewport;
uniform mat4 inv_proj;
uniform float blur_scale;
uniform float depth_scale;
uniform int blur_passes;

varying vec2 v_texCoords;

vec3 get_eye_normal(){
vec2 frag_coord = gl_FragCoord.xy/viewport;
frag_coord = (frag_coord-0.5)*2.0;
vec4 device_normal = vec4(frag_coord, 0.0, 1.0);
return normalize((inv_proj * device_normal).xyz);
}

vec3 decode_normal(vec2 enc){
vec2 fenc = enc*4.0-2.0;
float f = dot(fenc,fenc);
float g = sqrt(1.0-f/4.0);
return vec3(fenc*g, 1.0-f/2.0);
}

float decode_depth(vec2 src){
float depth = src.x/255.0+src.y;
depth *= depth_scale;
return depth*far+near;
}

void main() {
vec3 eye_ray = get_eye_normal();
vec4 eye_data = texture2D(u_texture1, v_texCoords);
vec3 eye_normal = decode_normal(eye_data.xy);
float eye_depth = decode_depth(eye_data.zw);

vec4 current = vec4(eye_ray * eye_depth, 1.0);
vec4 previous = ctp * current;
previous.xyz /= previous.w;
previous.xy = previous.xy * 0.5 + 0.5;

vec2 velocity = (previous.xy - v_texCoords) * 0.5 * blur_scale;

// blur pass
vec4 result = vec4(0.0);
float oneOnNumPasses = 1.0 / float(blur_passes);

for (int i = 0; i < blur_passes; ++i) {
// make offset in [-0.5, 0.5] range
float scale = (float(i) * oneOnNumPasses) - 0.5;
vec2 offset = scale * velocity;
result += texture2D(u_texture0, v_texCoords + offset);
}

//// Get the initial color at this pixel.
//result = texture2D(u_texture0, v_texCoords);
//vec2 texCoord = v_texCoords + velocity;
//for(int i = 1; i < blur_passes; ++i, texCoord += velocity)
//{
//// Add the current color to our color sum.
//result += texture2D(u_texture0, texCoord);
//}

gl_FragColor = result * oneOnNumPasses;
}
67 changes: 67 additions & 0 deletions android/assets/shaders/combine.fragment
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*******************************************************************************
* Copyright 2012 bmanuel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

#ifdef GL_ES
#define PRECISION mediump
precision PRECISION float;
#else
#define PRECISION
#endif

uniform PRECISION sampler2D u_texture0;
uniform PRECISION sampler2D u_texture1;
uniform float Src1Intensity;
uniform float Src2Intensity;
uniform float Src1Saturation;
uniform float Src2Saturation;

varying vec2 v_texCoords;

// The constants 0.3, 0.59, and 0.11 are chosen because the
// human eye is more sensitive to green light, and less to blue.
const vec3 GRAYSCALE = vec3(0.3, 0.59, 0.11);

// 0 = totally desaturated
// 1 = saturation unchanged
// higher = increase saturation
//const float BaseSat = 1;
//const float BloomSat = 1;

vec3 adjustSaturation(vec3 color, float saturation)
{
vec3 grey = vec3(dot(color, GRAYSCALE));
//vec3 grey = vec3((color.r+color.g+color.b)*0.333);
return mix(grey, color, saturation);
}

void main()
{
// lookup inputs
vec4 src1 = texture2D(u_texture0, v_texCoords) * Src1Intensity;
vec4 src2 = texture2D(u_texture1, v_texCoords) * Src2Intensity;

// adjust color saturation and intensity
src1.rgb = adjustSaturation(src1.rgb,Src1Saturation);
src2.rgb = adjustSaturation(src2.rgb,Src2Saturation);

// darken the base image in areas where ther's a lot of bloom
// to prevent things looking excessively burned-out
//original *= (1.0 - clamp(bloom, 0.0, 1.0));
src1 *= (1.0 - src2);

// combine
gl_FragColor = src1 + src2;
}
44 changes: 44 additions & 0 deletions android/assets/shaders/convolve-1d.fragment
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright 2012 bmanuel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

#ifdef GL_ES
#define PRECISION mediump
precision PRECISION float;
#else
#define PRECISION
#endif

#ifndef LENGTH
#error Please define a LENGTH
#endif

varying vec2 v_texCoords;
uniform PRECISION sampler2D u_texture0;
uniform PRECISION vec2 SampleOffsets[LENGTH];
uniform PRECISION float SampleWeights[LENGTH];

void main()
{
vec4 c = vec4(0);

// Combine a number of weighted image filter taps.
for (int i = 0; i < LENGTH; i++)
{
c += texture2D(u_texture0, v_texCoords + SampleOffsets[i]) * SampleWeights[i];
}

gl_FragColor = c;
}
Loading

0 comments on commit 6ec1c21

Please sign in to comment.