Jump to content
  • Advertisement
Sign in to follow this  
jbarcz1

Vertex texturing in HLSL

This topic is 5031 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

Hello. I'm trying to add vertex texturing to an HLSL vertex shader, and it seems that HLSL wasn't designed to support this, since none of the tex** intrinsics will compile with the vs_3_0 profile. I'm trying to get around it by using inline assembly, but that doesn't seem to work they way you'd expect it to either. I'm using only raw HLSL shaders built with D3DXCompileShaderFromFile, no effects. I've tried the following:

void main()
{
    asm
    {
        vs_3_0
        dcl_position o0.xyzw
        dcl_position v0
        dcl_2d s0
        texldl o0, v0, s0
    }
   
}
But FXC says: error X3064: object literals are not allowed inside functions compilation failed; no code produced Can anybody point me to some documentation on this? Is there a way to implement vertex texturing using an HLSL shader or do I have to write the entire thing in assembly?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jbarcz1

Hello. I'm trying to add vertex texturing to an HLSL vertex shader, and it seems that HLSL wasn't designed to support this, since none of the tex** intrinsics will compile with the vs_3_0 profile. I'm trying to get around it by using inline assembly, but that doesn't seem to work they way you'd expect it to either. I'm using only raw HLSL shaders built with D3DXCompileShaderFromFile, no effects.

I've tried the following:



void main()
{
asm
{
vs_3_0
dcl_position o0.xyzw
dcl_position v0
dcl_2d s0
texldl o0, v0, s0
}

}


But FXC says:

error X3064: object literals are not allowed inside functions

compilation failed; no code produced

Can anybody point me to some documentation on this? Is there a way to implement vertex texturing using an HLSL shader or do I have to write the entire thing in assembly?


There is no inline assembly in HLSL.

Vertex Texture loads are done the same as they are done in pixel shaders, but you can't use any of the gradient versions obvoisly. Just use tex2Dlod

Share this post


Link to post
Share on other sites
According to the DX SDK docs (from the October '04 update), tex2Dlod is only supported in ps_3_0, not vs. So unless they've patched the compiler in the december update, they don't have vertex texturing support.

JB

Share this post


Link to post
Share on other sites

Never mind, a quick test reveals that the docs simply lie:


struct VertexInput
{
float4 position : POSITION;
float4 coords : TEXCOORD0;
};
struct VertexOutput
{
float4 position : POSITION;
float4 color: COLOR0;
};

uniform sampler2D samp;

VertexOutput main(VertexInput vi)
{
VertexOutput vo;
vo.position = vi.position;
vo.color = tex2Dlod(samp, vi.coords);
return vo;
}

// Parameters:
//
// sampler2D samp;
//
//
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// samp s0 1
//

vs_3_0
dcl_position v0
dcl_texcoord v1
dcl_2d s0
dcl_position o0
dcl_color o1
texldl o1, v1, s0
mov o0, v0

// approximately 2 instruction slots used (1 texture, 1 arithmetic)

I really wish MS would document this stuff better.

Share this post


Link to post
Share on other sites
Quote:


I really wish MS would document this stuff better.


Unfortantly there is such a vast amount of material, and very few people who know graphics well enough to really document well. Ah maybe, one day I'll get off my lazy ass and actually write a book on HLSL ;)


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!