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 7585853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:16:39+00:00 2026-05-30T19:16:39+00:00

I have a Texture2D readily available; I have an apparently-working shader texture sampler and

  • 0

I have a Texture2D readily available; I have an apparently-working shader texture sampler and shader texture variable that I can put that Texture2D in.

The only problem is, I don’t know how to load a texture into a shader in DirectX11 – And either Google is being unhelpful, or it’s just my inability to construct good search terms.

What I need: Code that will take a Texture2D and load it into a shader. A link on how to do so, for example.

Anyway, here’s my shader code:

cbuffer CameraSet : register(b0)
{
    float4x4 ViewProj ;
} ;
cbuffer MeshSet : register(b1)
{
    float4x4 World ;
    texture2D Texture ;
    SamplerState MeshTextureSampler
    {
        Filter = MIN_MAG_MIP_LINEAR ;
        AddressU = WRAP ;
        AddressV = WRAP ;
    } ;
} ;


struct VShaderOutput
{
    float4 WorldPosition : POSITION ;
    float4 ScreenPosition : SV_POSITION ;
    float2 UV : TEXCOORD;
} ;

VShaderOutput VShader( float4 position : POSITION, float2 uv : TEXCOORD )
{
    VShaderOutput r ;

    r.WorldPosition = mul( position, World ) ;
    r.ScreenPosition = mul( r.WorldPosition, ViewProj ) ;
    r.UV.x = abs( uv.x ) ;
    r.UV.y = abs( uv.y ) ;

    return r ;
}


struct PShaderOutput
{
    float4 SV_Target : SV_TARGET ;
    float SV_Depth : SV_DEPTH ;
};

PShaderOutput PShader( VShaderOutput input )
{
    PShaderOutput r ;

    r.SV_Depth = input.ScreenPosition.z;

    r.SV_Target = Texture.Sample( MeshTextureSampler, input.UV ) ;

    return r ;
}

Thanks.

  • 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-30T19:16:40+00:00Added an answer on May 30, 2026 at 7:16 pm

    …If it’s

    context.PixelShader.SetShaderResource(TextureShaderResourceView, 0);

    I think I just answered my own question. But why does an array value of ‘0’ work?

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

Sidebar

Related Questions

I want to accomplish a GLSL Shader, that can texture and color my vertex
I have a very basic texture map problem in GL on iPhone, and I'm
I have got problem with my shaders. I am trying to put textures and
I have a texture which has only 1 channel as it's a grayscale image.
I have one texture that has some portions which are transparent transparent I want
I have a vertex shader with attributes that may or may not be set
I have a radial blur shader in GLSL, which takes a texture, applies a
I have a vertex shader in which I do a texture lookup to determine
I have an array of tiles that are of the type Texture2D and want
I'm trying to render a colored cube after rendering other cubes that have textures.

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.