mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
depth offset
This commit is contained in:
parent
472e203d67
commit
81fbb04fbf
@ -22,6 +22,8 @@ void gl_transform_to_viewport(GLContext *c,GLVertex *v)
|
||||
+ c->viewport.trans.v[1] );
|
||||
v->zp.z= (int) ( v->pc.v[2] * winv * c->viewport.scale.v[2]
|
||||
+ c->viewport.trans.v[2] );
|
||||
v->zp.z += (c->zbias << (ZB_Z_BITS - 8));
|
||||
|
||||
/* color */
|
||||
v->zp.r=(int)(v->color.v[0] * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN)
|
||||
+ ZB_POINT_RED_MIN);
|
||||
|
@ -56,6 +56,7 @@ void glInit(GLContext *c, ZBuffer *zbuffer)
|
||||
|
||||
/* depth test */
|
||||
c->depth_test = 0;
|
||||
c->zbias = 0;
|
||||
}
|
||||
|
||||
void glClose(GLContext *c)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "directionalLight.h"
|
||||
#include "spotlight.h"
|
||||
#include "depthWriteAttrib.h"
|
||||
#include "depthOffsetAttrib.h"
|
||||
#include "colorWriteAttrib.h"
|
||||
#include "alphaTestAttrib.h"
|
||||
#include "depthTestAttrib.h"
|
||||
@ -98,8 +99,9 @@ reset() {
|
||||
_inv_state_mask.clear_bit(ColorAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(ColorScaleAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(CullFaceAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(RescaleNormalAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(DepthOffsetAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(RenderModeAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(RescaleNormalAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(TextureAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(MaterialAttrib::get_class_slot());
|
||||
_inv_state_mask.clear_bit(LightAttrib::get_class_slot());
|
||||
@ -1464,6 +1466,14 @@ set_state_and_transform(const RenderState *target,
|
||||
_state_mask.set_bit(cull_face_slot);
|
||||
}
|
||||
|
||||
int depth_offset_slot = DepthOffsetAttrib::get_class_slot();
|
||||
if (_target_rs->get_attrib(depth_offset_slot) != _state_rs->get_attrib(depth_offset_slot) ||
|
||||
!_state_mask.get_bit(depth_offset_slot)) {
|
||||
//PStatTimer timer(_draw_set_state_depth_offset_pcollector);
|
||||
do_issue_depth_offset();
|
||||
_state_mask.set_bit(depth_offset_slot);
|
||||
}
|
||||
|
||||
int rescale_normal_slot = RescaleNormalAttrib::get_class_slot();
|
||||
if (_target_rs->get_attrib(rescale_normal_slot) != _state_rs->get_attrib(rescale_normal_slot) ||
|
||||
!_state_mask.get_bit(rescale_normal_slot)) {
|
||||
@ -2008,6 +2018,18 @@ do_issue_rescale_normal() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyGraphicsStateGuardian::do_issue_depth_offset
|
||||
// Access: Protected
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void TinyGraphicsStateGuardian::
|
||||
do_issue_depth_offset() {
|
||||
const DepthOffsetAttrib *target_depth_offset = DCAST(DepthOffsetAttrib, _target_rs->get_attrib_def(DepthOffsetAttrib::get_class_slot()));
|
||||
int offset = target_depth_offset->get_offset();
|
||||
_c->zbias = offset;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyGraphicsStateGuardian::do_issue_cull_face
|
||||
// Access: Protected
|
||||
|
@ -99,6 +99,7 @@ private:
|
||||
void do_issue_render_mode();
|
||||
void do_issue_cull_face();
|
||||
void do_issue_rescale_normal();
|
||||
void do_issue_depth_offset();
|
||||
void do_issue_material();
|
||||
void do_issue_texture();
|
||||
void do_issue_scissor();
|
||||
|
@ -9,7 +9,7 @@ void gl_eval_viewport(GLContext * c) {
|
||||
float xmin = v->xmin + v->xsize * s->left;
|
||||
float ysize = v->ysize * (s->top - s->bottom);
|
||||
float ymin = v->ymin + v->ysize * (1.0f - s->top);
|
||||
float zsize = (1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
|
||||
float zsize = (float)(1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
|
||||
|
||||
v->trans.v[0] = ((xsize - 0.5f) / 2.0f) + xmin;
|
||||
v->trans.v[1] = ((ysize - 0.5f) / 2.0f) + ymin;
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include "zfeatures.h"
|
||||
#include "pbitops.h"
|
||||
|
||||
typedef unsigned short ZPOINT;
|
||||
#define ZB_Z_BITS 16
|
||||
#define ZB_POINT_Z_FRAC_BITS 14
|
||||
typedef unsigned int ZPOINT;
|
||||
#define ZB_Z_BITS 20
|
||||
#define ZB_POINT_Z_FRAC_BITS 10 // These must add to < 32.
|
||||
|
||||
/* The number of fractional bits below the S and T texture coords.
|
||||
The more we have, the more precise the texel calculation will be
|
||||
|
@ -183,6 +183,7 @@ typedef struct GLContext {
|
||||
|
||||
/* depth test */
|
||||
int depth_test;
|
||||
int zbias;
|
||||
|
||||
/* specular buffer. could probably be shared between contexts,
|
||||
but that wouldn't be 100% thread safe */
|
||||
|
Loading…
x
Reference in New Issue
Block a user