Skip to content

Commit

Permalink
Merge pull request #342 from cx20/improved_memory_usage_rhodonite_sam…
Browse files Browse the repository at this point in the history
…ples

Improved memory usage in Rhodonite samples
  • Loading branch information
cx20 authored Jun 22, 2024
2 parents 50749cf + e86c0c5 commit 30f1e1a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/rhodonite/complex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ c.width = window.innerWidth;
c.height = window.innerHeight;

const load = async function () {
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');
Expand Down
3 changes: 3 additions & 0 deletions examples/rhodonite/cube/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ function readyBasicVerticesData() {

const load = async function () {
Rn.Config.maxCameraNumber = 20;
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');
Expand Down
3 changes: 3 additions & 0 deletions examples/rhodonite/primitive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import Rn from 'rhodonite';

const load = async function () {
Rn.Config.maxCameraNumber = 20;
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');
Expand Down
14 changes: 12 additions & 2 deletions examples/rhodonite/quaternion/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Rn from 'rhodonite';

const load = async function () {
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');


await Rn.System.init({
approach: Rn.ProcessApproach.DataTexture,
canvas: c,
Expand All @@ -29,9 +31,17 @@ const load = async function () {

const texture = new Rn.Texture();
texture.generateTextureFromUri('../../../assets/textures/frog.jpg');

const sampler = new Rn.Sampler({
magFilter: Rn.TextureParameter.Linear,
minFilter: Rn.TextureParameter.Linear,
wrapS: Rn.TextureParameter.ClampToEdge,
wrapT: Rn.TextureParameter.ClampToEdge,
});
sampler.create();

const material = Rn.MaterialHelper.createClassicUberMaterial();
material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture);
material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture, sampler);

const cube1 = Rn.MeshHelper.createCube({widthVector: Rn.Vector3.fromCopyArray([1, 1, 1]), material: material});
cube1.localScale = Rn.Vector3.fromCopyArray([0.5, 0.5, 0.5]);
Expand Down
3 changes: 3 additions & 0 deletions examples/rhodonite/square/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ function readyBasicVerticesData() {

const load = async function () {
Rn.Config.maxCameraNumber = 20;
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');
Expand Down
3 changes: 3 additions & 0 deletions examples/rhodonite/teapot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ let vertexTextureCoords;
let indices;

const load = async function () {
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

const c = document.getElementById('world');

await Rn.System.init({
Expand Down
3 changes: 3 additions & 0 deletions examples/rhodonite/texture/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ function readyBasicVerticesData() {

const load = async function () {
Rn.Config.maxCameraNumber = 20;
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');
Expand Down
3 changes: 3 additions & 0 deletions examples/rhodonite/triangle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function readyBasicVerticesData() {

const load = async function () {
Rn.Config.maxCameraNumber = 20;
Rn.Config.dataTextureWidth = 2 ** 9; // default: 2 ** 11;
Rn.Config.dataTextureHeight = 2 ** 9; // default: 2 ** 11;

await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');
Expand Down

0 comments on commit 30f1e1a

Please sign in to comment.