Skip to content

Commit

Permalink
Tidy attribute names.
Browse files Browse the repository at this point in the history
  • Loading branch information
hulkholden committed Oct 25, 2023
1 parent e1ff155 commit fd40f03
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
48 changes: 24 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@ <h5 class="modal-title">Controls</h5>
<script type="module" src="build/n64.min.js"></script>

<script id="fill-shader-vs" type="x-shader/x-vertex">#version 300 es
in vec4 aVertexPosition;
in vec4 aPosition;

void main(void) {
gl_Position = aVertexPosition;
gl_Position = aPosition;
}
</script>
<script id="fill-shader-fs" type="x-shader/x-fragment">#version 300 es
Expand All @@ -609,47 +609,47 @@ <h5 class="modal-title">Controls</h5>
</script>

<script id="blit-shader-vs" type="x-shader/x-vertex">#version 300 es
in vec4 aVertexPosition;
in vec2 aTextureCoord;
in vec4 aPosition;
in vec2 aUV;

out mediump vec2 vTextureCoord;
out mediump vec2 vUV;

void main(void) {
gl_Position = aVertexPosition;
vTextureCoord = aTextureCoord;
gl_Position = aPosition;
vUV = aUV;
}
</script>
<script id="blit-shader-fs" type="x-shader/x-fragment">#version 300 es
precision mediump float;
in mediump vec2 vTextureCoord;
in mediump vec2 vUV;
out vec4 outCol;

uniform sampler2D uSampler0;

void main(void) {
vec4 col = texture(uSampler0, vTextureCoord);
vec4 col = texture(uSampler0, vUV);
outCol = vec4(col.rgb, 1);
}
</script>

<script id="n64-shader-vs" type="x-shader/x-vertex">#version 300 es
in vec4 aVertexPosition;
in vec4 aVertexColor;
in vec2 aTextureCoord;
in vec4 aPosition;
in vec4 aColor;
in vec2 aUV;

out vec4 vColor;
out mediump vec2 vTextureCoord;
out mediump vec2 vUV;

void main(void) {
gl_Position = aVertexPosition;
vColor = aVertexColor;
vTextureCoord = aTextureCoord;
gl_Position = aPosition;
vColor = aColor;
vUV = aUV;
}
</script>
<script id="n64-shader-fs" type="x-shader/x-fragment">#version 300 es
precision mediump float;
in vec4 vColor;
in mediump vec2 vTextureCoord;
in mediump vec2 vUV;
out vec4 outCol;

uniform sampler2D uSampler0;
Expand All @@ -660,22 +660,22 @@ <h5 class="modal-title">Controls</h5>
uniform vec2 uTexScale0;
uniform vec2 uTexScale1;

uniform vec4 uPrimColor;
uniform vec4 uEnvColor;
uniform float uAlphaThreshold;
uniform vec4 uPrimColor;
uniform vec4 uEnvColor;
uniform float uAlphaThreshold;

void main(void) {
vec2 textureCoord0 = (vTextureCoord - uTexOffset0) * uTexScale0;
vec2 textureCoord1 = (vTextureCoord - uTexOffset1) * uTexScale1;
vec2 uv0 = (vUV - uTexOffset0) * uTexScale0;
vec2 uv1 = (vUV - uTexOffset1) * uTexScale1;

vec4 shade = vColor;
vec4 prim = uPrimColor;
vec4 env = uEnvColor;
vec4 one = vec4(1,1,1,1);
vec4 zero = vec4(0,0,0,0);
// TODO: consider doing the shift/mask/clamp here.
vec4 tex0 = texture(uSampler0, textureCoord0);
vec4 tex1 = texture(uSampler1, textureCoord1);
vec4 tex0 = texture(uSampler0, uv0);
vec4 tex1 = texture(uSampler1, uv1);
vec4 col;
vec4 combined = vec4(0,0,0,1);
float lod_frac = 0.0; // FIXME
Expand Down
10 changes: 4 additions & 6 deletions src/hle/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,22 @@ export class Renderer {
const gl = this.gl;
const va = new VertexArray(gl);

// aVertexPosition
const positions = [
-1, -1, 0, 1,
1, -1, 0, 1,
-1, 1, 0, 1,
1, 1, 0, 1,
];
va.initPosAttr(program, "aVertexPosition");
va.initPosAttr(program, "aPosition");
va.setPosData(new Float32Array(positions), gl.STATIC_DRAW);

// aTextureCoord
const uvs = [
0, 0,
1, 0,
0, 1,
1, 1,
];
va.initUVsAttr(program, "aTextureCoord");
va.initUVsAttr(program, "aUV");
va.setUVData(new Float32Array(uvs), gl.STATIC_DRAW);

return va;
Expand Down Expand Up @@ -207,7 +205,7 @@ export class Renderer {
+1, -1, 0, 1,
-1, -1, 0, 1,
];
va.initPosAttr(program, "aVertexPosition");
va.initPosAttr(program, "aPosition");
va.setPosData(new Float32Array(positions), gl.STATIC_DRAW);
return va;
}
Expand All @@ -234,7 +232,7 @@ export class Renderer {
initFillRectVA(program) {
const gl = this.gl;
const va = new VertexArray(gl);
va.initPosAttr(program, "aVertexPosition");
va.initPosAttr(program, "aPosition");
va.setPosData(new Float32Array(4 * 4), gl.DYNAMIC_DRAW);
return va;
}
Expand Down
6 changes: 3 additions & 3 deletions src/hle/shaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ class N64Shader {
this.shaderSource = shaderSource;

this.vertexArray = new VertexArray(gl);
this.vertexArray.initPosAttr(program, "aVertexPosition");
this.vertexArray.initUVsAttr(program, "aTextureCoord");
this.vertexArray.initColorAttr(program, "aVertexColor");
this.vertexArray.initPosAttr(program, "aPosition");
this.vertexArray.initUVsAttr(program, "aUV");
this.vertexArray.initColorAttr(program, "aColor");

this.uSamplerUniform0 = gl.getUniformLocation(program, "uSampler0");
this.uSamplerUniform1 = gl.getUniformLocation(program, "uSampler1");
Expand Down

0 comments on commit fd40f03

Please sign in to comment.