Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
pandrr committed Feb 5, 2024
2 parents c235e14 + 06c1d32 commit a906a92
Show file tree
Hide file tree
Showing 274 changed files with 1,084 additions and 1,045 deletions.
13 changes: 9 additions & 4 deletions src/core/cgl/cgl_mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ MESH.lastMesh = null;
* mesh.render(cgl.getShader());
* }
*/
const Mesh = function (_cgl, __geom, glPrimitive)
const Mesh = function (_cgl, __geom, _options)
{
this._cgl = _cgl;

let options = _options || {};
if (CABLES.UTILS.isNumeric(options))options = { "glPrimitive": _options }; // old constructor fallback...
this._log = new Logger("cgl_mesh");
this._bufVertexAttrib = null;
this._bufVerticesIndizes = this._cgl.gl.createBuffer();
Expand All @@ -37,7 +39,9 @@ const Mesh = function (_cgl, __geom, glPrimitive)
this._geom = null;
this._lastShader = null;
this._numInstances = 0;
this._glPrimitive = glPrimitive;
this._glPrimitive = options.glPrimitive;

this.opId = options.opId || "";
this._preWireframeGeom = null;
this.addVertexNumbers = false;
this._name = "unknown";
Expand Down Expand Up @@ -489,8 +493,6 @@ Mesh.prototype._bind = function (shader)
{
if (!shader.isValid()) return;


// if (shader != this._lastShader) this.unBind();
let attrLocs = [];
if (this._attribLocs[shader.id]) attrLocs = this._attribLocs[shader.id];
else this._attribLocs[shader.id] = attrLocs;
Expand Down Expand Up @@ -739,6 +741,9 @@ Mesh.prototype.render = function (shader)

if (!queryProfilerData) queryProfilerData = { "id": id, "num": 0 };

if (shader.opId)queryProfilerData.shaderOp = shader.opId;
if (this.opId)queryProfilerData.meshOp = this.opId;

this._cgl.profileData.glQueryData[id] = queryProfilerData;

if (!this._queryExt && this._queryExt !== false) this._queryExt = this._cgl.enableExtension("EXT_disjoint_timer_query_webgl2") || false;
Expand Down
4 changes: 3 additions & 1 deletion src/core/cgl/cgl_shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let materialIdCounter = 0;
* var shader=new CGL.Shader(cgl,'MinimalMaterial');
* shader.setSource(attachments.shader_vert,attachments.shader_frag);
*/
const Shader = function (_cgl, _name)
const Shader = function (_cgl, _name, _op)
{
if (!_cgl) throw new Error("shader constructed without cgl " + _name);

Expand All @@ -52,6 +52,8 @@ const Shader = function (_cgl, _name)

if (!_name) this._log.stack("no shader name given");
this._name = _name || "unknown";

if (_op) this.opId = _op.id;
this.glslVersion = 0;
if (_cgl.glVersion > 1) this.glslVersion = 300;

Expand Down
5 changes: 3 additions & 2 deletions src/core/cgl/cgl_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,10 @@ Context.prototype._setBlendMode = function (blendMode, premul)
}
};

Context.prototype.createMesh = function (geom, glPrimitive)
Context.prototype.createMesh = function (geom, options)
{
return new CGL.Mesh(this, geom, glPrimitive);
if (CABLES.UTILS.isNumeric(options))options = { "glPrimitive": options }; // old constructor fallback...
return new CGL.Mesh(this, geom, options);
};


Expand Down
1 change: 1 addition & 0 deletions src/libs/cgl/shadermodifier/cgl_shadermodifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ShaderModifier
this.needsTexturePush = false;
this._lastShader = null;
this._attributes = [];
if (options && options.opId) this.opId = options.opId;

if (this._cgl.glVersion == 1)
{
Expand Down
Binary file modified src/ops/base/Ops.Anim.LFO/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/ops/base/Ops.Array.ArrayChunk/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const moduleFrag = null;
inTex.onChange = updateLookupTexture;


const mod = new CGL.ShaderModifier(cgl, op.name);
const mod = new CGL.ShaderModifier(cgl, op.name, { "opId": op.id });
mod.addModule({
"title": op.name,
"name": "MODULE_VERTEX_POSITION",
Expand Down
19 changes: 5 additions & 14 deletions src/ops/base/Ops.Deprecated.Circlex/Ops.Deprecated.Circlex.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,25 +216,16 @@ function calc()
);

texCoords.push(
posxTexCoord, 0,
oldPosXTexCoord, 0,
posxTexCoordIn, 1,

posxTexCoord, 1,
oldPosXTexCoord, 0,
oldPosXTexCoordIn, 1);
posxTexCoord, 0, oldPosXTexCoord, 0, posxTexCoordIn, 1, posxTexCoord, 1, oldPosXTexCoord, 0, oldPosXTexCoordIn, 1);

vertexNormals.push(
0, 0, 1, 0, 0, 1, 0, 0, 1,
0, 0, 1, 0, 0, 1, 0, 0, 1
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1
);
tangents.push(
1, 0, 0, 1, 0, 0, 1, 0, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0
);
biTangents.push(
0, -1, 0, 0, -1, 0, 0, -1, 0,
0, -1, 0, 0, -1, 0, 0, -1, 0);
0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0);
}

