Skip to content

Commit 27fc6d3

Browse files
committed
add resources
1 parent 0358e37 commit 27fc6d3

File tree

7 files changed

+97
-19
lines changed

7 files changed

+97
-19
lines changed

core/src/assets/shaders/BackgroundFrag.glsl

Lines changed: 0 additions & 9 deletions
This file was deleted.

core/src/assets/shaders/BackgroundVert.glsl

Lines changed: 0 additions & 9 deletions
This file was deleted.

debug/apps/arscene/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ android {
1515
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1616
}
1717
}
18+
sourceSets {
19+
main.assets.srcDirs += '../../../mode/libraries/ar/src/assets'
20+
}
1821
productFlavors {
1922
}
2023
compileOptions {

mode/libraries/ar/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ sourceSets {
120120
java {
121121
srcDirs = ["src/"]
122122
}
123+
resources {
124+
srcDirs = ["src/"]
125+
}
123126
}
124127
}
125128

@@ -149,7 +152,7 @@ clean.doFirst {
149152
}
150153

151154
build.doLast {
152-
// // Copying ar jar to library folder
155+
// Copying ar jar to library folder
153156
File arJar = file("library/ar.jar")
154157
arJar.mkdirs();
155158
Files.copy(file("$buildDir/libs/ar.jar").toPath(),
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Part of the Processing project - http://processing.org
3+
4+
Copyright (c) 2012-16 The Processing Foundation
5+
Copyright (c) 2004-12 Ben Fry and Casey Reas
6+
Copyright (c) 2001-04 Massachusetts Institute of Technology
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation, version 2.1.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General
18+
Public License along with this library; if not, write to the
19+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20+
Boston, MA 02111-1307 USA
21+
*/
22+
23+
#ifdef GL_ES
24+
precision mediump float;
25+
precision mediump int;
26+
#endif
27+
28+
varying vec4 vertColor;
29+
varying vec4 backVertColor;
30+
varying vec4 colorCorrection;
31+
32+
void main() {
33+
// Approximate sRGB gamma.
34+
const float kGamma = 0.4545454;
35+
const float kInverseGamma = 2.2;
36+
const float kMiddleGrayGamma = 0.466;
37+
38+
vec3 colorShift = colorCorrection.rgb;
39+
float averagePixelIntensity = colorCorrection.a;
40+
41+
vec4 color = gl_FrontFacing ? vertColor : backVertColor;
42+
43+
// Apply SRGB gamma before writing the fragment color.
44+
color.rgb = pow(color.rgb, vec3(kGamma));
45+
46+
// Apply average pixel intensity and color shift
47+
color.rgb *= colorShift * (averagePixelIntensity / kMiddleGrayGamma);
48+
gl_FragColor.rgb = color;
49+
gl_FragColor.a = objectColor.a;
50+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Part of the Processing project - http://processing.org
3+
4+
Copyright (c) 2012-16 The Processing Foundation
5+
Copyright (c) 2004-12 Ben Fry and Casey Reas
6+
Copyright (c) 2001-04 Massachusetts Institute of Technology
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation, version 2.1.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General
18+
Public License along with this library; if not, write to the
19+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20+
Boston, MA 02111-1307 USA
21+
*/
22+
#ifdef GL_ES
23+
precision mediump float;
24+
precision mediump int;
25+
#endif
26+
27+
uniform sampler2D texture;
28+
29+
uniform vec2 texOffset;
30+
31+
varying vec4 vertColor;
32+
varying vec4 backVertColor;
33+
varying vec4 vertTexCoord;
34+
35+
void main() {
36+
gl_FragColor = texture2D(texture, vertTexCoord.st) * (gl_FrontFacing ? vertColor : backVertColor);
37+
}

mode/libraries/ar/src/processing/ar/BackgroundRenderer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import com.google.ar.core.Frame;
88

9+
import java.io.BufferedReader;
10+
import java.io.IOException;
11+
import java.io.InputStreamReader;
912
import java.net.URL;
1013
import java.nio.ByteBuffer;
1114
import java.nio.ByteOrder;

0 commit comments

Comments
 (0)