User Tag List

Results 1 to 5 of 5

Thread: Combine shaders

  1. #1
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Combine shaders

    Could someone please help me to combine the two shaders in this zip file? All my attempts to do so have failed. I wish I could code... no wait, I wish there was a shader stacking feature!


    FX.zip

  2. #2
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Anyone? Please I'm trying to put together an example that uses infinite scrolling, dynamic level loading (thanks to net ninja), the 3d shader (thanks to Sketchy's example) and Andos's dynamic light and shadow engine as well as the normal map shader.

    I promise it's going to look awesome (as well as being a massive resource hog) - better than GTA 2 but a little worse than LBP

  3. #3
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    This is my current code:

    Code:
    // Pixel shader input structure
    struct PS_INPUT
    {
        float4 Position   : POSITION;
        float2 Texture    : TEXCOORD0;
    
    };
    
    
    // Pixel shader output structure
    struct PS_OUTPUT
    {
        float4 Color   : COLOR0;
    
    };
    
    
    
    //3D Shader variables
    sampler2D Tex0;
    
    float h1;
    float h2;
    float c1;
    float c2;
    float t1;
    float t2;
    float l1;
    float l2;
    
    
    //Normal Map variables
    sampler2D img;
    sampler2D bkd : register(s1);
    
    int lightAenabled, lightBenabled, lightCenabled;
    float4 lightAColor, lightBColor, lightCColor, ambientLight;
    
    float fPixelWidth;
    float fPixelHeight;
    
    float lightAX, lightBX, lightCX;
    float lightAY, lightBY, lightCY;
    float lightAZ, lightBZ, lightCZ;
    float lightABrightness, lightBBrightness, lightCBrightness;
    
    float objX, objY;
    
    PS_OUTPUT ps_main( in PS_INPUT In) : COLOR
    {
    	float4 normal = tex2D(img, In.Texture);
    	normal = float4(normal.x-0.5, normal.y-0.5, normal.z-0.5, normal.w);
    	float4 background = tex2D(bkd, In.Texture);
    	float4 color = float4(0,0,0,normal.a);
    	float3 pixelPos = float3(In.Texture.xy,0);
    	float3 objPos = float3(objX,objY,0);
    	float3 lightPos, dir;
    	float dist, amount;
    
    	float ch = (h1 + (h2 - h1) * In.Texture.x) / 2;
    	float cc = c1 + (c2 - c1) * In.Texture.x;
    	float cl = l1 + (l2 - l1) * In.Texture.x;
    	
    	if(lightAenabled)
    	{
    		lightPos = float3((lightAX-objX)*fPixelWidth+0.5,(lightAY-objY)*fPixelHeight+0.5,lightAZ);
    		dir = normalize(lightPos - pixelPos);
    		dist = 1/length(lightPos - pixelPos);
    		amount = saturate(dot(normal,dir));
    		color.rgb += amount * lightABrightness * dist * lightAColor.rgb;
    	}
    	
    	if(lightBenabled)
    	{
    		lightPos = float3((lightBX-objX)*fPixelWidth+0.5,(lightBY-objY)*fPixelHeight+0.5,lightBZ);
    		dir = normalize(lightPos - pixelPos);
    		dist = 1/length(lightPos - pixelPos);
    		amount = saturate(dot(normal,dir));
    		color.rgb += amount * lightBBrightness * dist * lightBColor.rgb;
    	}
    	
    	if(lightCenabled)
    	{
    		lightPos = float3((lightCX-objX)*fPixelWidth+0.5,(lightCY-objY)*fPixelHeight+0.5,lightCZ);
    		dir = normalize(lightPos - pixelPos);
    		dist = 1/length(lightPos - pixelPos);
    		amount = saturate(dot(normal,dir));
    		color.rgb += amount * lightCBrightness * dist * lightCColor.rgb;
    	}
    	
    
    
    	PS_OUTPUT Out, Normal;
    	Out.Color = float4(1,0,0,1);
    	Normal.Color = float4 (ambientLight.rgb,0) + color * background;
    	
    	if(In.Texture.y < cc - ch || In.Texture.y > cc + ch) //<<<<<<<<<<<< = ps_2_0
    	{
    		Out.Color = float4(0,0,0,0);
    	}
    	
    	else
    	{
    		float cy = (In.Texture.y - cc + ch) / (ch*2);
    		float cx = In.Texture.x * (t2 - t1) + t1;
    		Out.Color = tex2D(Tex0, float2(cx,cy));
    		Out.Color *= float4(cl,cl,cl,1) ;
    	}
    	
    	
    	return Out;
    	//OR return Normal; 
    	//THIS WORKS BUT NOT BOTH!
    }
    
    
    
    // Effect technique
    technique tech_main {pass P0{PixelShader = compile ps_2_0 ps_main();}}

    I want something like:

    return Out + Normal;

    But of course that would be too easy wouldn't it? If all of this is horribly wrong it's because I only took 1st year Python and pretty much failed miserably at it

  4. #4
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Bump. Please help, I think this example I'm working on will be of interest.

  5. #5
    Forum Moderator Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    NaitorStudios's Avatar
    Join Date
    May 2010
    Location
    Brazil
    Posts
    467
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Would like to see it too

Similar Threads

  1. Flipping(giant, high animated) active objects without shaders(or any better shaders?)
    By DinnerSonic in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 24th September 2013, 12:57 PM
  2. Need help with a problem...combine 2 images in one
    By copperbob in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 15th June 2012, 04:19 PM
  3. combine loop with bounce movement
    By jaaj302005 in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 30th November 2011, 09:44 PM
  4. Is there a way to combine the mode 7 with lacewing
    By Tiger in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 2nd June 2011, 12:37 AM
  5. How to combine two images in an Active object?...
    By RGBreality in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 5th April 2011, 02:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •