Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:15:51+00:00 2026-05-26T22:15:51+00:00

im starting learning some Shader manipulation witg C++ and HLSL, im using D3DXCompileShaderFromFile to

  • 0

im starting learning some Shader manipulation witg C++ and HLSL, im using D3DXCompileShaderFromFile to do some tests while am learning

i was able to compile and run some VertexShader and PixelShader, send some Attributes, like
float, float2, float3, float4 , float4x4 , to set worldMatrix ,Color information ,etc, here is some example:

void CShader::SetVector4(char name[], Vect4f vect)
{
D3DXVECTOR4 v(vect.x,vect.y,vect.z,vect.w);
D3DXHANDLE h = m_pConstantTable->GetConstantByName(NULL, name);
m_pConstantTable->SetVector(m_pDevice, h, &v);
}

almost the same thing with SetMatrix and SetFloat, ex:

myShader->SetVector4("Diffuse",Vect4f(1.0f,0.0f,0.0f,1.0f) );

but i ran to a problem doing so Basic Light shader

how can i send a texture to my “pixelShader”? in my ps is declared as “sampler2d” type, so im not sure what to use to send this information

float4  Diffuse;
float4  Ambient;
sampler2D baseMap;


float4 Main(float3 L: TEXCOORD0, float3 N: TEXCOORD1,float2 texCoord: TEXCOORD2 ) : COLOR
{
  float facingRatio =  dot(L, N);
  float4 tex = tex2D( baseMap, texCoord );

  return tex * Diffuse * facingRatio + Ambient * tex;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:15:52+00:00Added an answer on May 26, 2026 at 10:15 pm

    Don’t you just need to bind the texture as normal? Not familiar with the directx api as I normally use Ogre, but quick look up suggests SetTexture(sampler, texture) is the way to go, with sampler being the sampler register.
    You can explicitly say which register the texture uses in the shader if you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been learning python for some time now. While starting this learning python
I'm starting learning rails, and having some troubles on configure cucumber to run my
I'm learning Mockito. Before starting to use mock objects I had some Unit tests
I'm interested in learning some python, and thought Pylons would be a good starting
I am starting to I am learning scala, and trying to build some simple
I've just starting learning jQuery and AJAX. I'm able to load a local page
I am starting with google maps. just learning. while ago, it was working. now
I'm starting to learning some asp.net so I'm looking for an application to develop
I'm starting out learning some ASP.Net programming and I'm going to be making a
I'm starting to do some web development and I was learning about forms and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.