Bugs with Ogre and Cg->glsles using HLSL2GLSL

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
d000hg
Goblin
Posts: 257
Joined: Tue Sep 02, 2008 9:41 pm

Bugs with Ogre and Cg->glsles using HLSL2GLSL

Post by d000hg » Mon Oct 29, 2012 4:04 pm

I found that none of my Cg shaders were working when using HLSL2GLSLFork. By saving the generated shaders as new glsles versions and examining them, I think I've found a couple of bugs.

Here's a working Cg shader:

Code: Select all

struct vs_out {
    float4 position:POSITION;
};
vs_out test_vs(float4 position: POSITION, uniform float4x4 worldViewProj)
{
    vs_out ret;
    ret.position = mul(worldViewProj, position);
    return ret;
}
Here is what Ogre/HLSL2GLSL has created:

Code: Select all

#version 100
precision mediump int;
precision mediump float;

struct vs_out {
    vec4 position;
};

uniform mat4 worldViewProj;

vs_out test_vs( in vec4 position, mat4 worldViewProj ) {
    vs_out ret;
    ret.position = (worldViewProj * position);
    #line 33
    return ret;
}
uniform mat4 xlu_worldViewProj;
attribute vec4 vertex;

void main() {
    vs_out xl_retval;
    xl_retval = test_vs( vec4(vertex), xlu_worldViewProj);
    gl_Position = vec4( xl_retval.position);
}
So I noticed these weird "xlu_" uniforms being created, the same name as Ogre's auto-vars but with the xlu_prefix. I changed the code to use the ogre versions instead of the xlu_ ones, and suddenly it was working!

So what's the deal here? Am I doing something wrong, or is there a problem with Ogre Vs HLSL2GLSL?
0 x

oiram
Halfling
Posts: 87
Joined: Sun Dec 13, 2009 5:06 am

Re: Bugs with Ogre and Cg->glsles using HLSL2GLSL

Post by oiram » Tue Dec 11, 2012 3:05 pm

To fix this issue:

Code: Select all


uniform float4x4 worldViewProj;

struct vs_out {
    float4 position:POSITION;
};

vs_out test_vs(float4 position: POSITION)
{
    vs_out ret;
    ret.position = mul(worldViewProj, position);
    return ret;
}
Hope it's helpful. :wink:
0 x

d000hg
Goblin
Posts: 257
Joined: Tue Sep 02, 2008 9:41 pm

Re: Bugs with Ogre and Cg->glsles using HLSL2GLSL

Post by d000hg » Tue Dec 11, 2012 3:17 pm

I'll make a note to test this, if it works that would be wonderful :)
0 x

d000hg
Goblin
Posts: 257
Joined: Tue Sep 02, 2008 9:41 pm

Re: Bugs with Ogre and Cg->glsles using HLSL2GLSL

Post by d000hg » Fri Mar 01, 2013 4:09 pm

This seems to fix it, that's totally awesome!

I wish Cg didn't have 3 ways (at least) to specify a function though... why do I have to do this?!
0 x

Post Reply