Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Shaders - HLSL - SampleLevel()

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Steven De Bock   Members   

482
Like
0Likes
Like

Posted 18 April 2013 - 01:52 PM

Could someone help me figure out why a float3 is being returned in the following HLSL line?

float3 v = gRandomTex.SampleLevel(gTriLinearSam, u, 0);
 

Now, gRandomTex, gTriLinearSam and u are defined as follows:

Texture1D gRandomTex;
SamplerState gTriLinearSam
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = WRAP;
    AddressV = WRAP;
}
float u = 1.0f; //Actually it is not a constant, but just for the example, I set it to 1.0f
 

 

 

 

 


Twitter: @StevenDeBo


#2 siri   Members   

283
Like
1Likes
Like

Posted 18 April 2013 - 01:59 PM

It's been a while since I used HLSL properly( so far back that SM2 was the thing ) so I may be completely off here. But you're asking it for a float3, no ? Does it fail if you switch it to float4 on the return ?

 

Also, according to MSDN it should return in the format of the texture -- specified by DXGI_FORMAT. What format is the texture in ? ( http://msdn.microsoft.com/en-gb/library/windows/desktop/bb509699(v=vs.85).aspx )

 

( I'm probably way off and completely wrong. But thought I'd post on the off-chance it's helpful. )



#3 Steven De Bock   Members   

482
Like
0Likes
Like

Posted 18 April 2013 - 02:22 PM

Thanks, I should have read the msdn more closely:

 

The Format of the texture is indeed defined as DXGI_FORMAT_R32G32B32A32_FLOAT.

I was too much focused on the fact that it was a Texture1D and ignored to see that an element could as well have multiple dimensions...

 

As for the float3 vs float4: I only need a random x, y and z component for v, so no use for a float4 variable.


Twitter: @StevenDeBo





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.