Removed some HLSL intrinsic from .sc shaders in favor of GLSL. Fixed varying.def parsing.

This commit is contained in:
bkaradzic 2013-04-05 20:40:50 -07:00
parent 789552fd34
commit 84bfec136a
4 changed files with 15 additions and 10 deletions

View file

@ -181,8 +181,8 @@ vec4 luma(vec4 _rgba)
vec3 conSatBri(vec3 _rgb, vec3 _csb)
{
vec3 rgb = _rgb * _csb.z;
rgb = lerp(luma(rgb), rgb, _csb.y);
rgb = lerp(vec3_splat(0.5), rgb, _csb.x);
rgb = mix(luma(rgb), rgb, _csb.y);
rgb = mix(vec3_splat(0.5), rgb, _csb.x);
return rgb;
}
@ -219,7 +219,7 @@ vec3 blendOverlay(vec3 _base, vec3 _blend)
{
vec3 lt = 2.0 * _base * _blend;
vec3 gte = 1.0 - 2.0 * (1.0 - _base) * (1.0 - _blend);
return lerp(lt, gte, step(vec3_splat(0.5), _base) );
return mix(lt, gte, step(vec3_splat(0.5), _base) );
}
vec4 blendOverlay(vec4 _base, vec4 _blend)
@ -239,7 +239,7 @@ vec4 packFloatToRgba(float _value)
{
const vec4 shift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);
const vec4 mask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
vec4 comp = frac(_value * shift);
vec4 comp = fract(_value * shift);
comp -= comp.xxyz * mask;
return comp;
}
@ -252,7 +252,7 @@ float unpackRgbaToFloat(vec4 _rgba)
float random(vec2 _uv)
{
return frac(sin(dot(_uv.xy, vec2(12.9898, 78.233) ) ) * 43758.5453);
return fract(sin(dot(_uv.xy, vec2(12.9898, 78.233) ) ) * 43758.5453);
}
#endif // __SHADERLIB_SH__

View file

@ -11,6 +11,8 @@
#if BGFX_SHADER_LANGUAGE_HLSL
# define dFdx(_x) ddx(_x)
# define dFdy(_y) ddy(-_y)
# define inversesqrt(_x) rsqrt(_x)
# define fract(_x) frac(_x)
# if BGFX_SHADER_LANGUAGE_HLSL > 3
struct BgfxSampler2D
@ -114,8 +116,8 @@ bvec3 lessThan(vec3 _a, vec3 _b) { return _a < _b; }
bvec4 lessThan(vec4 _a, vec4 _b) { return _a < _b; }
bvec2 lessThanEqual(vec2 _a, vec2 _b) { return _a <= _b; }
bvec2 lessThanEqual(vec3 _a, vec3 _b) { return _a <= _b; }
bvec2 lessThanEqual(vec4 _a, vec4 _b) { return _a <= _b; }
bvec3 lessThanEqual(vec3 _a, vec3 _b) { return _a <= _b; }
bvec4 lessThanEqual(vec4 _a, vec4 _b) { return _a <= _b; }
bvec2 greaterThan(vec2 _a, vec2 _b) { return _a > _b; }
bvec3 greaterThan(vec3 _a, vec3 _b) { return _a > _b; }
@ -145,8 +147,6 @@ vec4 mod(vec4 _a, vec4 _b) { return _a - _b * floor(_a / _b); }
#elif BGFX_SHADER_LANGUAGE_GLSL
# define atan2(_x, _y) atan(_x, _y)
# define frac(_x) fract(_x)
# define lerp(_x, _y, _t) mix(_x, _y, _t)
# define mul(_a, _b) ( (_a) * (_b) )
# define saturate(_x) clamp(_x, 0.0, 1.0)
# define SAMPLER2D(_name, _reg) uniform sampler2D _name
@ -160,6 +160,11 @@ vec3 instMul(vec3 _vec, mat3 _mtx) { return mul(_vec, _mtx); }
vec3 instMul(mat3 _mtx, vec3 _vec) { return mul(_mtx, _vec); }
vec4 instMul(vec4 _vec, mat4 _mtx) { return mul(_vec, _mtx); }
vec4 instMul(mat4 _mtx, vec4 _vec) { return mul(_mtx, _vec); }
float rcp(float _a) { return 1.0/_a; }
vec2 rcp(vec2 _a) { return vec2(1.0)/_a; }
vec3 rcp(vec3 _a) { return vec3(1.0)/_a; }
vec4 rcp(vec4 _a) { return vec4(1.0)/_a; }
#endif // BGFX_SHADER_LANGUAGE_HLSL
uniform vec4 u_viewRect;

Binary file not shown.

View file

@ -1499,7 +1499,7 @@ int main(int _argc, const char* _argv[])
varyingMap.insert(std::make_pair(var.m_name, var) );
}
parse = bx::strnl(parse);
parse = bx::strnl(eol);
}
}