This commit is contained in:
41666 2023-10-11 20:42:40 -04:00
parent 2b971ecc2a
commit d5025fabac
4 changed files with 30 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,20 @@
import { Shader } from "../renderer/shader";
import { Shader, ShaderConfig } from "../renderer/shader";
import { WebGLApp } from "../renderer/webgl";
import frag from "./basic.frag";
import vert from "./basic.vert";
export const basicShaderConfig: ShaderConfig = {
model: 0,
view: 4,
projection: 8,
world: 12,
light0: 13,
light0Color: 17,
uv0: 18,
normals: 19,
vertexColor: 20,
time: 21,
};
export const basic = (app: WebGLApp) =>
new Shader({}).vertex(vert).fragment(frag).app(app);
new Shader(basicShaderConfig).vertex(vert).fragment(frag).app(app);

View file

@ -1,8 +1,16 @@
#version 300 es
attribute vec4 aVertexPosition;
layout(location = 0) in mat4 model;
layout(location = 4) in mat4 view;
layout(location = 8) in mat4 projection;
layout(location = 12) in vec3 worldPos;
layout(location = 13) in mat4 light0;
layout(location = 17) in vec4 light0Color;
layout(location = 18) in vec2 uv0;
layout(location = 19) in vec3 normals;
layout(location = 20) in vec4 vertexColor;
layout(location = 21) in float time;
uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
// injection point
void main() {
gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;

View file

@ -26,7 +26,9 @@ export class Shader {
static VERTEX = 35633;
static FRAGMENT = 35632;
constructor(private config: ShaderConfig) {}
constructor(private config: ShaderConfig) {
config.model = 0;
}
private vertexCode = "";
private fragmentCode = "";