Sign in to follow this  
skyemaidstone

3D Converting my DX9 HLSL to DX10/11

Recommended Posts

Just a quick one (hopefully). I'm trying to use hardward PCF that's apparently built in later than dx9 so I'm updating some old shaders.

I was using:

distanceStoredInDepthMap = tex2D(ShadowMapSamplerHQ, lightSamplePos);    
                shadowCondition =  distanceStoredInDepthMap  <= (realDistanceToLight);    

                float lit = float(ShadowMapHQ.SampleCmpLevelZero(cmpSampler, lightSamplePos, realDistanceToLight));
                

distanceStoredInDepthMap = tex2D(ShadowMapSamplerHQ, lightSamplePos);	
shadowCondition =  distanceStoredInDepthMap  <= (realDistanceToLight);	

I'm trying update it to use the comparison method on the Texture2D object;

float lit = float(ShadowMapHQ.SampleCmpLevelZero(cmpSampler, lightSamplePos, realDistanceToLight));

But it's just returning 0. I've just left SamplerComparisonState as defaults.

Sorry if this is a dumb question.

Share this post


Link to post
Share on other sites

So essentially what i'm doing is correct with SampleCmpLevelZero is it? It compares whatever is at that texture coordinate with the float I pass in parameter 3 (using whatever samplercomparisionstate is have set)? Or have I misunderstood something else?

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Partner Spotlight

  • Forum Statistics

    • Total Topics
      627665
    • Total Posts
      2978529
  • Similar Content

    • By Kurupted Playz
      Hey, I'm looking for some people that can help me with a game that I'm making that is a 3d platformer.
      I mostly need someone for character design and animation,  I can do some coding but if you can do coding as well you're still welcome because I'm still not the greatest at coding just yet.
      if you need to contact me add me on discord @ Kurupted#1206
       
    • By Jcyshadow97
      Hi,guys.I m working on a Fantasy RPG.Currently i m work alone on the project.I really need someone can make UI stuff.If someone can handle it please feel free to contact me on email: 270514974@libero.it.
      Thank you guys and sorry for my english.
       
       



    • By scragglypoo
      Hi,
      How can I emulate triple buffering in Direct3d9, so I can have vsync with high fps.
      DWM does it in window mode; why has nobody done it in fullscreen mode?
    • By Scanmaster_k
      Our player character is progressing nicely. This is a render in Marmoset. 
    • By bandages
      I'm working in an old application (DX9-based) where I don't have access to the C code, but I can write any (model 3.0) HLSL shaders I want.  I'm trying to mess with some cube mapping concepts.  I've gotten to the point where I'm rendering a cube map of the scene to a cross cube that I can plug directly into ATI cubemapgen for filtering, which is already easier than trying to make one in Blender, so I'm pretty happy so far.  But I would like to do my own filtering and lookups for two purposes: one, to effortlessly render directly to sphere map (which is the out-of-the-box environment mapping for the renderer I'm using), and two, to try out dynamic cube mapping so I can play with something approaching real-time reflections.  Also, eventually, I'd like to do realish-time angular Gaussian on the cube map so that I can get a good feel for how to map specular roughness values to Gaussian-blurred environment miplevels.  It's hard to get a feel for that when it requires processing through several independent, slow applications.
       
      Unfortunately, the math to do lookups and filtering is challenging, and I can't find anybody else online doing the same thing.  It seems to me that I'm going to need a world-vector-to-cube-cross-UV function for the lookup, then a cube-cross-UV-to-world-vector function for the filtering (so I can point sample four or more adjacent texels, then interpolate on the basis of angular distance rather than UV distance.)
       
      First, I'm wondering if there's any kind of matrix that I can use here to transform vector to cube-cross map, rather than doing a bunch of conditionals on the basis of which cube face I want to read.  This seems like maybe it would be possible?  But I'm not really sure, it's kind of a weird transformation.  Right now, my cube cross is a 3:4 portrait, going top/front/bottom/back from top to bottom, because that's what cubemapgen wants to see.  I suppose I could make another texture from it with a different orientation, if that would mean I could skip a bunch of conditionals on every lookup.
       
      Second, it seems like once I have the face, I could just use something like my rendering matrix for that face to transform a vector to UV space,  but I'm not sure that I could use the inverse of that matrix to get a vector from an arbitrary cube texel for filtering, because it involves a projection matrix-- I know those are kind of special, but I'm still wrapping my head around a lot of these concepts.  I'm not even sure I could make the inverse very easily; I can grab an inverseProj from the engine, but I'm writing to projM._11_22 to set the FOV to 90, and I'm not sure how that would affect the inverse.
       
      Really interested in any kind of discussion on techniques involved, as well as any free resources.  I'd like to solve the problem, but it's much more important to me to use the problem as a way to learn more.
  • Popular Now