Unable to load material script

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
desk87
Gnoblar
Posts: 2
Joined: Tue Sep 26, 2023 3:16 pm

Unable to load material script

Post 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.

You do not have the required permissions to view the files attached to this post.
paroj
OGRE Team Member
OGRE Team Member
Posts: 2137
Joined: Sun Mar 30, 2014 2:51 pm
x 1145

Re: Unable to load material script

Post by paroj »

desk87
Gnoblar
Posts: 2
Joined: Tue Sep 26, 2023 3:16 pm

Re: Unable to load material script

Post 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.