User Tag List

Results 1 to 2 of 2

Thread: Texture disappears under DX11

  1. #1
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    581
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Texture disappears under DX11

    Hi all.
    I'm now making a custom version of looki's PixelOutline shader, as it couldn't process blend coef correctly(see pics below)


    Cause it only draw outlines at pixels that alpha = 0.0, and you can't get texture's alpha coef set in fusion properties window, so the alpha coef of outlines are always 1.0.
    So I attempted to add a custom AlphaCoef to fix this, and it works fine under DX9:

    But things go wrong under DX11, objects with this shader are all disappeared during runtime.I tried to isolate the issue, and I found the culprit, it seems that if you multiply the custom AlphaCoef to the texture's alpha coef, this texture will disappear.

    Here follows the shader demo and the mfa:
    DX11_Disappear.zip
    ...or you can quick check the shader here:
    XML:
    Code:
    <effect>
    <name>DX11_Disappear</name>
    <description>DX11_Disappear</description>
    <parameter>
    		<name>AlphaCoef</name>
    		<code>AlphaCoef</code>
    		<type>float</type>
    		<property>edit</property>
    		<value>0</value>
    </parameter>
    </effect>
    DX9:
    Code:
    sampler2D img;
    float fPixelWidth, fPixelHeight;
    int AlphaCoef;
    float4 ps_main(in float2 In: TEXCOORD0) : COLOR0	{
    	float4 src = tex2D(img,In);
    	float Alpha=1-AlphaCoef/255.0;
    	
    	src.a=src.a*Alpha;
    	return src;
    }
    
    technique tech_main	{ pass P0 { PixelShader = compile ps_2_0 ps_main(); }  }
    DX11:
    Code:
    // Pixel shader Input structure
    struct PS_INPUT
    {
      float4 Tint : COLOR0;
      //float2 Texture    : TEXCOORD0;
      float2 texCoord : TEXCOORD0;
      
      //SV_POSITION is used in vortex shader
      float4 Position : SV_POSITION;
    };
    
    // Pixel shader output structure
    struct PS_OUTPUT
    {
        float4 Color : SV_TARGET;
    };
    
    //Sampler
    Texture2D<float4> Texture0 : register(t0);
    sampler Texture0Sampler : register(s0);
    
    cbuffer PS_VARIABLES : register(b0)
    {
    	int AlphaCoef;
    };
    
    cbuffer PS_PIXELSIZE:register(b1){
    	float fPixelWidth; 
    	float fPixelHeight; 
    }
    
    
    PS_OUTPUT ps_main( in PS_INPUT In)
    {
    	// Output pixel
        PS_OUTPUT src;
    	
    	src.Color = Texture0.Sample(Texture0Sampler, In.texCoord) * In.Tint;
    	float Alpha=1-AlphaCoef/255.0;
    	
    	src.Color.a=src.Color.a*Alpha;
    	return src;
    }
    Actually I found that blend demo works properly under DX11, but I couldn't tell the difference between two methods, so where did I miss? Or this is another bug of DX11 runtime?

  2. #2
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    581
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    After a bit research I found the reason. It seems that DX11 runtime doesn't do type conversion like DX9 does. So when int type in hlsl file gets the value fusion passes as float type defined in XML file, appearently int will become a value much larger than 255, which causes the problem.
    Noted it here in case someone may incounter the same issue.

Similar Threads

  1. Converting DX9 shaders to DX11
    By Yves in forum Shader Development
    Replies: 62
    Last Post: 3rd March 2022, 10:30 PM
  2. Replies: 3
    Last Post: 5th September 2021, 03:24 PM
  3. Can someone please convert P3D shaders for DX11 ?
    By NaitorStudios in forum Shader Development
    Replies: 7
    Last Post: 6th October 2020, 06:12 AM
  4. Bayer Dither for DX11
    By Sloxone in forum Shader Development
    Replies: 0
    Last Post: 2nd June 2020, 10:29 PM
  5. DX11 Font Appears Different in Runtime
    By Kid_Roleplay in forum Fusion 2.5
    Replies: 1
    Last Post: 28th April 2019, 07:12 AM

Posting Permissions

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