Added noise function declarations

This commit is contained in:
Christophe Riccio 2011-04-26 15:46:22 +01:00
parent 00169d0cde
commit dbca36a123
2 changed files with 65 additions and 5 deletions

View File

@ -18,13 +18,13 @@
namespace glm
{
template <typename T, template<typename> class vecType>
inline vecType<T> permute(vecType<T> const & x)
GLM_FUNC_QUALIFIER vecType<T> permute(vecType<T> const & x)
{
return mod(((x * T(34)) + T(1)) * x, T(289));
}
template <typename T, template<typename> class vecType>
inline vecType<T> taylorInvSqrt(vecType<T> const & r)
GLM_FUNC_QUALIFIER vecType<T> taylorInvSqrt(vecType<T> const & r)
{
return T(1.79284291400159) - T(0.85373472095314) * r;
}
@ -32,8 +32,56 @@ namespace glm
namespace gtx{
namespace noise
{
template <typename T>
GLM_FUNC_QUALIFIER T cnoise(glm::detail::tvec2<T> const & v)
{
return T(0);
}
template <typename T>
GLM_FUNC_QUALIFIER T cnoise(glm::detail::tvec3<T> const & v)
{
return T(0);
}
template <typename T>
GLM_FUNC_QUALIFIER T cnoise(glm::detail::tvec4<T> const & v)
{
return T(0);
}
template <typename T>
GLM_FUNC_QUALIFIER T pnoise
(
glm::detail::tvec2<T> const & p,
glm::detail::tvec2<T> const & rep
)
{
return T(0);
}
template <typename T>
GLM_FUNC_QUALIFIER T pnoise
(
glm::detail::tvec3<T> const & p,
glm::detail::tvec3<T> const & rep
)
{
return T(0);
}
template <typename T>
GLM_FUNC_QUALIFIER T pnoise
(
glm::detail::tvec4<T> const & p,
glm::detail::tvec4<T> const & rep
)
{
return T(0);
}
template <typename T>
inline T snoise(glm::detail::tvec2<T> const & v)
GLM_FUNC_QUALIFIER T snoise(glm::detail::tvec2<T> const & v)
{
detail::tvec4<T> const C = detail::tvec4<T>(
T( 0.211324865405187), // (3.0 - sqrt(3.0)) / 6.0
@ -90,7 +138,7 @@ namespace noise
}
template <typename T>
inline T snoise(glm::detail::tvec3<T> const & v)
GLM_FUNC_QUALIFIER T snoise(glm::detail::tvec3<T> const & v)
{
detail::tvec2<T> const C = detail::tvec2<T>(1.0 / 6.0, 1.0 / 3.0);
detail::tvec4<T> const D = detail::tvec4<T>(0.0, 0.5, 1.0, 2.0);
@ -176,6 +224,12 @@ namespace noise
dot(p3, x3)));
}
template <typename T>
GLM_FUNC_QUALIFIER T snoise(glm::detail::tvec4<T> const & v)
{
return T(0);
}
}//namespace noise
}//namespace gtx
}//namespace glm

View File

@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-21
// Updated : 2011-04-21
// Updated : 2011-04-26
// Licence : This source is under MIT licence
// File : test/gtx/noise.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -14,4 +14,10 @@
int main()
{
float ValueSNoise2D = glm::snoise(glm::vec2(0.5f));
float ValueSNoise3D = glm::snoise(glm::vec3(0.5f));
float ValueSNoise4D = glm::snoise(glm::vec4(0.5f));
float ValueCNoise2D = glm::cnoise(glm::vec2(0.5f));
float ValueCNoise3D = glm::cnoise(glm::vec3(0.5f));
float ValueCNoise4D = glm::cnoise(glm::vec4(0.5f));
}