Jump to content
  • Advertisement
Sign in to follow this  

Problem with Vertex Texture Fetch - HLSL

This topic is 3619 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, i was trying to use vertex texture lookups for my program. But of course this doesn't work. There is no error but the function "float4 height = tex2Dlod(dispSamp,float4(UV.xy ,0,0));" always (but only in vertex shader, in pixel shader it works perfectly) returns the value float4(0,0,0,1). I'm rendering some stuff into the vertextexture (Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default) and then pass it to the vertex shader. This question here is very similar but also these answers couldn't help me. So maybe You can help me. PS: The same Shader works perfect in nVidia's FX Composer with a texture from file. Are there maybe some problems with my device-settings? PSS: I use the Default Pool. But here it is said, that the texture must be created in the scratch pool. But it isn't possible for me to create it in scratch pool. [Edited by - gogogigo on January 20, 2009 12:21:07 PM]

Share this post

Link to post
Share on other sites
How are you binding the texture to your device? Are you directly calling SetTexture on the device, or are you setting it on the Effect?

Also, you will probably want to run your app with the debug runtimes active, to see if you can get any information from that.

Share this post

Link to post
Share on other sites
Thanx for response!
I'm using (VisualBasic).NET.

To create the texture:

dispmap = New Texture(device, (-field.rect.X + field.rect.Width + 1) * 50, (-field.rect.Y + field.rect.Height + 1) * 50, _
0, Microsoft.DirectX.Direct3D.Usage.RenderTarget, Format.A32B32G32R32F, _

// (-field.rect.X + field.rect.Width + 1)*50 is 550

HLSL Code for texture:

texture dispTex;
sampler dispSamp = sampler_state
Texture = <dispTex>;
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
//... and to sample:
float4 height = tex2Dlod(dispSamp,float4(UV.xy ,0,0));

To set the texture in program:

dispTexHandle = effect.GetParameter(dispTexHandle, "dispTex")
effect.SetValue(dispTexHandle , dispmap)

I don't know yet how to debug the shader in Visual Basic...
I wonder about, that the Shader works in FXComposer and mainly about that "tex2Dlod(dispS..." works in pixelshader in my app.
I have the feeling that there's a problem with my device or sth like that.?

To Create my Device i use this code:

Dim present As PresentParameters = New PresentParameters

present.BackBufferCount = 1
present.BackBufferFormat = Format.A8R8G8B8
present.SwapEffect = SwapEffect.Discard
present.AutoDepthStencilFormat = DepthFormat.D24X8
present.EnableAutoDepthStencil = True
present.Windowed = False
present.BackBufferWidth = 1280
present.BackBufferHeight = 1024

device = New Direct3D.Device(0, DeviceType.Hardware, targetform, CreateFlags.SoftwareVertexProcessing, present)

device.RenderState.ZBufferEnable = True
device.RenderState.ZBufferWriteEnable = True
device.RenderState.SourceBlend = Blend.SourceAlpha
device.RenderState.DestinationBlend = Blend.SourceAlpha
device.SamplerState(0).MaxAnisotropy = 8
device.SamplerState(0).MinFilter = TextureFilter.Anisotropic
device.SamplerState(0).MagFilter = TextureFilter.Anisotropic

By the way: is it really necessary to use the scratch pool?

[Edited by - gogogigo on January 20, 2009 2:18:44 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!