Two HLSL questions

Posted By: Rigoletto

Two HLSL questions - 09/05/05 11:03

Hi,

yesterday i tried HLSL first time and iŽam suprised that it is very easy and not so complicated it looks. Just make a try with "Introduction to HLSL shaders" at the top in "Shaders". However iŽam makeing a SimpleHLSLShaderTutorial similar to my others.

But i have two questions i canŽt find answer for:

1. How to calculate with two different formats, for example float4 and float2. Casting is not working.

2. Is using functions in HLSL slowing down the shader, or it is compiled inline? I ask why i want to make reusable code?
Posted By: Matt_Aufderheide

Re: Two HLSL questions - 09/05/05 12:29

No, using functions is not any slower, in fact it is partly why HLSL is so useful..it was designed with code reuse in mind.

You cant convert implicitly to larger variable type.. like float 2 to float 3 etc.
Always start with larger variable types and convert down.. or make a 'dummy' float4 out of a float 2 like .. float4 fake(f2.x,f2.y,0,0)

I'm sure you can get more expert advice on this subject elsewhere.
© 2024 lite-C Forums