I´ve seen that if SHADER_EXTERNAL_DEBUG is set, then the parallax shader is loaded from parallax.psh, but I can´t find this file.
Anyone knows where it is?
Looking for parallax.psh
Re: Looking for parallax.psh
There isn't on in 1.8. Presumable you would set the item if you wished to supply the file yourself. Otherwise, there is a shader embedded in the code so the #define is not needed.
Re: Looking for parallax.psh
I found this "improved" version of the Irrlicht parallax shader in HLSL with quite a nice work-through (in Chinese) on the theory.
Ref: Kaneko, T., et al. "Detailed Shape Representation with Parallax Mapping"
(edited)
Solution (translated from Madarin):
1: For Swimming Effect, the methods used in Irrlicth yes, right Height above and then multiplied by a Normal.z.
From Irrlicth CD3D8ParallaxMapRenderer.cpp
In fact, the off = h * h_scale * n.z
2: The low angle problem, as occurs in the Irrlicht shader, one must not simply multiply by tan (a), in this way we can avoid the problem of the low angle; Another method is to set a limit angle when the angle exceeds the allowable limit, the limit is used instead of the angle. That is tan (a) a maximum value.
Improved Parallax Map
Improvement is by looping to find the actual intersection.
Improved Parallax Pixel shader in HLSL:
Seems to be based on this technique which looks interesting http://http.developer.nvidia.com/GPUGem ... ter08.html
Ref: Kaneko, T., et al. "Detailed Shape Representation with Parallax Mapping"
(edited)
Solution (translated from Madarin):
1: For Swimming Effect, the methods used in Irrlicth yes, right Height above and then multiplied by a Normal.z.
From Irrlicth CD3D8ParallaxMapRenderer.cpp
In fact, the off = h * h_scale * n.z
2: The low angle problem, as occurs in the Irrlicht shader, one must not simply multiply by tan (a), in this way we can avoid the problem of the low angle; Another method is to set a limit angle when the angle exceeds the allowable limit, the limit is used instead of the angle. That is tan (a) a maximum value.
Improved Parallax Map
Improvement is by looping to find the actual intersection.
Improved Parallax Pixel shader in HLSL:
Code: Select all
//////////////////////////////////////////////////////////////////////////////////////////////
// Improved Parallax Pixel Shader HLSL
sampler NrmSampler : register(ps, s1);
sampler DtlSampler : register(ps, s0);
struct PS_INPUT
{
float3 litVec : COLOR0;
float3 eyeVec : COLOR1;
float2 tex0 : TEXCOORD0;
};
static const float scale = 0.04; // Height map scaling
static const float n = 10; // Trace count
static const float fHStep = 1.0/n;
static const float fMaxUVStep = 2.0*scale; // Camera angle limitation
float4 main(PS_INPUT input) : COLOR0
{
// Get the normal and height
float3 eyeVec = normalize(input.eyeVec);
float2 uvStep = eyeVec.xy*min(scale/eyeVec.z, fMaxUVStep); // Init as the most offet
float4 uv = {input.tex0+uvStep, 0.0, 0.0}; // The start uv
float4 nrm = tex2D(NrmSampler, uv.xy);
float curHDiff = 0.0;
float preHDiff = 1.0;
if(nrm.a < 1.0) // if nrm.a == 1.0, it's the highest point
{
float curH = 1.0;
float preH = 1.0-nrm.a;
uvStep *= fHStep;
[loop] for(int i=0; i<n; ++i)
{
if(nrm.a >= curH)
{
curHDiff = nrm.a-curH;
break;
}
preHDiff = curH-nrm.a;
curH -= fHStep;
uv.xy -= uvStep;
nrm = tex2Dlod(NrmSampler, uv);
}
}
uv.xy += curHDiff/(preHDiff+curHDiff)*uvStep; // Interpolate
nrm = tex2D(NrmSampler, uv.xy);
// Do the parallax mapping
nrm.xyz = normalize(float3(nrm.xyz*2-1));
float3 litVec = normalize(input.litVec);
float4 output = saturate(dot(litVec.xyz, nrm.xyz))*tex2D(DtlSampler, uv.xy);
return output;
};