karlis Posted July 1, 2011 Share Posted July 1, 2011 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
karlis Posted July 3, 2011 Author Share Posted July 3, 2011 sorry, i know its noobish to bump, but really theres noone that understands HLSL? Link to comment
Jockie Posted July 3, 2011 Share Posted July 3, 2011 I see a small typo @ line 17, you've forgot the ; at the end. Link to comment
karlis Posted July 3, 2011 Author Share Posted July 3, 2011 oh true, but doesn't work with fix either. strange that debug script didn't output compile error. Link to comment
eAi Posted July 3, 2011 Share Posted July 3, 2011 ccw might be the person to deal with this - he may be able to put some more output in to report shaded errors. Link to comment
Jockie Posted July 3, 2011 Share Posted July 3, 2011 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
karlis Posted July 3, 2011 Author Share Posted July 3, 2011 EDIT: Have you tried to add VertexShader = null; above to the PixelShader line? didn't work. Link to comment
Jockie Posted July 4, 2011 Share Posted July 4, 2011 @ Line 20 try: newColor.a = 0.0f; Link to comment
karlis Posted August 30, 2011 Author Share Posted August 30, 2011 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
50p Posted August 31, 2011 Share Posted August 31, 2011 I'm not a shader writer but to me it looks like you're missing ; (line 13 and 31 as well). Remember, it's not Lua, you need to use ;. This is the reason why I use them in my Lua scripts. Link to comment
karlis Posted August 31, 2011 Author Share Posted August 31, 2011 I'm not a shader writer but to me it looks like you're missing ; (line 13 and 31 as well). Remember, it's not Lua, you need to use ;. This is the reason why I use them in my Lua scripts. apparently that was 1 of the reasons, thanks Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now