Jump to content


no texture wrapping with samplelevel in hlsl?


3 replies to this topic

#1 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2718 posts

Posted 28 November 2012 - 10:55 PM

error X4014: cannot have gradient operations inside loops with divergent flow control

finally got my loops to not unroll in the shader and now ive got a problem that it only lets me use samplelevel, and sample level doesnt seem to work with texture wrap over!!!! is this right?
Posted Image

Im trying to raytrace some fractal noise, is there any solution to my problem?
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#2 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2718 posts

Posted 29 November 2012 - 01:24 AM

sorta... got it working, but its going really slow, im float modulating by 1.0f in the texture coordinate, theres got to be a better way than that tho... this should be realtime.
Posted Image
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 5305 posts
  • LocationBellevue, WA

Posted 29 November 2012 - 02:00 AM

SampleLevel should work fine with wrapping; you just have to pass in a sampler state that sets AddressU and AddressV to Wrap.

You're not getting proper mipmapping this way, of course. You would need to do the texture lookup outside the loop in order for it to work. Regular texturing implicitly uses the UV derivatives to select the mip level. It seems you cannot take derivatives inside a loop or branch...that kinda sucks, but it's understandable. The hardware does derivatives by comparing values across nearby pixels, but if those nearby pixels might take a different execution path through the shader due to loops or branches, it doesn't have anything to compare to.

If you can calculate the UV derivatives yourself, you can use them with SampleGrad to get mipmapping back.
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2718 posts

Posted 29 November 2012 - 07:17 AM

hahahaha oh silly me, i forgot to set the sampler!!!! XD got me... thanks reedbeta.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users