Search Result

  • RE: Get Character's current Animation-Frame's Size & Position?

    Ah yes, it might make Sense to explain that Problem: The Character.Position is centered on the manually set Point where the Character's Feet touch the Ground, but if a Sprite is being loaded into a Shader as a Texture, the Center-Point will be the upper left Corner of the Sprite, so the Character-Sprite loaded into the Shader would have its upper left Corner centered on the Point where the actual Character's Feet touch the Ground (and the loaded Sprite would be displayed to the bottom right of the actual Character). So, the Sprite loaded into the Shader should have its upper left Corner placed where the actual Character's Sprite has its upper left Corner placed on Screen.The Problem is similar to scaling or rotating an Object via Lua, in which Case the Sprite's "RotationCenter" can and should be set as well, but since "graphics.shaderUniform" wants me to load in a Sprite via Filepath, I seemingly cannot just make it load a specificly defined Sprite that has been definied to have its RotationCenter at a specific Point (if that would even help me here).So, I am afraid the Character.Position is not what I am looking for in this particular Case, though I am currently using that (and Character.Size) to place and scale the Sprite in the Shader, but that needs anadditional Correction, and depending on my Character's current Animation, that Approximation (which necessarily includes Values which make no Sense to me) can sometimes fit perfectly and sometimes have a slight but noticeable Offset, possibly (but I can only speculate) because the Character's current Sprite might be cut down to only its visible Pixels (which would be the Difference between "graphics.getAnimationSize" and "graphics.getAnimationInnerSize", which I might be able to use for Scaling (not sure, I tried, it did not work, but maybe I just coded it wrongly), but that still would not help me with the Sprite's Positioning, I think).

    by caligarimarte, 6 years ago

    22
    0
    caligarimarte 6 years ago
  • Get Character's current Animation-Frame's Size & Position?

    Hello, I have recently experimented with some Shader-Ideas (Shadowcasting, Reflections, Crepuscular Rays) by loading my Character's current Sprite into different Shaders via "graphics.getCurrentSpritePath()" -- and it works pretty well! But I have only managed to approximately place and size the loaded Sprite manually inside the Shader, the manual Positioning does not always entirely match up. It would be nice if I could load in that current Animation-Frame's Size and Position (on Screen) to directly feed these Values into the Shader, automatically and always fitting. I have tried several Methods, among them "CurrentSpritePos", "Sprite:getPosition()", and "getAnimationSize()", but the Problem seems to be that the Methods either only work for Object-Sprites but not Character-Sprites, and/or I do not know how a Character's current Animation-Frame could be accessed (except for its Filepath). Can anyone help me with that?

    by caligarimarte, 6 years ago

    22
    0
    caligarimarte 6 years ago
  • RE: [SOLVED] Lightmap-Tint in Character-Shader

    Okay, I have solved the Issue as described, by loading the Lightmap into the Shader and calculating Color of the Player's Spot on it inside the Shader -- assuming a Game-Resolution of 1920*1080px, here are some Code-Snippets for that Solution, in Case anyone else on the Forum might ever need it.LUA-SCRIPT: graphics.shaderUniform(eff, "ObjPosX", Characters["Player"].Position.x /1920); graphics.shaderUniform(eff, "ObjPosY", Characters["Player"].Position.y /1080); graphics.shaderUniform(eff, "_t_LightmapTex", game.CurrentScene.LightMap)  SHADER: uniform sampler2D LightmapTex; uniform float ObjPosX; uniform float ObjPosY; ... vec3 Lightmap = texture2D(LightmapTex, uvVarying / vec2(1920,1080) + vec2(ObjPosX,ObjPosY) ).rgb; result.rgb *= Lightmap;For the Sake of other People's Comfort, if anyone will ever search for it, I will also change the Title of the Thread, to befit the Solution better -- I hope that is okay.

    by caligarimarte, 6 years ago

    5
    0
    caligarimarte 6 years ago
  • RE: [SOLVED] Lightmap-Tint in Character-Shader

    it seems to be -1 for default tint (aka no tint) otherwise if you were to assign a red tint with 0x0000ff, then it would return 255 which I think is the alpha equivalent of hex? Though I have just tried and turned off the Shader-Script entirely, then told Visionaire to wait two Seconds before executing Values.DebugText.String = tostring(Erlene.Tint), and then after another short Pause told it to give show me <vs=debugtext>, and although without the Shader I can clearly see the Character being tinted according to the Lightmap, the Value I am shown is still "-1". So, it must be something other than Default-Tint aka. no Tint...... or is the Character's lightmap-influenced Tint not saved in the Character's "Tint"? This has just now occurred to me, in which Case it would make Sense why this hasn't worked so far. But as far as I can tell, "the lightmap (if present) and scene brightness will be used for the tint of the character", so to my Understanding (or Lack thereof) the Tint according to the Lightmap should actually be accessible via the Character's Tint, without a manual Setting. Or is lightmap-influenced Tint just "no Tint"? But then, where and how do I get the Linghtmap-Influence-Tint via Lua?EDIT: I guess it might be possible to load the current Scene's Lightmap into the Shader and use the Character's Position to calculate from that Lightmap-Image what Color it should be. I guess. I just hoped it would not have to be such a clunky Workaround. :/</vs=debugtext>

    by caligarimarte, 6 years ago

    5
    0
    caligarimarte 6 years ago
  • RE: [SOLVED] Lightmap-Tint in Character-Shader

    tint is 0xBGR I think. for some reason red & blue are not in the correct order they are supposed to be, so red would be something along the lines of 0x00ff00 instead of 0xff0000.I am aware of that (in BGR Red would be 0x0000ff), but that is not my Problem. I just do not know how to visualize the Value so I can check what it looks like, because I have to assume the Conversion Code cannot handle it, and if I depict tostring(Characters["Player"].Tint) in an Object Text via <vs> (since I cannot seem to make Sense of the print-Function in Visionaire), I only get -1 or nil as a Result. Depicting or utilizing (in the Shader) a manually written Hex-Code is no Problem, so I have to assume there is something odd about the Tint's Format, and it is not just that it is BGR.Here is the Conversion-Code, and the Line to depict it as an ObjectText for the Value "DebugText"; "Erlene" is a Global that refers to my Player-Character, getObject("Characters[Erlene]"). What could I be doing wrong?Values.DebugText.String = tostring(Erlene.Tint)hex = tostring(Erlene.Tint):gsub("0x","")graphics.shaderUniform(eff, "ObjTint", { tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))} );

    by caligarimarte, 6 years ago

    5
    0
    caligarimarte 6 years ago
  • [SOLVED] Lightmap-Tint in Character-Shader

    Hello, I recently noticed that after applying a Shader to my Character, the Character would lose its lightmap-influenced Tint. So, I thought I'll just add the Tint to the Shader as a vec3 -- and then I remembered the Tint is in Hex-Code, so I have to try and parse it from Hex to RGB first. I have a functioning Script for the Conversion, at least it functions if I manually write down a Hex-Color like "#ff0000" or "0xff0000" and convert that to RGB, but when I tell the Code to do that with Player-Character's Tint, it just doesn't work. I would like to try and display what the Character's Tint Value looks like, by trying to display it either as an Int or a String onscreen (I don't seem to understand how to use the print Function in Visionaire -- yes, I know that sounds ridiculous), but the only Results I get are "-1" or "nil", but never anything that looks like a Hex-Colorcode. So, in Order to know what exactly it looks like and to know how the Hex-RGB-Conversion Script must be adapted, how can I see the Character's Tint displayed anywhere?

    by caligarimarte, 6 years ago

    5
    0
    caligarimarte 6 years ago
  • RE: Torch effect like in Lone Survivor?

    You need the shader tool kit, its called  shaderscript11.lua and you'll find it in the wikihttp://www.visionaire-studio.com/luadocs/downloads/shaderscript11.luaOrder matters! so the shaderscript11 is listed first then the script with the vignette shader script

    by Nigec, 6 years ago

    4
    0
    Nigec 6 years ago
  • RE: Torch effect like in Lone Survivor?

    You can do it with a Shader, I failed dismally but Simon put me right:local name = "vignette"shader_effects[name] = { shader = Shaders.vignette.Compiled }shaderAddEffect(name)shader_effects[name].num.u_resolution = {1920,1080}shader_effects[name].num.vPos = {1920/2,1080/2}varying vec2 uv;uniform sampler2D texel;uniform vec2 u_resolution;uniform vec2 vPos;void main (){  vec4 color = texture2D(texel, uv);  vec2 position = uv - vec2(0.5);             float dist = length(position * vec2(u_resolution.x/u_resolution.y, 1.0));  float radius = 0.5;  float softness = 0.09;  float vignette = smoothstep(radius, radius - softness, dist);  color.rgb = color.rgb - (1.0 - vignette);  gl_FragColor = color;}

    by Nigec, 6 years ago

    4
    0
    Nigec 6 years ago
  • RE: Torch effect like in Lone Survivor?

    The professional way would be a shader, but I have no idea how to do that, maybe look into vignetting?The age old  way is and image with a transparent dot in the center twice the size of the stage as a cursor or following overlay

    by Nigec, 6 years ago

    4
    0
    Nigec 6 years ago
  • RE: [Solved] Shaders (again) in VS5

    Oh great, yes it works, thanks so much!!!So to summarize for future people who would be interested:1 - Use the latest script availableGet it here: https://www.visionaire-studio.com/luadocs/#shadertoolkit(download shaderscript.lua, open it and paste the content in a new Definition script)2 - Make sure you use the correct syntax (check the examples in the script, the syntax might differ from previous versions)Examples:-- shaderBlur(radius, delay)-- shaderSaturation(factor, delay)-- shaderLightness(offset, delay)-- shaderContrast(contrast, delay)3 - Use this script to activate a premade fullscreen shader:local name = "ShaderName"shaderAddEffect(name)shader_effects[ name].num.speed = 0.2bind(name, "time", field("shader_iTime"))(where you have to replace ShaderName by one of these:warp1tv1ripple1*ripple2*asciiedgeglowchromaripple3warp2ripple4pearlshighlightfourbittv2tv3tv4)* Might be brokenAnd enjoy the result!

    by Simon_ASA, 6 years ago

    8
    0
    Simon_ASA 6 years ago