tgjones / HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released
Other
561 stars 97 forks source link

Support for texture2D.Sample in vs2017? #185

Closed DaedalusGame closed 3 years ago

DaedalusGame commented 4 years ago

My current version is 1.1.300 and texture2D appears to be missing the newer Sample methods, because HLSLTools fills my errorlog with HLSL0031 Type 'texture' does not have a method 'Sample(SamplerState, float2)'. I tried to suppress the error but to no effect, is there any other solution to this?

DaedalusGame commented 4 years ago

For now I've disabled Error Reporting in Options > Text Editor > HLSL > Advanced

tgjones commented 4 years ago

HLSL Tools does support the newer Sample methods on objects like Texture2D. Can you paste the declaration of your texture here, as well as your call to Sample?

DaedalusGame commented 4 years ago

Ah right, i probably should've posted that to begin with.

Declaration (https://github.com/DaedalusGame/RogueTower/blob/90f11c539c1c68209f4d4458447e9e7b0cac9614/RogueTower/Content/effects.fx#L15):

texture2D texture_main : register(t0);
texture2D texture_map : register(t1);
SamplerState sampler_main;

Sample (https://github.com/DaedalusGame/RogueTower/blob/90f11c539c1c68209f4d4458447e9e7b0cac9614/RogueTower/Content/effects.fx#L78):

float4 color = texture_main.Sample(sampler_main, input.TextureCoordinates) * input.Color;

I'll admit that I'm rather amateurish at writing HLSL, and I think monogame's HLSL might have some aberrations (internally they can compile shaders to both HLSL and GLSL).

tgjones commented 3 years ago

Oops, I'm really sorry for the long delay! I think this could be fixed by changing your texture declarations to use Texture2D instead of texture2D. If I recall correctly, MonoGame's effect compiler does allow that. Please let me know if that doesn't fix the issue.