This project is read-only.

HLSL: noise intrinsic function

Apr 29, 2010 at 12:55 PM


Hi.

First of all congratulations for this great piece of software.

Back to the problem, I am trying to use the "noise" intrinsic function in a custom shader.
Unfortunatetly, I always end up with one of these erros:

// Error generating shader:
//(48): error X4532: cannot map expression to vertex shader instruction set (line: 47 col: 0)
// Error generating shader:
//(73): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression (line: 72 col: 0)
// Error generating shader:
//ID3DXEffectCompiler: Compilation failed (line: 2 col: 0)

or

// Error generating shader:
//Error decoding PreShader: Unexpected command 'noise' (line: 0 col: 0)

 I already noticed that these errors depend if I am using a varying variable:

float4 Tutorial09PS(float2 texCoord : TEXCOORD0) : COLOR 
{
	float n = noise(texCoord);
	return n*tex2D(DisplayTextureSampler, texCoord);
}

or a constant:

float4 Tutorial09PS(float2 texCoord : TEXCOORD0) : COLOR 
{
	float n = noise(0);
	return n*tex2D(DisplayTextureSampler, texCoord);
}

 as the "noise" input argument. Also, to avoid possible external problems (I really don't trust my code that much :D), I tested this using the "Tutorial_09".

Is there any limitation in Xen using this "noise" function? I remember using this function before, but it was before using Xen.

Thanks in advance!

Apr 29, 2010 at 1:18 PM

Unfortuntely noise() is not supported at all in HLSl.

DirectX Frequently Asked Questions
What is the HLSL noise() intrinsic for?

The noise intrinsic function generates perlin noise as defined by Ken Perlin. The HLSL function can currently only be used to fill textures in texture shaders as current h/w does not support the method natively. Texture shaders are used in conjuction with the D3DXFill*Texture() functions which are useful helper functions to generate procedurally defined textures during load time.

Yeah. I'm not sure what they were thinking :-) HLSL is crazy in how much scope it covers.