prepare billboard
This commit is contained in:
parent
9b5157594f
commit
3393a90127
BIN
doc/BlenderGizmo/Move.png
Normal file
BIN
doc/BlenderGizmo/Move.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 141 KiB |
BIN
doc/BlenderGizmo/Rotate.png
Normal file
BIN
doc/BlenderGizmo/Rotate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 215 KiB |
BIN
doc/BlenderGizmo/Scale.png
Normal file
BIN
doc/BlenderGizmo/Scale.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 180 KiB |
@ -41,6 +41,8 @@ SET(SHADERGEN_COMMON_FILES ${STD_MTL_HEADER_PATH}/UBOCommon.h
|
||||
common/MFCommon.h
|
||||
common/MFGetPosition.h
|
||||
common/MFGetNormal.h
|
||||
common/MFCamera.h
|
||||
common/MFBillboard.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP("Common" FILES ${SHADERGEN_COMMON_FILES})
|
||||
|
38
src/ShaderGen/common/MFBillboard.h
Normal file
38
src/ShaderGen/common/MFBillboard.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include"MFCamera.h"
|
||||
#include<hgl/graph/mtl/ShaderBuffer.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
namespace func
|
||||
{
|
||||
//@link http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/
|
||||
|
||||
constexpr const ShaderBufferSource SBS_Billboard=
|
||||
{
|
||||
"BillboardData",
|
||||
"billboard",
|
||||
|
||||
R"(
|
||||
vec2 center;
|
||||
vec2 size;
|
||||
)"
|
||||
};
|
||||
|
||||
constexpr const char *GetBillboardPosition=R"(
|
||||
vec4 GetBillboardPosition()
|
||||
{
|
||||
mat4 cv_mat =GetCameraViewMatrix();
|
||||
|
||||
vec3 cv_right =GetViewRight(cv_mat);
|
||||
vec3 cv_up =GetViewUp(cv_mat);
|
||||
|
||||
vec3 pos =GetPosition3D();
|
||||
|
||||
vec3(billboard.center,0)+
|
||||
cv_right*pos.x*billboard.size.x+
|
||||
cv_up *pos.y*billboard.size.y;
|
||||
}
|
||||
)";
|
||||
}//namespace func
|
||||
STD_MTL_NAMESPACE_END
|
31
src/ShaderGen/common/MFCamera.h
Normal file
31
src/ShaderGen/common/MFCamera.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
namespace func
|
||||
{
|
||||
//@link http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/
|
||||
|
||||
constexpr const char *GetCameraViewMatrix=R"(
|
||||
mat4 GetCameraViewMatrix()
|
||||
{
|
||||
return camera.view*GetLocalToWorld();
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char *GetCameraViewRight=R"(
|
||||
vec3 GetViewRight(mat4 cv)
|
||||
{
|
||||
return vec3(cv[0][0],cv[1][0],cv[2][0]);
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char *GetCameraViewUp=R"(
|
||||
vec3 GetViewUp(mat4 cv)
|
||||
{
|
||||
return vec3(cv[0][1],cv[1][1],cv[2][1]);
|
||||
}
|
||||
)";
|
||||
}//namespace func
|
||||
STD_MTL_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user