Hi folks!
Today i’m trying write some vertex shader and it must fetch the diffmap for vertex displacement
i’m copy the libSolid.hlsl and doing some fixes into it.
the first of all i try to find how dx9 doing fetch from textures in vertex shader and find this tut
http.developer.nvidia.com/GPUGem … ter18.html
i find this
float4 main(float4 position : POSITION,
  uniform sampler2D tex0,
so i decide just add sampler2D sDiffMap : COLOR for VS in parameters
void VS(float4 iPos : POSITION,
    float3 iNormal : NORMAL,
    float2 iTexCoord : TEXCOORD0,
    sampler2D sDiffMap : COLOR,
    #if defined(LIGHTMAP) || defined(AO)
        float2 iTexCoord2 : TEXCOORD1,
    #endif
    #ifdef NORMALMAP
        float4 iTangent : TANGENT,
    #endif
    #ifdef SKINNED
        float4 iBlendWeights : BLENDWEIGHT,
        int4 iBlendIndices : BLENDINDICES,
    #endif
vertex displace
    float4x3 modelMatrix = iModelMatrix;
    float3 dcolor = tex2Dlod (sDiffMap, float4(iTexCoord.xy, 0,0));
    float displace = (dcolor.r * cChannelFactor.r + dcolor.g * cChannelFactor.g + dcolor.b * cChannelFactor.b );
    float3 dispPos = iPos.xyz + iNormal.xyz * displace * cDisplacement;   
     
    float3 worldPos = mul(dispPos, modelMatrix);
    oPos = GetClipPos(worldPos);
    oNormal = GetWorldNormal(modelMatrix);  
    oWorldPos = float4(worldPos, GetDepth(oPos));also i’m add some uniforms for vs and ps in uniforms.hlsl
uniform float4 cChannelFactor;
uniform float cDisplacement;
uniform float2 cRange;
but i’m got an editor’s crush then trying to open my scene, with object that have this custom draw tech.
i guess there not so simple way to doing fetch in dx9 ?
 
         
         
        


 
         
        