Texture with alpha channel
2 posters
Texture with alpha channel
I have an RGBA texture I'd like to show as a shadow under an object. I've followed the advice in tutorial 4 and changed the texture channel's "Map To" attribute to "Value". Still, the texture doesn't show up. When I change the "translucency" slider from 0 to say 0.5, it starts showing, but doesn't look like expected.
Does anyone have further hints where to look at?
Thanks
Matt
Does anyone have further hints where to look at?
Thanks
Matt
Re: Texture with alpha channel
I think I did because that was the second issue you mentioned in the video tutorial, but I'll double-check once I'm back home.
Thanks,
Matt
Thanks,
Matt
Re: Texture with alpha channel
I just checked. Two side is On, Map To is Value... nothing rendered. Only if I start to increase the translucency slider, something shows up...
Other ideas?
Thanks
Matt
Other ideas?
Thanks
Matt
Re: Texture with alpha channel
Anyway for shadows what I would do is this, since basically what you are doing by having a plane with a alpha texture is faking planar shadow...
- Code:
void shadowmatrix( float *_m, vec4 *_n, vec4 *_lpos )
{
float dp = ( _n->x * _lpos->x ) +
( _n->y * _lpos->y ) +
( _n->z * _lpos->z ) +
( _n->w * _lpos->w );
_m[ 0 ] = dp - ( _lpos->x * _n->x );
_m[ 4 ] = 0.0f - ( _lpos->x * _n->y );
_m[ 8 ] = 0.0f - ( _lpos->x * _n->z );
_m[ 12 ] = 0.0f - ( _lpos->x * _n->w );
_m[ 1 ] = 0.0f - ( _lpos->y * _n->x );
_m[ 5 ] = dp - ( _lpos->y * _n->y );
_m[ 9 ] = 0.0f - ( _lpos->y * _n->z );
_m[ 13 ] = 0.0f - ( _lpos->y * _n->w );
_m[ 2 ] = 0.0f - ( _lpos->z * _n->x );
_m[ 6 ] = 0.0f - ( _lpos->z * _n->y );
_m[ 10 ] = dp - ( _lpos->z * _n->z );
_m[ 14 ] = 0.0f - ( _lpos->z * _n->w );
_m[ 3 ] = 0.0f - ( _lpos->w * _n->x );
_m[ 7 ] = 0.0f - ( _lpos->w * _n->y );
_m[ 11 ] = 0.0f - ( _lpos->w * _n->z );
_m[ 15 ] = dp - ( _lpos->w * _n->w );
}
...
...
// Create the shadow matrix...
if( !m[ 0 ] )
{
// Plane Normal (up Z axis) & Light Position
vec4 n, lpos;
// Initialize the plane normal vector
n.x = n.y = n.w = 0.0f;
n.z = 1.0f;
// Setup the light position
lpos.x = 22.0f;
lpos.y = -11.0f;
lpos.z = 22.0f;
lpos.w = 0.0f;
// Create the shadow matrix.
shadowmatrix( m, &n, &lpos );
}
...
...
// Render the object tweaking the modelview matrix
// to squash the object into the plane (ground)
glPushMatrix();
{
// Multiply our current modelview matrix with the
// shadow matrix.
glMultMatrixf( &m[ 0 ] );
// Black color for the shadows.
glColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
// Enable polygon offset to avoid zfighting
glEnable( GL_POLYGON_OFFSET_FILL );
// If you are using the simulator theses values
// will do.
//glPolygonOffset( -2.0f, 2.0f );
// Setup the polygon offset, on the device polygon
// offset require extreme value in order to work
// correctly. Try setting the optimal combination
// proper to your application. The following value
// will work but are not optimized...
glPolygonOffset( -10.0f, -10.0f );
// Render your shadow objects without material
// sio2ObjectRender( _SIO2object, sio2->_SIO2camera, 0 );
// Reset the object states
sio2ObjectReset();
// Disable polygon offset
glDisable( GL_POLYGON_OFFSET_FILL );
}
glPopMatrix();
Re: Texture with alpha channel
This would mean re-rendering the whole object for shadows, which is a no-go here. But I'll probably use that for another project, thanks.
Any other hints?
Matt
Any other hints?
Matt
Re: Texture with alpha channel
I don't think its no big deal for 1 object... anyway send me the .blend that cause problem I can check it out... just a question are you enabling polygon offset or? another question... how did you fix the OGG loading problem?
Re: Texture with alpha channel
For me, it's a big deal since I'm scratching the performance limits. Even worse, I was testing with an iPod 2G all the time and now I learned that it's noticably slower on the iPhone (30 FPS vs. 20 FPS). Bad luck.
I'm not enabling polygon offset. I'll try to create a short testbed for the problem and send it over to you. Thanks for caring.
Regarding the OGG loading problem, I simply went over to Apples native AudioQueue API. Since it seems to decode pages in hardware it's a lot faster.
Best,
Matt
I'm not enabling polygon offset. I'll try to create a short testbed for the problem and send it over to you. Thanks for caring.
Regarding the OGG loading problem, I simply went over to Apples native AudioQueue API. Since it seems to decode pages in hardware it's a lot faster.
Best,
Matt
Re: Texture with alpha channel
It seems like I won't make it to pack a sample until I need to get this finished. One particular problem I have recognized is that the Z-buffer is filled even if a texel is transparent. Shouldn't that be the case? The other possiblity would be that the material isn't considered to be transparent at all, but that shoulnd't be the case with Map To = Value, right? At least I see that SIO2 recognizes the faces as transparent, because they only get rendered with SIO2_RENDER_ALPHA_OBJECT on.
Best,
Matt
Best,
Matt
Re: Texture with alpha channel
Ok, sorry, I got it. My fault... When I debugged through the sorting, I recognized that I used wrong positions.
Best,
Matt
Best,
Matt
Similar topics
» Alpha Texture Problem
» Real quick - plane with alpha texture
» Draw font to texture or render to texture possible?
» Fast Gaussian blur
» alpha blending manually
» Real quick - plane with alpha texture
» Draw font to texture or render to texture possible?
» Fast Gaussian blur
» alpha blending manually
Permissions in this forum:
You cannot reply to topics in this forum