oldPosXTexCoordIn = posxTexCoordIn;
Expand Down Expand Up @@ -264,7 +255,7 @@ function calc()

if (geom.vertices.length == 0) return;
if (mesh) mesh.dispose();
mesh = op.patch.cg.createMesh(geom);
mesh = op.patch.cg.createMesh(geom, { "opId": op.id });
needsCalc = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let render = op.inTrigger("render");
let trigger = op.outTrigger("trigger");

let cgl = op.patch.cgl;
let shader = new CGL.Shader(cgl, op.name);
let shader = new CGL.Shader(cgl, op.name, op);

shader.setSource(shader.getDefaultVertexShader(), attachments.scroller_frag);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function reset()
// if(mesh) mesh.addVertexNumbers=true;
// if(mesh) mesh.setGeom(geom);
if (mesh)mesh.dispose();
mesh = new CGL.Mesh(cgl, geom, cgl.gl.POINTS);
mesh = new CGL.Mesh(cgl, geom, { "glPrimitive": cgl.gl.POINTS });
mesh.addVertexNumbers = true;
// mesh.setGeom(geom);
}
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@

const exe=op.inTrigger("exe");
var num=op.addInPort(new CABLES.Port(op,"num"));
var size=op.addInPort(new CABLES.Port(op,"size"),CABLES.OP_PORT_TYPE_VALUE);
var seed=op.addInPort(new CABLES.Port(op,"random seed"));
var scaleX=op.addInPort(new CABLES.Port(op,"scaleX",CABLES.OP_PORT_TYPE_VALUE,{ display:'range' }));
var scaleY=op.addInPort(new CABLES.Port(op,"scaleY",CABLES.OP_PORT_TYPE_VALUE,{ display:'range' }));
var scaleZ=op.addInPort(new CABLES.Port(op,"scaleZ",CABLES.OP_PORT_TYPE_VALUE,{ display:'range' }));
const exe = op.inTrigger("exe");
let num = op.addInPort(new CABLES.Port(op, "num"));
let size = op.addInPort(new CABLES.Port(op, "size"), CABLES.OP_PORT_TYPE_VALUE);
let seed = op.addInPort(new CABLES.Port(op, "random seed"));
let scaleX = op.addInPort(new CABLES.Port(op, "scaleX", CABLES.OP_PORT_TYPE_VALUE, { "display": "range" }));
let scaleY = op.addInPort(new CABLES.Port(op, "scaleY", CABLES.OP_PORT_TYPE_VALUE, { "display": "range" }));
let scaleZ = op.addInPort(new CABLES.Port(op, "scaleZ", CABLES.OP_PORT_TYPE_VALUE, { "display": "range" }));
// var round=op.inValueBool('round',false);

