Shader source truncated

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Shader source truncated

Post by machineonpointer »

I tried to print the shader generated by RTSS, but for some material only part of the source is printed.

eg:

Code: Select all

#version 100
precision highp float;
precision highp int;
void FFP_Add(in vec3 vIn0, in vec3 vIn1, out vec3 vOut)
{
vOut = vIn0 + vIn1;
}
void FFP_Assign(in vec4 vIn, out vec4 vOut)
{
vOut = vIn;
}
void FFP_Lerp(in vec4 vIn0, in vec4 vIn1, in float T, out vec4 vOut)
{
vOut = mix(vIn0, vIn1, T);
}
void FFP_Modulate(in vec4 vIn0, in vec4 vIn1, out vec4 vOut)
{
vOut = vIn0 * vIn1;
}
void FFP_SampleTexture(in sampler2D s, in vec2 f, out vec4 t)
{
t = texture2D(s, f);
}
uniform	sampler2D	gTextureSampler0;
uniform	vec4	gFogColor0;
varying	vec4	oColor_0;
varying	vec4	oColor_1;
varying	vec2	oTexcoord2_0;
varying	float	oTexcoord1_1;
void main() {
	vec4 outputColor;
	vec4	texel_0;
	vec4	source1;
	vec4	source2;
	FFP_Assign(oColor_0, outputColor);
	FFP_SampleTexture(gTextureSampler0, oTexcoord2_0, texel_0);
	FFP_Assign(texel_0, source1);
	FFP_Assign(oColor_0, source2);
	FFP_Modulate(source1, source2, outputColor);
	FFP_Add(outputColor.xyz, oColor_1.xyz, outputCol

Code: Select all

namespace OgreBites
{

    /** This class demonstrates basic usage of the RTShader system.
     It sub class the material manager listener class and when a target scheme callback
     is invoked with the shader generator scheme it tries to create an equivalent shader
     based technique based on the default technique of the given material.
     */
    class ShaderGeneratorTechniqueResolverListener: public Ogre::MaterialManager::Listener
    {
    public:

        ShaderGeneratorTechniqueResolverListener(Ogre::RTShader::ShaderGenerator* pShaderGenerator)
        {
            mShaderGenerator = pShaderGenerator;
        }

        /** This is the hook point where shader based technique will be created.
         It will be called whenever the material manager won't find appropriate technique
         that satisfy the target scheme name. If the scheme name is out target RT Shader System
         scheme name we will try to create shader generated technique for it.
         */
        virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend)
        {
            Ogre::Technique* generatedTech = NULL;

            // Case this is the default shader generator scheme.
            if (schemeName == Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME)
            {
                bool techniqueCreated;

                // Create shader generated technique for this material.
                techniqueCreated = mShaderGenerator->createShaderBasedTechnique ( originalMaterial->getName (), Ogre::MaterialManager::DEFAULT_SCHEME_NAME, schemeName );

                // Case technique registration succeeded.
                if (techniqueCreated)
                {
                    // Force creating the shaders for the generated technique.
                    mShaderGenerator->validateMaterial ( schemeName, originalMaterial->getName () );

                    // Grab the generated technique.
                    Ogre::Material::TechniqueIterator itTech = originalMaterial->getTechniqueIterator ();

                    while (itTech.hasMoreElements ())
                    {
                        Ogre::Technique* curTech = itTech.getNext ();
                        if (curTech->getSchemeName () == schemeName)
                        {
                            generatedTech = curTech;
                            LogTool::logString ( "\n\n" );
                            LogTool::logString ( "ShaderGenerator..." );
                            LogTool::logString ( "scheme name:", schemeName );
                            LogTool::logString ( "material name:", originalMaterial->getName () );
                            LogTool::logString ( "vertex shader\n", generatedTech->getPass ( 0 )->getVertexProgram ()->getSource () );
                            LogTool::logString ( "vertex-fragment Dividing line----------------------------" );
                            LogTool::logString ( "fragment shader\n", generatedTech->getPass ( 0 )->getFragmentProgram ()->getSource () );
                            LogTool::logString ( "\n\n" );
                            break;
                        }
                    }
                }
            }

            return generatedTech;
        }

    protected:
        Ogre::RTShader::ShaderGenerator* mShaderGenerator;    // The shader generator instance.
    };
}
Last edited by spacegaier on Fri Jun 20, 2014 8:09 am, edited 1 time in total.
Reason: added code tags
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Shader source truncated

Post by c6burns »

Set a cache path for the shader generator to use instead:
http://www.ogre3d.org/docs/api/1.9/clas ... b6c7cd97d9
Then read the shaders from there. If I had to guess, you are using an android device and __android_log_print is truncating it (or something like that)
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Re: Shader source truncated

Post by machineonpointer »

Yes, It's an mobile app.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Shader source truncated

Post by c6burns »

I thought so. So split the shader across multiple log calls, or write the shaders to a cache location (like /sdcard on android) and pull them off the device for reading.
Post Reply