How to use noise() in HLSL
hi all,
I use it this way:
fragout Out;
float4 color=tex2D(TextureSampler, TexCoord);
float cc=noise(color);
Out.color=float4(cc,0.0,0.0,1.0);
Then it prompts this error:"error X4532: cannot map expression to pixel shader instruction set."
but when I change "Out.color=float4(cc,0.0,0.0,1.0);" to "Out.color=float4(1.0,0.0,0.0,1.0);", it will be OK:
fragout Out;
float4 color=tex2D(TextureSampler, TexCoord);
float cc=noise(color);
Out.color=float4(1.0,0.0,0.0,1.0);
Can anyone tell me why? And give me an sample source code to show how to use noise()?
Thanks!
noise() is only supported in Texture Shaders. From the wording of your error, you're trying to use it in a Pixel Shader. That won't work.
When you change your shader to not use the value generated by noise, the HLSL compiler optimizes that function out (since you don't use the value) and thus doesn't give you an error.
Hope this helps.
When you change your shader to not use the value generated by noise, the HLSL compiler optimizes that function out (since you don't use the value) and thus doesn't give you an error.
Hope this helps.
Thanks.
Can you give me an example to show how to use noise() function? having sourcecode is best.
3x
Can you give me an example to show how to use noise() function? having sourcecode is best.
3x
Quote:Original post by skyman_cnA texture shader is pretty much the same thing (iirc no reading from samplers though) just you run it via D3DXFillTextureTX() instead of via the normal pipeline. Pull up the docs on that function and you should be ready to go [smile]
Can you give me an example to show how to use noise() function?
hth
Jack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement