Page 1 of 1

Unable to load material script

Posted: Tue Sep 26, 2023 3:47 pm
by desk87

Hi everyone,

I'm working on an online viewer using the Ogre emscripten build.
I'd like to use a custom material for a manual object that represents the pivot around which the orbital camera rotates. However, I am unable to parse the following, very simple, material script:

CameraTarget.material

Code: Select all

vertex_program CameraTargetVertex glsl
{
    source CameraTarget.vert
}

fragment_program CameraTargetFragment glsl
{
    source CameraTarget.frag
}

material CameraTarget
{
    technique
    {
        pass
        {
            vertex_program_ref CameraTargetVertex
            {
            }
            
fragment_program_ref CameraTargetFragment { } } } }

CameraTarget.vert

Code: Select all

#version 300 es            

void main() {
    vec3 pos = vec3(0.0f);
    gl_Position = vec4(pos, 1.0f);
}

CameraTarget.frag

Code: Select all

#version 300 es        
precision mediump float; out vec4 FragColor; void main() { FragColor = vec4(1.0f); }

ManualObject creation

Code: Select all

void PivotCameraController::setupTargetManualObject()
{
    using namespace Ogre;
    auto material =
        MaterialManager::getSingleton().getByName( "CameraTarget" );

mTargetManualObject->begin(
    material->getName(), RenderOperation::OT_LINE_LIST );
mTargetManualObject->colour( ColourValue::Red );
mTargetManualObject->position( .5 * Vector3::NEGATIVE_UNIT_X );
mTargetManualObject->position( .5 * Vector3::UNIT_X );
mTargetManualObject->end();

mTargetManualObject->begin(
    material->getName(), RenderOperation::OT_LINE_LIST );
mTargetManualObject->colour( ColourValue::Green );
mTargetManualObject->position( .5 * Vector3::NEGATIVE_UNIT_Y );
mTargetManualObject->position( .5 * Vector3::UNIT_Y );
mTargetManualObject->end();

mTargetManualObject->begin(
    material->getName(), RenderOperation::OT_LINE_LIST );
mTargetManualObject->colour( ColourValue::Blue );
mTargetManualObject->position( .5 * Vector3::NEGATIVE_UNIT_Z );
mTargetManualObject->position( .5 * Vector3::UNIT_Z );
mTargetManualObject->end();
}

for which I get the following warning:

Warning: material CameraTarget has no supportable Techniques and will be blank. Explanation:
Pass 0: vertex program CameraTargetVertex cannot be used - not supported.

Attached you can find the full log of the execution.

Any idea of what I might be doing wrong?

Thank you in advance.


Re: Unable to load material script

Posted: Wed Sep 27, 2023 10:17 am
by paroj

Re: Unable to load material script

Posted: Wed Sep 27, 2023 1:53 pm
by desk87

Thanks for the help, I managed to fix the issue by changing

Code: Select all

vertex_program CameraTargetVertex glsl

and

Code: Select all

fragment_program CameraTargetFragment glsl

to

Code: Select all

vertex_program CameraTargetVertex glsles

and

Code: Select all

fragment_program CameraTargetFragment glsles

respectively.