fxied bug in shader node

This commit is contained in:
tamat
2019-05-23 18:35:59 +02:00
parent 3dcf1ad38a
commit 50d3fb77bd
2 changed files with 16 additions and 16 deletions

View File

@@ -773,8 +773,8 @@
NodeScript.prototype.compileCode = function(code) {
this._func = null;
if (code.length > 100) {
console.warn("Script too long, max 100 chars");
if (code.length > 256) {
console.warn("Script too long, max 256 chars");
} else {
var code_low = code.toLowerCase();
var forbidden_words = [

View File

@@ -601,7 +601,8 @@
shader = new GL.Shader( Shader.SCREEN_VERTEX_SHADER, final_pixel_code );
this.boxcolor = "#00FF00";
} catch (err) {
console.log("Error compiling shader: ", err, final_pixel_code );
//console.log("Error compiling shader: ", err, final_pixel_code );
GL.Shader.dumpErrorToConsole(err,Shader.SCREEN_VERTEX_SHADER, final_pixel_code);
this.boxcolor = "#FF0000";
this.has_error = true;
return;
@@ -610,6 +611,9 @@
this._shader_code = uvcode + "|" + pixelcode;
}
if(!this._shader)
return;
var value = this.getInputData(2);
if (value != null) {
this.properties.value = value;
@@ -676,14 +680,16 @@
this.addOutput("out", "Texture");
this.properties = {
code: "",
u_value: 1,
u_color: [1,1,1,1],
width: 512,
height: 512,
precision: LGraphTexture.DEFAULT
};
this.properties.code =
"\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n//your code here\n\ngl_FragColor = vec4(color, 1.0);\n}\n";
this._uniforms = { in_texture: 0, texSize: vec2.create(), time: 0 };
"//time: time in seconds\n//texSize: vec2 with res\nuniform float u_value;\nuniform vec4 u_color;\n\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n //your code here\n color.xy=uv;\n\ngl_FragColor = vec4(color, 1.0);\n}\n";
this._uniforms = { u_value: 1, u_color: vec4.create(), in_texture: 0, texSize: vec2.create(), time: 0 };
}
LGraphTextureShader.title = "Shader";
@@ -819,6 +825,7 @@
var in_tex = null;
//set uniforms
if(this.inputs)
for (var i = 0; i < this.inputs.length; ++i) {
var info = this.getInputInfo(i);
var data = this.getInputData(i);
@@ -855,18 +862,11 @@
uniforms.texSize[0] = w;
uniforms.texSize[1] = h;
uniforms.time = this.graph.getTime();
uniforms.u_value = this.properties.u_value;
uniforms.u_color.set( this.properties.u_color );
if (
!this._tex ||
this._tex.type != type ||
this._tex.width != w ||
this._tex.height != h
) {
this._tex = new GL.Texture(w, h, {
type: type,
format: gl.RGBA,
filter: gl.LINEAR
});
if ( !this._tex || this._tex.type != type || this._tex.width != w || this._tex.height != h ) {
this._tex = new GL.Texture(w, h, { type: type, format: gl.RGBA, filter: gl.LINEAR });
}
var tex = this._tex;
tex.drawTo(function() {