Jump to content

  • Log In with Google      Sign In   
  • Create Account


michaelmk86

Member Since 14 Feb 2012
Offline Last Active Aug 08 2013 06:16 PM

Topics I've Started

Texture Arrays

28 May 2013 - 08:31 AM

it is possible to pass to the shader a Texture Array and at the same time 2 or more Textures that are not in an arrey?

I have try like that but it doesn't work

deviceContext->PSSetShaderResources(0, 1, &ShadowMapTexture);//contains 1 Texture
deviceContext->PSSetShaderResources(1, 1, &ReflectionTexture);//contains 1 Texture
deviceContext->PSSetShaderResources(2, 4, modelTexturesArray);//contains 4 Textures



//HLSL
Texture2D Textures[6] : register(t0);

Textures[0].Sample(.....// it is the ShadowMapTexture
Textures[1].Sample(.....// it is the ReflectionTexture
Textures[2].Sample(.....// it is the modelTexturesArray 0
Textures[3].Sample(.....// it is the modelTexturesArray 1
Textures[4].Sample(.....// it is the modelTexturesArray 2
Textures[5].Sample(.....// it is the modelTexturesArray 3
...

the weird thing is that if i do the following it works but not with the hadowMapTexture and ReflectionTexture at the same time

deviceContext->PSSetShaderResources(0, 1, &ShadowMapTexture);//contains 1 Texture
deviceContext->PSSetShaderResources(1, 4, modelTexturesArray);//contains 4 Textures



//HLSL
Texture2D Textures[5] : register(t0);

Textures[0].Sample(.....// it is the ShadowMapTexture
Textures[1].Sample(.....// it is the modelTexturesArray 0
Textures[2].Sample(.....// it is the modelTexturesArray 1
Textures[3].Sample(.....// it is the modelTexturesArray 2
Textures[4].Sample(.....// it is the modelTexturesArray 3
...

Convert std::string to WCHAR ?

20 May 2013 - 05:18 PM

^ title


How to get multiple textures on a model in DX11?

20 May 2013 - 12:47 PM

Hi, how to get multiple textures on a model without the need to use separate draw calls for each texture that is on the model?

 

SamplerState SampleTypeWrap  : register(s0);

Texture2D mTexture0 : register(t0);
Texture2D mTexture1 : register(t1);
Texture2D mTexture2 : register(t2);


struct PixelInputType
{
    float4 position : SV_POSITION;
    float2 tex : TEXCOORD0; // contains texture coordinates for all 3 Textures that are on the model
    float3 normal : NORMAL;
};

float4 PPixelShader(PixelInputType input) : SV_TARGET
{

    //need to fine how to determine what Textures(mTexture0, mTexture1, mTexture2) corresponds to the input.tex (that contains all the texture coordinates)

    float4 output;

    //if(this pixel have Texture mTexture0)
    	output = mTexture0.Sample(SampleTypeWrap, input.tex);
    //if(this pixel have Texture mTexture1)
    	output = mTexture1.Sample(SampleTypeWrap, input.tex);
    //if(this pixel have Texture mTexture2)
    	output = mTexture2.Sample(SampleTypeWrap, input.tex);

    return output;
}

 

I hope i make myself clear.smile.png


DX11 Instancing question

05 May 2013 - 01:38 PM

Hi everyone,

Based on this tutorial: http://www.rastertek.com/dx11tut37.html

can someone point to me some hints on how to pass the rotation of the Instances to the shader?


soft shadows problem

21 March 2013 - 04:25 AM


Hi,
I am trying to implement the Brute-Force Implementation ( as described here http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html) but the shadows do not display correctly (wrong place, orientation), although the shadows appear to look with antialiasing.

 

the code

 float3 offset_lookup(sampler map, float4 loc, float2 offset){
        float2 texmapscale = float2(1/xResolution.x, 1/xResolution.y);
        return tex2Dproj(map, float4(loc.xy + offset * texmapscale * loc.w, loc.z, loc.w));
 }

 float ShadowedArea(int subFrustum, float diffuseLightingFactor, float distanceFromCamera, SSceneVertexToPixel PSIn)
 {
        float depthStoredInShadowMap;
        float sum = 0;
        float x, y;

        for (y = -1.5; y <= 1.5; y += 1.0)
            for (x = -1.5; x <= 1.5; x += 1.0)
                sum += offset_lookup(xShadowMapSubFrustum0_Sampler, PSIn.Pos2DAsSeenByLight[subFrustum], float2(x, y));
        depthStoredInShadowMap = sum / 16.0;
        
        float realDistance = PSIn.Pos2DAsSeenByLight[subFrustum].z/xMaxDepth[subFrustum];

        if((realDistance - 1.0f/100.0f) <= depthStoredInShadowMap){
            //light can see
        }else{
            if(dot(PSIn.Normal, xLightDirection) >= 0){
                //covered by object, and light can't see
                float shadowFade = ShadowFade(diffuseLightingFactor, distanceFromCamera);
                if(shadowFade < diffuseLightingFactor)
                    diffuseLightingFactor = shadowFade;
            }else{
                //not facing the light, and light can't see
                diffuseLightingFactor = 0;
            }
        }
    return diffuseLightingFactor;
 }

 

when I reverse the sign to the loc.y, and divide the (loc.xy + offset * texmapscale * loc.w) with /2.0 + 0.5 the shadows display correctly, but with not antialiasing for some reason(they look pixelated, the same way they were before the soft shadows implementation)

 float3 offset_lookup(sampler map, float4 loc, float2 offset){
        float2 texmapscale = float2(1/xResolution.x, 1/xResolution.y);
        loc.y = -loc.y; 
        return tex2Dproj(map, float4((loc.xy + offset * texmapscale * loc.w)/2.0 + 0.5, loc.z, loc.w));
 }

 


PARTNERS