Jump to content

HLSL help


karlis

Recommended Posts

hey, as i needed it for my IVhud resource, i learned a basics of HLSL, and made a simple pixel shader to draw texture in circular shape, however shader somewhy fail to start(returns false when trying to create shader).

is it problem of hardware, or theres some errors?

.fx script:

  
int radius; 
int2 centerPos; 
float4 borderCol; 
texture theMap; 
sampler2D theMapSampler = sampler_state { 
    Texture = (theMap); 
    MinFilter = Anisotropic; 
    MagFilter = Anisotropic; 
    AddressU = Border; 
    AddressV = Border; 
    BorderColor = borderCol; 
} 
  
float4 PixelShaderFunction( float2 texCord : TEXCOORD0, int2 pixelPos : VPOS0 ) : COLOR0 
{ 
    float4 newColor 
    newColor = tex2D(theMapSampler,texCord); 
    if (distance(pixelPos,centerPos)>radius) 
        newColor.a = 0; 
    return newColor; 
} 
  
technique circularDraw 
{ 
    pass Pass1 
    { 
        AlphaBlendEnable = TRUE; 
        DestBlend = INVSRCALPHA; 
        SrcBlend = SRCALPHA; 
        PixelShader = compile ps_2_0 PixelShaderFunction(); 
    } 
} 

the cut from main script, with all the values etc:

  
local mapBorderCol={0,255,120,255} 
local texture=dxCreateTexture("images/radar.jpg") 
local shader=dxCreateShader("shader.fx") 
dxSetShaderValue(shader,"radius",size) --size is radius of the drawing, it IS defined 
dxSetShaderValue(shader,"centerPos",x,y) --x,y is center of drawing, it IS defined 
dxSetShaderValue(shader,"borderCol",mapBorderCol[1]/255,mapBorderCol[2]/255,mapBorderCol[3]/255,mapBorderCol[4]/255) 
dxSetShaderValue(shader,"theMap",texture) 
  

and yes, its in proper nightly 1.1 version.

Link to comment

I have also sometimes a strange unknown error:

ID3DXEffectCompiler::CompileEffect: There was an error compiling expression

ID3DXEffectCompiler: Compilation failed

When I just try to compile with Pixel Shader 1.1

EDIT: Have you tried to add VertexShader = null; above to the PixelShader line?

Link to comment
  • 1 month later...

24v7fc4.png

im intrested about 1st error, whats wrong?

same script

  
int radius; 
int2 centerPos; 
float4 borderCol; 
texture theMap; 
sampler2D theMapSampler = sampler_state { 
    Texture = (theMap); 
    MinFilter = Linear; 
    MagFilter = Linear; 
    AddressU = Border; 
    AddressV = Border; 
    BorderColor = borderCol; 
} 
  
float4 PixelShaderFunction( float2 texCord : TEXCOORD0, int2 pixelPos : VPOS0 ) : COLOR0 
{ 
    float4 newColor = tex2D(theMapSampler,texCord); 
    if (distance(pixelPos,centerPos)>radius) 
    { 
        newColor.a = 0.0f; 
    } 
    return newColor; 
} 
  
technique circularDraw{ 
    pass Pass1 
    { 
        AlphaBlendEnable = TRUE; 
        DestBlend = INVSRCALPHA; 
        SrcBlend = SRCALPHA; 
        VertexShader = null 
        PixelShader = compile ps_2_0 PixelShaderFunction(); 
    } 
} 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...