mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-13 13:20:07 +00:00
also initialize near/far for depth shader in TinyRenderer
This commit is contained in:
parent
9d78809a55
commit
8c6d4a4c85
@ -38,6 +38,9 @@ struct DepthShader : public IShader {
|
||||
m_lightModelView(lightModelView),
|
||||
m_lightDistance(lightDistance)
|
||||
{
|
||||
m_nearPlane = m_projectionMat.col(3)[2]/(m_projectionMat.col(2)[2]-1);
|
||||
m_farPlane = m_projectionMat.col(3)[2]/(m_projectionMat.col(2)[2]+1);
|
||||
|
||||
m_invModelMat = m_modelMat.invert_transpose();
|
||||
}
|
||||
virtual Vec4f vertex(int iface, int nthvert) {
|
||||
@ -580,7 +583,6 @@ void TinyRenderer::renderObjectDepth(TinyRenderObjectData& renderData)
|
||||
Vec3f localScaling(renderData.m_localScaling[0],renderData.m_localScaling[1],renderData.m_localScaling[2]);
|
||||
|
||||
DepthShader shader(model, lightModelViewMatrix, lightViewProjectionMatrix,renderData.m_modelMatrix, localScaling, light_distance);
|
||||
shader.m_farPlane=1e30;
|
||||
for (int i=0; i<model->nfaces(); i++)
|
||||
{
|
||||
for (int j=0; j<3; j++) {
|
||||
|
@ -180,10 +180,11 @@ void triangle(mat<4,3,float> &clipc, IShader &shader, TGAImage &image, float *zb
|
||||
zbuffer[P.x+P.y*image.get_width()]>frag_depth)
|
||||
continue;
|
||||
bool discard = shader.fragment(bc_clip, color);
|
||||
if (frag_depth<-shader.m_farPlane)
|
||||
discard=true;
|
||||
if (frag_depth>-shader.m_nearPlane)
|
||||
discard=true;
|
||||
if (frag_depth<-shader.m_farPlane)
|
||||
discard=true;
|
||||
if (frag_depth>-shader.m_nearPlane)
|
||||
discard=true;
|
||||
|
||||
if (!discard) {
|
||||
zbuffer[P.x+P.y*image.get_width()] = frag_depth;
|
||||
if (segmentationMaskBuffer)
|
||||
|
Loading…
Reference in New Issue
Block a user