mikiex's Recent Forum Activity

  • You're welcome to do what you want with it

    I wish I had more time to improve it, but I thought I would post it rather than just leave it sitting on my pc doing nothing.

    You might be interested in : http://accad.osu.edu/~smay/RManNotes/RegularPatterns/index.html

    Its a page about regular patterns using Renderman shaders but they are very similar to HLSL.

    Construct is cool btw

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is a quick example of how you could use an effect to replace a sprite with a procedual texture, this fx file makes a circle. This is unfinished in as much as it could be made to do things such as having a consistant line width, allow custom colours etc.

    Hope someone finds it useful

    // AMS_Circle
    // Mikiex
    // PS 2.0
    // Circle Maker Example.
    
    //#CROSS-SAMPLING : changes Tex.xy.
    //#PARAM float Cwidth 0.1 : Circle line width : Circle line width.
    //#PARAM float edgefuzz 0.01 : edgefuzz : Fuzzyness of the edges.
    
    // Parameter variables
    float Cwidth;
    float edgefuzz;
    
    // Foreground texture
    texture ForegroundTexture;
    
    // Foreground sampler
    sampler2D foreground = sampler_state {
        Texture = (ForegroundTexture);
        MinFilter = Linear;
        MagFilter = Linear;
        MipFilter = Linear;
    };
    
    // Increments 1 per frame
    float frameCounter;
    
    //These are all constants from Construct
    float boxLeft;
    float boxRight;
    float boxTop;
    float boxBottom;
    float pixelWidth;
    float pixelHeight;
    float hotspotX;
    float hotspotY;
    float boxWidth;
    float boxHeight;
    float angle;
    
    // Effect function
    float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
    {
    
    //    float4 jj = tex2D(foreground, Tex.xy); //we just ignore the original image
    	float tx = (Tex.x-boxLeft)/boxWidth; // make the box into U coords from 0 to 1
    	float ty = (Tex.y-boxTop)/boxHeight; // make the box into V coords from 0 to 1
    	float res = distance(0.5,float2(tx,ty)); // Use the distance function to create what looks like a radial gradient
    	float xfuzz = boxWidth*edgefuzz; // how fuzzy do we want the x edges
    	float yfuzz = boxHeight*edgefuzz; // how fuzzy do we want the y edges
    	
    	float SS1 = 0.5; // this sets the smoothstep position
    	float SS2 = 0.5-Cwidth; // this is the inside smoothstep position
    	
    	res = smoothstep(SS1,SS1-xfuzz,res)*smoothstep(SS2-yfuzz,SS2,res); // the magic of smoothstep!
     
      	
      	float4 resr = {res,0,0,res}; // we pass the result to just the red channel and the alpha channel
    
        return resr;
    }
    
    // ConstructEffect
    technique ConstructEffect
    {
        pass p0
        {
            VertexShader = null;
            PixelShader = compile ps_2_0 EffectProcess();
        }
    }[/code:3skzwxbh]
  • I think you want the boxLeft/boxTop/boxRight/boxBottom float parameters, which are detailed here.

    I did try this, i noticed these in the source code. But I was getting strange results.

    I'll post a .fx snippet

    The idea I had was to generate a procedual replacement of a sprite.

    You can easy make things like circles etc.

  • Hi,

    I like how construct is going, but I have a question - how would I match an effects (in and FX file) UV's so they match the box around the sprite. So I want to get the world coords from the corners of the box into the shader.

    Mhmhm did I explain that bad?

mikiex's avatar

mikiex

Member since 11 May, 2008

None one is following mikiex yet!

Trophy Case

  • 16-Year Club

Progress

16/44
How to earn trophies