Skip to content

Commit 01773e6

Browse files
committed
Adding source of P2DX renderer
1 parent 03c2efe commit 01773e6

File tree

3 files changed

+2265
-0
lines changed

3 files changed

+2265
-0
lines changed

core/src/assets/shaders/P2DFrag.glsl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifdef GL_ES
2+
precision mediump float;
3+
precision mediump int;
4+
#endif
5+
6+
varying vec4 vertColor;
7+
varying vec2 vertTexCoord;
8+
varying float vertTexFactor;
9+
10+
uniform sampler2D texture;
11+
12+
void main() {
13+
gl_FragColor = mix(vertColor, vertColor * texture2D(texture, vertTexCoord), vertTexFactor);
14+
}

core/src/assets/shaders/P2DVert.glsl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
attribute vec3 position;
2+
attribute vec4 color;
3+
attribute vec2 texCoord;
4+
attribute float texFactor;
5+
6+
varying vec4 vertColor;
7+
varying vec2 vertTexCoord;
8+
varying float vertTexFactor;
9+
10+
uniform mat4 transform;
11+
uniform vec2 texScale;
12+
13+
void main() {
14+
gl_Position = transform * vec4(position, 1);
15+
16+
//we avoid affecting the Z component by the transform
17+
//because it would mess up our depth testing
18+
gl_Position.z = position.z;
19+
20+
vertColor = color.zyxw;
21+
vertTexCoord = texCoord * texScale;
22+
vertTexFactor = texFactor;
23+
}

0 commit comments

Comments
 (0)