Talk:Orange Shader        

Help!

When I apply shader/orange to the ground plane in a simple scene, it turns out grey (because of ambient light in the scene). If I remove the ambient light, it's totally white. No errors in the log, and no errors when I start up. All files are where they need to be, and I've copied bit for bit the tutorial here. What's up? Using Dagon 1.2 Final SDK.

Solution

I solved this myself... I have no prior experience with shaders in Ogre, or with shaders in general. So I apologize for my unnecessary cry for help above. Though, if others run into this problem, I will show how I solved it.

The .material file outlined in this article showed this:

fragment_program shader/orangeFP cg
{
    source orangeshader.cg
    entry_point main_fp
    profiles ps_1_1
}

material shader/orange
{
    technique
    {
        pass
        {
            fragment_program_ref shader/orangeFP
            {
            }
        }
    }
}


As I said before when asking for help, it didn't show up orange, it showed up bright white with no lighting, or with some ambient light for example, it had proper lighting. But it wasn't doing what it was intended to do. So, after trying many things I got it working by adding a texture_unit. The fixed code looks like this:

fragment_program shader/orangeFP cg
{
    source orangeshader.cg
    entry_point main_fp
    profiles ps_1_1
}

material shader/orange
{
    technique
    {
        pass
        {
            fragment_program_ref shader/orangeFP
            {
            }
                        
                        texture_unit
                        {
                        }
        }
    }
}


Now as I said, I'm not experienced with shaders in Ogre. So I cannot explain why this works, and the original code doesn't. I'll take a wild stab at it, and say that without the texture_unit, well... There is not actual texture_unit to apply. So the shader may work, and compile fine, but without the actual texture_unit there it's not going to see it as an actual texture. Like I said- a wild stab. It would be very appreciated if someone could clear this up for me, as well as others who may be new to this area of design/development.


it works so i'm posting your changes

hey, thanks for your posts. it's a silly thing to put but it makes it all work. I don't understand why this works but not the original. In any case, since yours works, i'm posting yours in the main article.

thanks!
Ramy