diff --git a/CMCore b/CMCore index 03443255..006eaa3f 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit 03443255541b4dde822f147fb7b817b3811cd8b9 +Subproject commit 006eaa3f1c0b46e70c01a672d919e8740cb8f2bb diff --git a/ShaderLibrary/Std3D/BlinnPhongPureColor.mtl b/ShaderLibrary/Std3D/BlinnPhongPureColor.mtl index fa8f2412..facd8714 100644 --- a/ShaderLibrary/Std3D/BlinnPhongPureColor.mtl +++ b/ShaderLibrary/Std3D/BlinnPhongPureColor.mtl @@ -1,17 +1,12 @@ -#Material -Name Blinn-phong shading model only color -Base Std3D +#Material +Name BlinnPhong+HalfLambert shading model only color +Reference https://zhuanlan.zhihu.com/p/442023993 +Base Std3D -Require LocalToWorld,Camera,Sun +Require LocalToWorld,Camera,Sun #MaterialInstance -Code -{ - float Diffuse; - float Intensity; -} - #VertexInput vec3 Normal @@ -30,4 +25,40 @@ Code } #Fragment +Output +{ + vec4 FragColor; +} +Code +{ + void main() + { + //将法线归一化 + vec3 world_normal =normalize(Input.Normal); + + //对世界坐标下的灯光方法归一化 + vec3 world_light_direction =normalize(sun.direction); + + //点乘法线和光照 + vec3 diffuse =0.5*dot(world_light_direction,world_normal)+0.5; + + //直接光颜色 + vec3 direct_color =sun.diffuse*diffuse*sun.color; + + #ifndef HAVE_SPECULAR + FragColor=vec4(direct_color,1.0); + #else + //归一代视角方向 + vec3 view_direction =normalize(camera.pos-world_position); + + //世界坐标下的反射光方向 + vec3 reflect_direction =normalize(reflect(-world_light_direction,world_normal)); + + //高光 + vec3 specular =sun.specular*pow(saturate(dot(reflect_direction,view_direction)),gloss); + + FragColor=vec4(direct_color+specular,1.0); + #endif//HAVE_SPECULAR + } +} diff --git a/ShaderLibrary/Std3D/MetricCellsGrid.mtl b/ShaderLibrary/Std3D/MetricCellsGrid.mtl index 882078dc..f748b2d5 100644 --- a/ShaderLibrary/Std3D/MetricCellsGrid.mtl +++ b/ShaderLibrary/Std3D/MetricCellsGrid.mtl @@ -9,6 +9,7 @@ vec2 TexCoord #MaterialInstance Length 120 Stage Fragment + Code { vec4 x_color; @@ -31,6 +32,7 @@ Output { vec2 TexCoord } + Code { void main() @@ -72,12 +74,13 @@ Code // ======= AXES float xb = step(abs(x) - mi.axis_line_width, 0.0); float yb = step(abs(y) - mi.axis_line_width, 0.0); + color.rgb = mix(color.rgb, mi.x_axis_color.rgb, (xb)); color.rgb = mix(color.rgb, mi.y_axis_color.rgb, (yb)); // ======= CENTER float cb = length(vec2(x,y))-mi.center_radius; - color.rgb = mix(color.rgb, mi.center_color.rgb, cb>0.0?0.0:smoothstep(0,edge*256.0,abs(cb))); + color.rgb = mix(color.rgb, mi.center_color.rgb, cb>0.0?0.0:smoothstep(0,edge*mi.scale.y,abs(cb))); FragColor=color; } diff --git a/example/Gizmo/BlenderAxis.cpp b/example/Gizmo/BlenderAxis.cpp new file mode 100644 index 00000000..c5a53c39 --- /dev/null +++ b/example/Gizmo/BlenderAxis.cpp @@ -0,0 +1,30 @@ +// Blender axis +/** +* 0 1 2 3 4 5 6 7 +* 0+---------->>>> X +* 1| +* 2| +* 3| +--+ +* 4| +--+ +* 5| +* 6V +* 7V +* +* 坐标轴参考Blender设计 +* +* 单方向坐标轴长度为8 +* 最终箭头长度为2 +* +* 负责2D平移的方块尺寸为1,位置在3-4 +* +*/ + +/** + * 缩放工具 + */ +class GizmoScale +{ +public: + + +};//class GizmoScale diff --git a/example/Gizmo/CMakeLists.txt b/example/Gizmo/CMakeLists.txt index 6839ad18..9f0ef8ae 100644 --- a/example/Gizmo/CMakeLists.txt +++ b/example/Gizmo/CMakeLists.txt @@ -14,4 +14,6 @@ CreateProject(01_PlaneGrid3D PlaneGrid3D.cpp) CreateProject(02_RayPicking RayPicking.cpp) CreateProject(03_MetricCellsGrid MetricCellsGrid.cpp) +CreateProject(04_Gizmo3DMove Gizmo3DMove.cpp) + #CreateProject(03_BlenderAxis BlenderAxis.cpp) diff --git a/example/Gizmo/Gizmo3DMove.cpp b/example/Gizmo/Gizmo3DMove.cpp new file mode 100644 index 00000000..e69de29b diff --git a/example/Gizmo/MetricCellsGrid.cpp b/example/Gizmo/MetricCellsGrid.cpp index 79a26727..ef76a8e6 100644 --- a/example/Gizmo/MetricCellsGrid.cpp +++ b/example/Gizmo/MetricCellsGrid.cpp @@ -31,7 +31,7 @@ struct MetricCellsGridData constexpr const size_t MCG_SIZE=sizeof(MetricCellsGridData); -constexpr const float PLANE_SIZE=512; +constexpr const float PLANE_SIZE=1024; class TestApp:public SceneAppFramework { diff --git a/inc/hgl/graph/mtl/Material3DCreateConfig.h b/inc/hgl/graph/mtl/Material3DCreateConfig.h index e22256b1..b3fc6195 100644 --- a/inc/hgl/graph/mtl/Material3DCreateConfig.h +++ b/inc/hgl/graph/mtl/Material3DCreateConfig.h @@ -53,10 +53,6 @@ public: MaterialCreateInfo *CreateVertexColor3D(const Material3DCreateConfig *); MaterialCreateInfo *CreateVertexLuminance3D(const Material3DCreateConfig *); -//MaterialCreateInfo *CreatePureColor2D(const Material2DCreateConfig *); -//MaterialCreateInfo *CreatePureTexture2D(const Material2DCreateConfig *); -//MaterialCreateInfo *CreateRectTexture2D(Material2DCreateConfig *); -//MaterialCreateInfo *CreateRectTexture2DArray(Material2DCreateConfig *); /** * 从文件加载材质 diff --git a/src/ShaderGen/2d/M_RectTexture2DArray.cpp b/src/ShaderGen/2d/M_RectTexture2DArray.cpp index e82ce6dd..9bdc335b 100644 --- a/src/ShaderGen/2d/M_RectTexture2DArray.cpp +++ b/src/ShaderGen/2d/M_RectTexture2DArray.cpp @@ -95,7 +95,6 @@ void main() return(true); } - };//class MaterialRectTexture2D:public Std2DMaterial }//namespace