var cgl=op.patch.cgl;
let cgl = op.patch.cgl;

scaleX.set(1);
scaleY.set(1);
scaleZ.set(1);

function doRender()
{
if(mesh)
if (mesh)
{
mesh.render(cgl.getShader());

if (cgl.shouldDrawHelpers(op))
{
CABLES.GL_MARKER.drawCube(op,
size.get()/2*scaleX.get(),
size.get()/2*scaleY.get(),
size.get()/2*scaleZ.get());
size.get() / 2 * scaleX.get(),
size.get() / 2 * scaleY.get(),
size.get() / 2 * scaleZ.get());
}
}
}

exe.onTriggered=doRender;
exe.onTriggered = doRender;

var mesh=null;
var geom=null;
var mesh = null;
let geom = null;

function reset()
{
geom=new CGL.Geometry();
var verts=[];
var n=Math.round(num.get())||1;
if(n<0)n=1;
var texCoords=[];
var vertColors=[];
verts.length=n*3;
texCoords.length=n*2;
vertColors.length=n*3;
geom = new CGL.Geometry();
let verts = [];
let n = Math.round(num.get()) || 1;
if (n < 0)n = 1;
let texCoords = [];
let vertColors = [];
verts.length = n * 3;
texCoords.length = n * 2;
vertColors.length = n * 3;

Math.randomSeed=seed.get()+0.01;
Math.randomSeed = seed.get() + 0.01;

var sizeMul=size.get();
let sizeMul = size.get();

for(var i=0;i<num.get();i++)
for (let i = 0; i < num.get(); i++)
{
verts[i*3+0]=scaleX.get()*(Math.seededRandom()-0.5)*sizeMul;
verts[i*3+1]=scaleY.get()*(Math.seededRandom()-0.5)*sizeMul;
verts[i*3+2]=scaleZ.get()*(Math.seededRandom()-0.5)*sizeMul;
verts[i * 3 + 0] = scaleX.get() * (Math.seededRandom() - 0.5) * sizeMul;
verts[i * 3 + 1] = scaleY.get() * (Math.seededRandom() - 0.5) * sizeMul;
verts[i * 3 + 2] = scaleZ.get() * (Math.seededRandom() - 0.5) * sizeMul;

vertColors[i*3+0]=Math.seededRandom();
vertColors[i*3+1]=Math.seededRandom();
vertColors[i*3+2]=Math.seededRandom();
vertColors[i * 3 + 0] = Math.seededRandom();
vertColors[i * 3 + 1] = Math.seededRandom();
vertColors[i * 3 + 2] = Math.seededRandom();

texCoords[i*2]=Math.seededRandom();
texCoords[i*2+1]=Math.seededRandom();
texCoords[i * 2] = Math.seededRandom();
texCoords[i * 2 + 1] = Math.seededRandom();
}

geom.setPointVertices(verts);
geom.vertColors=vertColors;
geom.texCoords=texCoords;
geom.vertColors = vertColors;
geom.texCoords = texCoords;

if(mesh)mesh.dispose();
mesh =new CGL.Mesh(cgl,geom,cgl.gl.POINTS);
mesh.addVertexNumbers=true;
if (mesh)mesh.dispose();
mesh = new CGL.Mesh(cgl, geom, { "glPrimitive": cgl.gl.POINTS });
mesh.addVertexNumbers = true;
mesh.setGeom(geom);
}

size.set(5);
seed.set(0);
seed.onChange=reset;
num.onChange=reset;
size.onChange=reset;
scaleX.onChange=reset;
scaleZ.onChange=reset;
scaleY.onChange=reset;
seed.onChange = reset;
num.onChange = reset;
size.onChange = reset;
scaleX.onChange = reset;
scaleZ.onChange = reset;
scaleY.onChange = reset;

num.set(1000);
Loading

0 comments on commit a906a92

Please sign in to comment.