Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

varying.def.sc file is too mysterious #306

Closed
DagAgren opened this issue Mar 23, 2015 · 8 comments
Closed

varying.def.sc file is too mysterious #306

DagAgren opened this issue Mar 23, 2015 · 8 comments

Comments

@DagAgren
Copy link

There's no documentation for the varying.def.sc file format, and it seems to have lots of peculiarities about it. I've run into lots of trouble getting my shaders working because of problems with varying.def.sc. For instance, it seems highly sensitive to whitespace placement. It is also not quite clear what the various parts of it actually mean.

@bkaradzic
Copy link
Owner

White space is probably bug. What's exact problem?

Format is:

 [lowp/mediump/highp] [flat/smooth/noperspective] <type> <name> : <semantics> [= default value];

@DagAgren
Copy link
Author

I got problems when I did not have spaces around : and =. Parsing seemed to fail and no varying statement was added to the source.

@DagAgren
Copy link
Author

Also, right now, both my $input and $output values are being declared as "varying" for some reason I can't figure out.

$input vertex_attrib
$output position

#include <bgfx_shader.sh>

uniform vec3 size;

void main()
{
    position=vertex_attrib*size;
    gl_Position=mul(u_modelViewProj,vec4(position,1.0));
}

varying.def.sc:

vec3 position : POSITION = vec3(0.0,0.0,0.0);

vec3 vertex_attrib : POSITION;

And with options --type v --platform osx --profile 120.

@DagAgren
Copy link
Author

The result is:

varying vec3 vertex_attrib;
varying vec3 position;
uniform mat4 u_modelViewProj;
uniform vec3 size;
void main ()
{
  position = (vertex_attrib * size);
  vec4 tmpvar_1;
  tmpvar_1.w = 1.0;
  tmpvar_1.xyz = position;
  gl_Position = (u_modelViewProj * tmpvar_1);
}

@bkaradzic
Copy link
Owner

vertex_attrib is invalid name for attribute ($input). It must be one of following:
https://github.com/bkaradzic/bgfx/blob/master/include/bgfx.h#L72

For $output you can name varying as you like.

@bkaradzic
Copy link
Owner

I fixed varying parsing.

@DagAgren
Copy link
Author

Ok, good!

But some documentation would be quite nice, so you can find out that some names are special.

(Is there any reason they have to be? Can't shaderc change the names around if special ones are needed on some platform?)

@bkaradzic
Copy link
Owner

It's documented in all examples since they are using a_* notation + header file that provides documentation about vertex declaration explicitly states how those are bound to shader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants