specular OK in BlinnPhongDirectionLight sample. but direction error.
This commit is contained in:
parent
f56928d734
commit
5347ac7091
@ -23,7 +23,8 @@ Length 16
|
|||||||
Stage Fragment
|
Stage Fragment
|
||||||
Code
|
Code
|
||||||
{
|
{
|
||||||
vec4 Color;
|
vec3 Color;
|
||||||
|
float Gloss;
|
||||||
}
|
}
|
||||||
|
|
||||||
#VertexInput
|
#VertexInput
|
||||||
@ -32,6 +33,7 @@ vec3 Normal
|
|||||||
#Vertex
|
#Vertex
|
||||||
Output
|
Output
|
||||||
{
|
{
|
||||||
|
vec4 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +44,8 @@ Code
|
|||||||
HandoverMI();
|
HandoverMI();
|
||||||
|
|
||||||
Output.Normal=Normal;
|
Output.Normal=Normal;
|
||||||
gl_Position=GetPosition3D();
|
Output.Position=GetPosition3D();
|
||||||
|
gl_Position=Output.Position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,18 +74,18 @@ Code
|
|||||||
vec3 direct_color =diffuse*sun.color.rgb*mi.Color.rgb;
|
vec3 direct_color =diffuse*sun.color.rgb*mi.Color.rgb;
|
||||||
|
|
||||||
// #ifndef HAVE_SPECULAR
|
// #ifndef HAVE_SPECULAR
|
||||||
FragColor=vec4(direct_color,1.0);
|
// FragColor=vec4(direct_color,1.0);
|
||||||
// #else
|
// #else
|
||||||
// //归一代视角方向
|
//归一代视角方向
|
||||||
// vec3 view_direction =normalize(camera.pos-world_position);
|
vec3 view_direction =normalize(camera.pos-Input.Position.xyz);
|
||||||
//
|
|
||||||
// //世界坐标下的反射光方向
|
//世界坐标下的反射光方向
|
||||||
// vec3 reflect_direction =normalize(reflect(-world_light_direction,world_normal));
|
vec3 reflect_direction =normalize(reflect(-world_light_direction,world_normal));
|
||||||
//
|
|
||||||
// //高光
|
//高光
|
||||||
// vec3 specular =sun.specular*pow(saturate(dot(reflect_direction,view_direction)),gloss);
|
float specular =pow(clamp(dot(reflect_direction,view_direction),0.0,1.0),mi.Gloss);
|
||||||
//
|
|
||||||
// FragColor=vec4(direct_color+specular,1.0);
|
FragColor =vec4(direct_color+vec3(specular),1.0);
|
||||||
// #endif//HAVE_SPECULAR
|
// #endif//HAVE_SPECULAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ static Color4f white_color(1,1,1,1);
|
|||||||
|
|
||||||
static mtl::blinnphong::SunLight sun_light=
|
static mtl::blinnphong::SunLight sun_light=
|
||||||
{
|
{
|
||||||
Vector4f(1,1,1,0),
|
Vector4f(0,0,1,0),
|
||||||
Vector4f(1,0,0,1)
|
Vector4f(1,0,0,1)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,7 +86,13 @@ private:
|
|||||||
mtl_sun_light->BindUBO(DescriptorSetType::Global,"sun",ubo_sun);
|
mtl_sun_light->BindUBO(DescriptorSetType::Global,"sun",ubo_sun);
|
||||||
mtl_sun_light->Update();
|
mtl_sun_light->Update();
|
||||||
|
|
||||||
mi_sphere=db->CreateMaterialInstance(mtl_sun_light,nullptr,&white_color);
|
float mi_data[4]=
|
||||||
|
{
|
||||||
|
1,0,0, //color
|
||||||
|
4 //gloss
|
||||||
|
};
|
||||||
|
|
||||||
|
mi_sphere=db->CreateMaterialInstance(mtl_sun_light,nullptr,&mi_data);
|
||||||
if(!mi_sphere)return(false);
|
if(!mi_sphere)return(false);
|
||||||
|
|
||||||
p_sphere=CreatePipeline(mtl_sun_light,InlinePipeline::Solid3D,Prim::Triangles);
|
p_sphere=CreatePipeline(mtl_sun_light,InlinePipeline::Solid3D,Prim::Triangles);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user