FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Texture with alpha channel

2 posters

Go down

Texture with alpha channel Empty Texture with alpha channel

Post  matt Tue Nov 25, 2008 6:39 pm

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

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  sio2interactive Tue Nov 25, 2008 8:46 pm

Have you tried to render it with "Two Side" ON?
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  matt Wed Nov 26, 2008 3:18 am

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

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  matt Wed Nov 26, 2008 5:34 pm

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

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  sio2interactive Wed Nov 26, 2008 5:50 pm

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();

sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  matt Wed Nov 26, 2008 5:55 pm

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

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  sio2interactive Wed Nov 26, 2008 6:06 pm

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?
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  matt Wed Nov 26, 2008 6:16 pm

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

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  matt Thu Nov 27, 2008 9:13 am

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

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  matt Thu Nov 27, 2008 11:04 am

Ok, sorry, I got it. My fault... When I debugged through the sorting, I recognized that I used wrong positions.

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Texture with alpha channel Empty Re: Texture with alpha channel

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum