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
x 1

Bugs with Ogre and Cg->glsles using HLSL2GLSL

Post by d000hg »

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?
oiram
Halfling
Posts: 87
Joined: Sun Dec 13, 2009 5:06 am
x 6

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

Post by oiram »

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:
d000hg
Goblin
Posts: 257
Joined: Tue Sep 02, 2008 9:41 pm
x 1

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

Post by d000hg »

I'll make a note to test this, if it works that would be wonderful :)
d000hg
Goblin
Posts: 257
Joined: Tue Sep 02, 2008 9:41 pm
x 1

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

Post by d000hg »

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?!
Post Reply