|
@@ -33,13 +33,15 @@ class Parallax extends hxsl.Shader {
|
|
if( maxLayers == 0 )
|
|
if( maxLayers == 0 )
|
|
calculatedUV += viewNS.xy * heightMap.get(calculatedUV) * amount;
|
|
calculatedUV += viewNS.xy * heightMap.get(calculatedUV) * amount;
|
|
else {
|
|
else {
|
|
- var numLayers = mix(float(maxLayers), float(minLayers), abs(viewNS.z));
|
|
|
|
|
|
+ var numLayers = int(mix(float(maxLayers), float(minLayers), abs(viewNS.z)));
|
|
var layerDepth = 1 / numLayers;
|
|
var layerDepth = 1 / numLayers;
|
|
var curLayerDepth = 0.;
|
|
var curLayerDepth = 0.;
|
|
var delta = (viewNS.xy / viewNS.z) * amount / numLayers;
|
|
var delta = (viewNS.xy / viewNS.z) * amount / numLayers;
|
|
var curUV = calculatedUV;
|
|
var curUV = calculatedUV;
|
|
var curDepth = heightMap.getLod(curUV,0.);
|
|
var curDepth = heightMap.getLod(curUV,0.);
|
|
- while( curLayerDepth < curDepth ) {
|
|
|
|
|
|
+ for (i in 0...numLayers) {
|
|
|
|
+ if (curLayerDepth < curDepth)
|
|
|
|
+ break;
|
|
curUV += delta;
|
|
curUV += delta;
|
|
curDepth = heightMap.getLod(curUV,0.);
|
|
curDepth = heightMap.getLod(curUV,0.);
|
|
curLayerDepth += layerDepth;
|
|
curLayerDepth += layerDepth;
|