Skip to content

Commit

Permalink
new models
Browse files Browse the repository at this point in the history
  • Loading branch information
neuroprod committed Nov 18, 2023
1 parent 134681a commit 100cc9d
Show file tree
Hide file tree
Showing 9 changed files with 863 additions and 253 deletions.
Binary file modified frontend/public/roomFinal.bin
Binary file not shown.
1,060 changes: 815 additions & 245 deletions frontend/public/roomFinal.json

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions frontend/src/AORenderPass.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import RenderPass from "./lib/core/RenderPass";
import ColorAttachment from "./lib/textures/ColorAttachment";
import RenderTexture from "./lib/textures/RenderTexture";
import RenderTexture, {BaseRenderTextureOptions} from "./lib/textures/RenderTexture";
import Material from "./lib/core/Material";
import Blit from "./lib/Blit";
import Renderer from "./lib/Renderer";
Expand All @@ -22,6 +22,7 @@ export default class AORenderPass extends RenderPass{
private aoRadius =1;
private aoStrength=1.3;
private aoNumSamples =16;
private halfSize: boolean =true;
constructor(renderer: Renderer) {

super(renderer, "OAPass");
Expand All @@ -46,7 +47,16 @@ export default class AORenderPass extends RenderPass{
}
onUI(){
UI.separator("SSAO")

if( UI.LBool("Half Size",this.halfSize) !=this.halfSize){
this.halfSize =!this.halfSize;
let options=this.target.options as BaseRenderTextureOptions
if(this.halfSize){
options.sizeMultiplier =0.5;
}else{
options.sizeMultiplier =1;
}
this.renderer.forceRescaleTextures()
}
this.aoRadius =UI.LFloatSlider("radius",this.aoRadius,0.01,2)
this.aoStrength = UI.LFloatSlider("strength",this.aoStrength,0,5)
this.aoNumSamples =Math.round( UI.LFloatSlider("numSamples", this.aoNumSamples,1,64));
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,11 @@ export default class Main {
let mp = this.mouseListener.mousePos.clone()
mp.scale(new Vector2(1 / this.renderer.width, 1 / this.renderer.height))
mp.x -= 0.5
mp.x*=2.0;
mp.y -= 0.5
mp.y *= 2.0
mp.y *= 3.0
this.mouseTarget.lerp(mp, 0.1);
let cameraPositionMap = new Vector3(-this.mouseTarget.x * 2.0, 1.5 + this.mouseTarget.y*2.0, 7);
let cameraPositionMap = new Vector3(-this.mouseTarget.x * 2.0, 2.0 + this.mouseTarget.y, 10);
this.camera.cameraWorld = cameraPositionMap.clone();
this.camera.cameraLookAt = new Vector3(cameraPositionMap.x, cameraPositionMap.y, 0);
let screenLocal = new Vector2(this.renderer.ratio * 3, 3)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/Camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class Camera extends UniformGroup {
public cameraUp: Vector3 = new Vector3(0, 1, 0);
public fovy = 0.9
public near =2;
public far = 15
public far = 20
public lensShift = new Vector2(1, 0)
private view: Matrix4 = new Matrix4();
private projection: Matrix4 = new Matrix4();
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/lib/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ export default class Renderer {
addUniformGroup(uniformGroup: UniformGroup) {
this.uniformGroups.push(uniformGroup)
}

forceRescaleTextures() {
for (let t of this.scaleToCanvasTextures) {
t.resize(this.width, this.height);
}
}
private updateSize() {

if (this.width != this.canvas.width || this.height != this.canvas.height) {
Expand Down Expand Up @@ -172,5 +176,7 @@ export default class Renderer {
a.onScreenResize(this.size)
}
}


}

22 changes: 22 additions & 0 deletions frontend/src/lib/textures/DefaultTextures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ export default class DefaultTextures {
private static black: Texture;
private static grid: Texture;
private static normal: Texture;
private static mre: Texture;


static getMRE(render: Renderer) {
if (this.mre) return this.mre;

this.mre = new Texture(render, "defaultWhite", {
format: TextureFormat.RGBA8Unorm,
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
})
this.mre.make()

let f = new Uint8ClampedArray(4);
f[0]=0;
f[1]=250;
f[2]=0;
f[3]=255;
this.mre.writeTexture(f,1,1,4);

return this.mre;
}

static getWhite(render: Renderer) {
if (this.white) return this.white;

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/textures/RenderTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export default class RenderTexture extends Texture {
}
resize(width,height)
{

let options=this.options as BaseRenderTextureOptions
if( this.options.width ==width*options.sizeMultiplier && this.options.height ==height*options.sizeMultiplier)return;

this.options.width =width*options.sizeMultiplier;
this.options.height =height*options.sizeMultiplier;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/shaders/GBufferShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class GBufferShader extends Shader{
}
this.addUniform("scale",1);
this.addTexture("colorTexture",DefaultTextures.getWhite(this.renderer))
this.addTexture("mraTexture",DefaultTextures.getWhite(this.renderer))
this.addTexture("mraTexture",DefaultTextures.getMRE(this.renderer))
this.addTexture("normalTexture",DefaultTextures.getNormal(this.renderer))
this.addSampler("mySampler")

Expand Down

0 comments on commit 100cc9d

Please sign in to comment.