Search Result

  • ShaderToolkit96_Failed to execute hook function 'shaderMain' [SOLVED]

    Hello! I ran into a problem that I don't know how to solve yet: When I exit the game in the menu, I have the option to continue the game (with autosave). If I continue in the same gaming session everything works fine. But if I exit the game and then start again and load the autosave, the shader crashes (i.e. does not work). and the following errors appear in the log: 2:35:05.634:stack traceback: [C]: in function 'debugerror' [string "function debugfunc(err) debugerror(err) end"]:1: in function 'debugfunc' [string "(30,6)"]:1038: in function 'shaderMain'2:35:05.634:Failed to execute hook function 'shaderMain':2:35:05.641:[string "(30,6)"]:1038: attempt to call a number value (field 'integer index')2:35:05.641:stack traceback: [C]: in function 'debugerror' [string "function debugfunc(err) debugerror(err) end"]:1: in function 'debugfunc' [string "(30,6)"]:1038: in function 'shaderMain'2:35:05.641:Failed to execute hook function 'shaderMain':2:35:05.645:[string "(30,6)"]:1038: attempt to call a number value (field 'integer index')2:35:05.645:stack traceback: [C]: in function 'debugerror' [string "function debugfunc(err) debugerror(err) end"]:1: in function 'debugfunc' [string "(30,6)"]:1038: in function 'shaderMain'2:35:05.645:Failed to execute hook function 'shaderMain':2:35:05.652:[string "(30,6)"]:1038: attempt to call a number value (field 'integer index')Can you suggest where to look for the problem? What to check?1038:  shader_effects[v[1]].num[v[2]] = v[3]()      end    end  end  registerEventHandler("mainLoop", "shaderMain")  shaderMain()  passesUpdate()Thanks.

    by red363, 3 years ago

    7
    0
    red363 3 years ago
  • RE: ShaderToolkit fourbit question

    I added the long code in Sharder tab and name it fourbit. I added the code in Fragment tab, what do I need to add in Vertex tab?Then when I'm trying to "Execute a script" with the lines:" shader_effects["fourbit"] = { shader = Shaders["fourbit"].Compiled } shaderAddEffect("fourbit") bind("fourbit", "time", field("shader_iTime")) shader_effects["fourbit"].num.pixelSize = 1" Doesn´t work, not sure where the lines goes.

    by Andres, 3 years ago

    12
    0
    Andres 3 years ago
  • RE: ShaderToolkit fourbit question

    You can make the pixel size an uniform: #ifdef GL_ES precision highp float; precision lowp int; #endif uniform float time; uniform sampler2D composite; uniform int renderpass; uniform vec2 mouse; uniform vec2 resolution; varying vec2 texcoord; uniform float pixelSize; // 4BIT COLOR // Maps into DawnBringer's 4-bit (16 color) palette http://www.pixeljoint.com/forum/forum_posts.asp?TID=12795 // Also see the amazing ASCII shadertoy: https://www.shadertoy.com/view/lssGDj float hash(vec2 p) { return fract(1e4 * sin(17.0 * p.x + p.y * 0.1) * (0.1 + abs(sin(p.y * 13.0 + p.x)))); } float compare(vec3 a, vec3 b) { // Increase saturation a = max(vec3(0.0), a - min(a.r, min(a.g, a.b)) * 0.25); b = max(vec3(0.0), b - min(b.r, min(b.g, b.b)) * 0.25); a*=a*a; b*=b*b; vec3 diff = (a - b); return dot(diff, diff); } void main(void) { vec2 c = floor(texcoord * resolution / pixelSize); vec2 coord = c * pixelSize; vec3 src = texture2D(composite, coord / resolution.xy).rgb; // Track the two best colors vec3 dst0 = vec3(0), dst1 = vec3(0); float best0 = 1e3, best1 = 1e3; # define TRY(R, G, B) { const vec3 tst = vec3(R, G, B); float err = compare(src, tst); if (err < best0) { best1 = best0; dst1 = dst0; best0 = err; dst0 = tst; } } TRY(0.078431, 0.047059, 0.109804); TRY(0.266667, 0.141176, 0.203922); TRY(0.188235, 0.203922, 0.427451); TRY(0.305882, 0.290196, 0.305882); TRY(0.521569, 0.298039, 0.188235); TRY(0.203922, 0.396078, 0.141176); TRY(0.815686, 0.274510, 0.282353); TRY(0.458824, 0.443137, 0.380392); TRY(0.349020, 0.490196, 0.807843); TRY(0.823529, 0.490196, 0.172549); TRY(0.521569, 0.584314, 0.631373); TRY(0.427451, 0.666667, 0.172549); TRY(0.823529, 0.666667, 0.600000); TRY(0.427451, 0.760784, 0.792157); TRY(0.854902, 0.831373, 0.368627); TRY(0.870588, 0.933333, 0.839216); # undef TRY best0 = sqrt(best0); best1 = sqrt(best1); gl_FragColor = vec4(mod(c.x + c.y, 2.0) > (hash(c * 2.0 + fract(sin(vec2(floor(time), floor(time* 1.7))))) * 0.75) + (best1 / (best0 + best1)) ? dst1 : dst0, 1.0); }And then set it via lua:shader_effects["fourbit"] = { shader = Shaders["fourbit"].Compiled } shaderAddEffect("fourbit") bind("fourbit", "time", field("shader_iTime")) shader_effects["fourbit"].num.pixelSize = 1

    by SimonS, 3 years ago

    12
    0
    SimonS 3 years ago
  • RE: ShaderToolkit fourbit question

    A follow-up question, I have the following problem with shaders, I will try to describe: From any scene, I can click on the corresponding interface button and get into the menu. When this button is pressed, Autosave #1 is recorded. Once in the menu, I can press the return to the game button, and, accordingly, autosave #1 is loaded. Everything works fine. But, if you repeat exactly the same thing a second time, then when you return to the game, the shader somehow continues to work, but its animation freezes. This happens with all shaders and in all scenes after doing this algorithm of actions. What could be the reason? Thanks.

    by red363, 3 years ago

    12
    0
    red363 3 years ago
  • RE: ShaderToolkit fourbit question

    Hello! I get this error after I put long code in shader compiler: "error X4000: variable 'outColor' used without having been completely initialized" What could be the problem?

    by red363, 4 years ago

    12
    0
    red363 4 years ago
  • RE: ShaderToolkit fourbit question

    No, put the shader part (the long part) into a shader in the shader section in the engine (third icon from the right upper left), just add a shader and name it fourbit and put the shader in fs, it then compiles automatically, and you can change the pixelsize there if needed. You must use the internal shader compiler.Just add the lua script as a definition script afterwards, there are no changes needed.

    by SimonS, 4 years ago

    12
    0
    SimonS 4 years ago
  • RE: ShaderToolkit fourbit question

    sorry, I´m not expert with this code :DShould I add #ifdef GL_ES code in ShaderToolkit script at the end and add"shader_effects["fourbit"] = { shader = Shaders["fourbit"].Compiled } shaderAddEffect("fourbit") bind("fourbit", "time", field("shader_iTime"))" everytime I wanted to use the fourbit, right?and then play with pixelSize ?(I tried that and it didn´t work) 

    by Andres, 4 years ago

    12
    0
    Andres 4 years ago
  • 5.1.8.1 1226 Update released

    New things:- Used dialog option font- Russian translationChanges:- Can copy/paste in integrity dialog with CTRL+A/C- Action parts are now executed even in fade: change/show character, change/show scene (fades stack), load/save- Select first dialog on character select / Clear if noneIlios changes:- Blocks can be multiselected and copied/pasted- Comment block- Get Object on b2Body - Duplicate/Copy/Remove objects- Static variables in blocks- Convertable blocks crash- Class name checks for invalid chars- Update is now using floats and called (you might need to recreate the block)- Change the component class in scene/object is now possible- Controller events- Clear values on reset- Added some math functionsFixes:- Android is slow- Crashes in rtf export- Monospace fonts are not spaced correctly- Savegames tab crashes on save without savegames- Can walk out of bounds with controller- Open browser in Linux works only once- Action part setting shift up/down work now correctly- Shift up/down doesn't fade sounds- Fade over/Shift shows one frame of the target if interfaces excluded from shader- Characters disappear on fade over/shift- Character animation blinks on hide animation- Script editor can freeze/crash in some scenarios- Align for immediate actions not working

    by SimonS, 4 years ago

    0
    0
    SimonS 4 years ago
  • RE: ShaderToolkit fourbit question

    Here's the code: #ifdef GL_ES precision highp float; precision lowp int; #endif uniform float time; uniform sampler2D composite; uniform int renderpass; uniform vec2 mouse; uniform vec2 resolution; varying vec2 texcoord; // 4BIT COLOR // Maps into DawnBringer's 4-bit (16 color) palette http://www.pixeljoint.com/forum/forum_posts.asp?TID=12795 // Also see the amazing ASCII shadertoy: https://www.shadertoy.com/view/lssGDj float hash(vec2 p) { return fract(1e4 * sin(17.0 * p.x + p.y * 0.1) * (0.1 + abs(sin(p.y * 13.0 + p.x)))); } float compare(vec3 a, vec3 b) { // Increase saturation a = max(vec3(0.0), a - min(a.r, min(a.g, a.b)) * 0.25); b = max(vec3(0.0), b - min(b.r, min(b.g, b.b)) * 0.25); a*=a*a; b*=b*b; vec3 diff = (a - b); return dot(diff, diff); } void main(void) { const float pixelSize = 1.0; vec2 c = floor(texcoord * resolution / pixelSize); vec2 coord = c * pixelSize; vec3 src = texture2D(composite, coord / resolution.xy).rgb; // Track the two best colors vec3 dst0 = vec3(0), dst1 = vec3(0); float best0 = 1e3, best1 = 1e3; # define TRY(R, G, B) { const vec3 tst = vec3(R, G, B); float err = compare(src, tst); if (err < best0) { best1 = best0; dst1 = dst0; best0 = err; dst0 = tst; } } TRY(0.078431, 0.047059, 0.109804); TRY(0.266667, 0.141176, 0.203922); TRY(0.188235, 0.203922, 0.427451); TRY(0.305882, 0.290196, 0.305882); TRY(0.521569, 0.298039, 0.188235); TRY(0.203922, 0.396078, 0.141176); TRY(0.815686, 0.274510, 0.282353); TRY(0.458824, 0.443137, 0.380392); TRY(0.349020, 0.490196, 0.807843); TRY(0.823529, 0.490196, 0.172549); TRY(0.521569, 0.584314, 0.631373); TRY(0.427451, 0.666667, 0.172549); TRY(0.823529, 0.666667, 0.600000); TRY(0.427451, 0.760784, 0.792157); TRY(0.854902, 0.831373, 0.368627); TRY(0.870588, 0.933333, 0.839216); # undef TRY best0 = sqrt(best0); best1 = sqrt(best1); gl_FragColor = vec4(mod(c.x + c.y, 2.0) > (hash(c * 2.0 + fract(sin(vec2(floor(time), floor(time* 1.7))))) * 0.75) + (best1 / (best0 + best1)) ? dst1 : dst0, 1.0); } <font face="monospace"></font>There's pixelSize, I set to it to 1.0. Add this as a shader named fourbit in the shadertab, then you can use with this:shader_effects["fourbit"] = { shader = Shaders["fourbit"].Compiled }shaderAddEffect("fourbit")bind("fourbit", "time", field("shader_iTime"))

    by SimonS, 4 years ago

    12
    0
    SimonS 4 years ago
  • ShaderToolkit fourbit question

    Hi!I´m using Shader Toolkit Version 0.96... is this one the last version?Is there a way to see fourbit less pixelated?Thanks! Andrés

    by Andres, 4 years ago

    12
    0
    Andres 4 years ago