Funky Koval's Forum Posts

  • I'm actually using 3DObjects as well, for different parts of the project. The problem is that I need to dynamically alter the shape of the Sprite as a whole, but only at object init. Think of it as randomly generated terrain.

  • The title says it all... Does anyone know how to achieve Sprite rotation similar to Pitch/Yaw/Roll for 3DBoxes or 3DObjects? I can do it by transforming Distort Points, but it's very inefficient to transform every single point...

    Alternatively, how difficult would it be to implement such functionality in Sprites? And would anyone be willing to do it?

    I've reached a point in my project where performance is adversely affected by unnecessarily transforming a crapload of Distort Points. I've decided to seek help here before deciding to cut down on detail.

    Thanks in advance.

  • Pixel Distort

    Performs absolute pixel shifting on underlying data. Download the .cap to see an example. Cannibalized from DistortNormal and Offset.

    The layer with PixelDistort becomes a coordinate array where R,G equals X,Y for picking final color values. Sprite/Canvas dimensions act as a multiplier to distortion values. Only rotations in 90 degrees increments give predictable results.

    *EDIT*

    Updated the shader - functionality is the same, but now for pasting to canvas, Max X distortion and Max Y distortion should just be set to DisplayWidth and DisplayHeight. Also, B and A channel usage has been removed, since the distortion strenght is now relative to the source dimensions.

    // Pixel Distort

    // Q'ba

    // PS 2

    // Shifts BG.RGB values based on FG.RG

    //#CROSS-SAMPLING : changes Tex.xy.

    //#PARAM float xmax 256 : Max X distortion: In pixels. Corresponds to R=255. For pasting into Canvas, set to DisplayWidth.

    float xmax;

    //#PARAM float ymax 256 : Max Y distortion : In pixels. Corresponds to G=255. For pasting into Canvas, set to DisplayHeight.

    float ymax;

    //#PARAM float poff 0.5 : Precission offset : In pixels. Prevents sampling the preceeding/superceeding pixel.

    float poff;

    float pixelWidth;

    float pixelHeight;

    float boxLeft;

    float boxTop;

    // Foreground texture

    texture ForegroundTexture;

    // Background texture

    texture BackgroundTexture;

    // Foreground sampler

    sampler2D foreground = sampler_state {

        Texture = (ForegroundTexture);

        MinFilter = Point;

        MagFilter = Point;

        MipFilter = Point;

    };

    // OriginalTexture sampler

    sampler2D background = sampler_state {

        Texture = (BackgroundTexture);

        MinFilter = Point;

        MagFilter = Point;

        MipFilter = Point;

    };

    // Effect function

    float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0

    {

         float4 col = tex2D(foreground, Tex.xy);

         {

              Tex.x = boxLeft+pixelWidth*(poff+col.r*xmax);

              Tex.y = boxTop+pixelHeight*(poff+col.g*ymax);

              col = tex2D(background, Tex.xy);

         }

         return col;

    }

    // ConstructEffect

    technique ConstructEffect

    {

        pass p0

        {

            VertexShader = null;

            PixelShader = compile ps_2_0 EffectProcess();

        }

    }

  • Yup. That was one of the first ideas I tried - I even tested it with a 3DBox as well - works fine as long as you do not alter the pitch/roll/yaw values, which I sadly need to do...

    I'll either live with the changing FOV or just render the view at the highest supported res and downscale it, though it's a huge waste of resources...

    Thank you for your help.

  • That's what I was affraid of. Setting depth individually won't work though - I'm using 3DObjects as well as Sprites, so they'd have to not only be placed at a correct depth, but also "skewed" (if rotated to non-right angles), to fake a constant view cone - something Construct cannot do. I've tried non-equal layer zoom valutes too, but that didn't work.

    Thanks for your help.

  • The title says it all. Is there any way to modify EyeDistance dynamically at runtime, or at least on layout change? I'm working on a multi-resolution project utilizing depth extensively and I need the variable Eye Distance to keep the FOV constant across resolutions.

    Thanks in advance.

  • For starting the app at a designated time, you can use Task Scheduler - included in Windows.

  • Thank you for the .cap, however this technique requires me to fire several "traces" (the red boxes) to accurately check for visibility - think of it as a field-of-view cone. I'm now checking if that approach is faster than the downscaled playfield I'm using. It definitelly seems much direct and cleaner. Thanks again.

  • That's what I want to avoid.

    To give a wider perspective - I have a game where the player can see very far into the playing filed (meaning a lot of objects are visible), but only interacts with a few of them at a time (the ones closest to him).

    I've tried handling visibility checks using "Per Pixel" collisions and overlap tests, but the performance was rather poor - that's why I thought of doing visiblity using "Angled Box", but switching to "Per-Pixel" for player interaction (collision, to be precise).

    Due to the nature of the game, "Box" will not do - the objects are elongated Sprites, so "Box" would create a lot of false visibility positives.

    Currently, I have it solved using a shrunk-down copy of the playing field set to per-pixel collisions - the performace is acceptable, but I have a large Event Sheet just for that purpose. Plus it complicates Pairing tasks.

    Thanks for your assistance.

  • It seems that while Angled Box is available as a collision method, the Event for toggling collision types at runtime does not list it - it still has only point, box and per pixel.

    Does anyone know of a workaround if one needs to toggle collision modes on the fly? Thanks.

  • Is it max 9 or max 2009? If the former, grab the free GuruWare .obj exporter - it's included in the newer versions. As for the error, I'd wager it's something with your graphics card - drivers maybe or invalid mapping on the mesh - double check your UVs in max just in case.

    I have yet to encounter a crash with .objs exported from max and my "game" uses them quite extensively.

  • newt:

    That won't work, since the data is not explicitly set by me - it is dynamically generated.

    Tulamide

    While the logic seems correct, the shader does not work - it may be pasting the new RGBA data, but as you've mentioned, it doesn't clear the "old" BG first.

    I've managed to find a solution, however - see the attached .cap file - best way to verify that it works is to hover your mouse over a spot and press the left mouse button to perform the paste. You'll see that the RGB values stay intact while A gets correctly modified.

    The visuals are not important - as long as the Image Manipulator picks up the correct data, all is good. Requires NuovoFill, ChannelToAlpha and AlphaReplacer.

    As the shader I've made is useful for a very narrow range of cases, I'll just post it here instead of the Addons forum:

    // AlphaReplacer

    // Funky Koval

    // PS 0.0

    // Replaces BG.A with FG.A. FG.RGB must be zeroed out.

    // ConstructEffect

    technique ConstructEffect

    {

        pass p0

        {

            VertexShader = null;

            PixelShader = null;

         AlphaBlendEnable = TRUE;

         SrcBlend        = INVSRCALPHA;

         DestBlend        = INVSRCCOLOR;       

        }

    }

    Thank you everyone for the assist.

    sendspace.com/file/2tys8o

  • I've been using the Canvas object in conjunction with Image Manipulator to store data in color (RGB) channels for later retrieval. I've reached a point where I require a fourth storage channel (Alpha) for this purpose, but I'm unable to paste to it, without destroying existing data in the color channels.

    I've tried Erase, Mask and most of Fisholith's Effects, but as mentioned they destroy the RGB data.

    An example of what I need would be pasting a pixel with RGBA values of 1 1 1 .3 onto a Canvas with .5 .8 .3 1 and getting .5 .8 .3 .3 as a result - the source RGB would be disgarded and the destination A would be replaced with source A.

    I've started writing an Effect for this purpose, but I've hit a snag with relative Sprite sizes (I'm guessing):

    // AlphaReplace

    // Funky Koval

    // PS 2.0

    // Replaces BG alpha with FG alpha preserving color values.

    // Foreground texture

    texture ForegroundTexture;

    // Foreground sampler

    sampler2D foreground = sampler_state {

        Texture = (ForegroundTexture);

        MinFilter = Point;

        MagFilter = Point;

        MipFilter = Point;

    };

    // Background texture

    texture BackgroundTexture;

    // Background sampler

    sampler2D background = sampler_state {

        Texture = (BackgroundTexture);

        MinFilter = Point;

        MagFilter = Point;

        MipFilter = Point;

    };

    // Effect function

    float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0

    {

        float4 bg = tex2D(background, Tex);

        float4 fg = tex2D(foreground, Tex);     

        

        bg.a=fg.a;

        

        return bg;

    }

    // ConstructEffect

    technique ConstructEffect

    {

        pass p0

        {

            VertexShader = null;

            PixelShader = compile ps_2_0 EffectProcess();

        }

    }

    Any help would be most appreciated.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Bumpmapping:

    Not directly and probably not very precisely - you can bumpmap a 2D projection of your box by having it on a separate layer with a normal map texture applied and having that bump-mapping Effect on - the name escapes me at the moment. Then you'd probably have to use events to set up a "light" for the light direction.

    Squirrel!:

    Use Physics with springs to create a chain of objects, but for display, use Ribbon and bind each Ribbon vertex to each of the Physics chain object's pivot.

  • Like you've mentioned, GlovePIE will work by having a script that continuously loops a key hold action.

    AutoIt3 can do it too, plus it can compile your script into an executable.