11.15
This commit is contained in:
@@ -12,7 +12,7 @@ const char* TestPixelShader::getName(void) const
|
||||
return "test";
|
||||
}
|
||||
|
||||
void TestPixelShader::prepare(const RenderPipe* pipe, SetInputAttributeFunc setInputAttributeFunc)
|
||||
void TestPixelShader::prepare(const RenderPipe* pipe, davinci::MaterialConstPtr material)
|
||||
{
|
||||
m_pipe = pipe;
|
||||
}
|
||||
@@ -68,76 +68,41 @@ void TestPixelShader::process(const VertexDesc& veretexDesc, const float32_t* pi
|
||||
|
||||
fVector3 u_lightColor = fVector3(1.0, 1.0, 1.0);
|
||||
|
||||
fVector4 u_textureColor = shader::texture2D(*m_pipe, "material:pbr:base_color_texture", *v_uv, fVector4::WHITE);
|
||||
fVector4 u_textureColor;// = shader::texture2D(*m_pipe, "material:pbr:base_color_texture", *v_uv, fVector4::WHITE);
|
||||
|
||||
const fVector4 defaultNormal = fVector4(0.5f, 0.5f, 1.0f, 1.0f);
|
||||
fVector4 u_normalColor = shader::texture2D(*m_pipe, "material:pbr:normal_texture", *v_uv, defaultNormal);
|
||||
fVector4 u_normalColor;// = shader::texture2D(*m_pipe, "material:pbr:normal_texture", *v_uv, defaultNormal);
|
||||
|
||||
//----------------
|
||||
fVector3 vN = fVector3::UNIT_Z;// u_normalColor.xyz() * 2.0f - fVector3::ONE;
|
||||
fVector3 vN = u_normalColor.xyz() * 2.0f - fVector3::ONE;
|
||||
vN.normalise();
|
||||
|
||||
//vector vL = normalize(v_toLight);
|
||||
fVector3 vL =vLight;
|
||||
vL.normalise();
|
||||
|
||||
//vector vV = normalize(v_toCamera);
|
||||
fVector3 vV = *v_toCamera;
|
||||
vV.normalise();
|
||||
|
||||
float ndotl = vL.dotProduct(vN);
|
||||
|
||||
//vector vR = 2 * dot(vL, vN)*vN - vL;
|
||||
fVector3 vR = 2 * ndotl * vN - vL;
|
||||
|
||||
float rdotv = vR.dotProduct(vV);
|
||||
|
||||
//vector vH = normalize(vL + vV);
|
||||
//fVector3 vH = vL + vV;
|
||||
//vH.normalise();
|
||||
|
||||
|
||||
//color colAmbient = u_ambientColor*u_matColor;
|
||||
fVector3 colAmbient = u_ambientColor * u_matColor;
|
||||
|
||||
//float ndotl = max(dot(vN, vL), 0);
|
||||
//float32_t ndotl = std::max(vN.dotProduct(vL), 0.0f);
|
||||
//color colDiff = ndotl * u_matColor * u_lightColor;
|
||||
fVector3 colDiff = shader::max(0.0f, ndotl) * u_matColor* u_lightColor;
|
||||
|
||||
|
||||
//float32_t spec = std::max(vR.dotProduct(vV), 0.0f)*1.0;
|
||||
//color colSpec = step(0, ndotl) * pow(spec, 64) * u_matColor * u_lightColor;
|
||||
|
||||
const float _m = 1.0f;
|
||||
float spec = shader::step(0.0f, ndotl) * shader::pow(shader::max(0.0f, rdotv), 32.f);
|
||||
fVector3 colSpec = spec * u_matColor* u_lightColor;
|
||||
|
||||
//color final = colAmbient + colDiff + colSpec;
|
||||
fVector3 final = fVector3::BLACK;// (colAmbient + colDiff + colSpec)* u_textureColor.xyz();
|
||||
|
||||
final += colAmbient;
|
||||
fVector3 final = fVector3::BLACK;
|
||||
//final += colAmbient;
|
||||
final += colDiff;
|
||||
final += colSpec;
|
||||
|
||||
final *= u_textureColor.xyz();
|
||||
//fVector3 final = (colAmbient +colDiff +colSpec)*u_textureColor.xyz();
|
||||
//final += colSpec;
|
||||
//final *= u_textureColor.xyz();
|
||||
|
||||
//final = u_normalColor.xyz();
|
||||
//color = fVector4::RED;
|
||||
color = fVector4(final.saturate(), 1.0f);// fVector4::RED;
|
||||
}
|
||||
|
||||
const char* SolidColorPixelShader::getName(void) const
|
||||
{
|
||||
return "solid";
|
||||
}
|
||||
|
||||
void SolidColorPixelShader::prepare(const RenderPipe* pipe, SetInputAttributeFunc setInputAttributeFunc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SolidColorPixelShader::process(const VertexDesc& veretexDesc, const float32_t* pixelData, fVector4& color)
|
||||
{
|
||||
color = fVector4::RED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user