shader noobi question

anyways, i could have there 1 or 1000 of output positions and it would make no difference! :wink: its not about the output , it about the input :wink: lol. i just wanted to know how to store more than just one object. lol as, you can see, im not having a output in the second one. so forget about the output, its only about the input and how to loop over it. but thanks for letting me know that i need therefor a geometry shader.

now i know whats varying is :slight_smile:

i will use now glsl, seems to be more handsome and better documented.

quite nice to know now:
panda3d.org/manual/index.php/T … c_renderer

thats a quite nice document i found about geometry shaders:
developer.nvidia.com/object/nvid … specs.html

opengl.org/registry/specs/NV … ogram4.txt

hmmm :wink:

A vertex shader may define one or more varying variables (see the OpenGL
Shading Language specification). Varying variables are outputs of a vertex
shader. They are either used as the mechanism to communicate values to a
geometry shader, if one is active, or to communicate values to the
fragment shader. The OpenGL Shading Language specification also defines a
set of built-in varying variables that vertex shaders can write to (see
section 7.6 of the OpenGL Shading Language Specification). These variables
can also be used to communicate values to a geometry shader, if one is
active, or to communicate values to the fragment shader and to the fixed-
function processing that occurs after vertex shading.

If a geometry shader is not active, the values of all varying variables,
including built-in variables, are expected to be interpolated across the
primitive being rendered, unless flat shaded. The number of interpolators
available for processing varying variables is given by the
implementation-dependent constant MAX_VARYING_COMPONENTS_EXT. This value
represents the number of individual components that can be interpolated;
varying variables declared as vectors, matrices, and arrays will all
consume multiple interpolators. When a program is linked, all components
of any varying variable written by a vertex shader, or read by a fragment
shader, will count against this limit. The transformed vertex position
(gl_Position) does not count against this limit. A program whose vertex
and/or fragment shaders access more than MAX_VARYING_COMPONENTS_EXT
components worth of varying variables may fail to link, unless
device-dependent optimizations are able to make the program fit within
available hardware resources.

sorry to say, but the shader thingi in panda is really strange.

actually i figured out a wrong entry again in the manual:
to load a shader in c++ it isnt Shader.SLGLSL its Shader.SL_GLSL.

i will wait a bit, till the shader supporting works smoother and better documented.

What do you mean, the shader supporting works smoother? What doesn’t work smooth about it? As far as I can tell, you’re using it incorrectly.

I think your concept of what a shader does is a bit off. A shader runs on each element of an object (be that vertex or pixel) in parallel, you cannot do something like loop over the vertices of an object in a shader.

If you haven’t done so, I would recommend reading NVIDIA’s CG tutorial:
http.developer.nvidia.com/CgTuto … ter01.html
It helps explain why shaders function as they do.

@rdb: maybe im doing something wrong, but please tell what.

here is the shader:

(basic shader from panda manual)

//GLSL
void main() {
  gl_Position = ftransform();
}

or neither this works: (which is the supported way above glsl 1.5 or so)

//GLSL
void main() 
{    
    gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex; 
}

here, how im loading my shader:

PT(Shader) myRuler = Shader::load(Shader.SL_GLSL,"myRuler.glsl","","");

this crashes if im loading shader (like in the panda manual discribes). erros: wrong declaration (Shader.SLGLSL)

PT(Shader) myRuler = Shader::load(Shader.SLGLSL,"myRuler.glsl","","");

maybe there is way to define the used shader like ST_vertex or ST_geometry … which i saw in the shader.h file. so i could leave this empty strings.

thanks for letting me know what im doing wrong, it would be very nice.

the error message while executing the shader:

ERROR:  compilation errors.  No code generated.

ERROR: 0:1: 'defined' : syntax error parse error
ERROR:  compilation errors.  No code generated.

@teedee: sorry, but i have to loop over verts or faces. i needed to calculate some relations between.
or how to store vertex or any gemetry values instead to do some calculations?

I’m not sure if it helps what you’re trying to do, but one thing you can do is re-purpose UV or vertex colours to store information there that the shader will use. For example, to store pre-calculated ambient occlusion, vertex position offsets, or really any data you want.

thank you, im sure that i will give this whirl. sounds like it could work. but before i need to wait for rdb´s answer, i want to develop this shader in glsl. it seems to be far deeper developed, better documented and more flexible in use.

@rdb: it would be very kind of you to answer me. please tell me what im doing wrong.

To be honest, I don’t know. It works fine for me. Can it be the problem that you saved the text file with an editor that prepends those microsoft-specific two bytes?

im using visual studio for writing this code.
i saw that a other user had the same problem. i checked my code file too. but i cant see any extension entries there.

its noones fault, panda got in the meantime such complex and huge, so its normal that there are some things not working like they should. like you said, 1.7 is a experimental release, its amazing brilliant, but some things should be fixed (please fix this glsl supporting for windows machines). i would love to learn shader programming, i can see a amazing potential behind. ok i have to relativate this, only can see a amazing potential behind glsl.

its not that i wouldnt love to switch back again to linux, but some tools and hardware i use are only working on windows like they should (which is related to the money). (i could write a song about all my troubles i had with hardware supporting on linux). but on the other hand i would love to run my machine on linux, only for having more control and a better performance. but i cant. and i think win vista or win 7(which is win vista, just with very tiny changes) is a amazing advanced os. i cant say anything bad about win vista.

Your use of Visual Studio is most likely the problem. Can you try creating the shader file in a non-Microsoft editor, and save it with Unix newlines also?

comeon rdb!

My apologies. I will not bother you again with my apparently annoying attempts to find out what is wrong.

im sorry, but as you know or you can imagin, the tiny surface of forgiving is fragil, so im sorry. same error if im change the spaces to hex 20!

I see that the file still has DOS newlines, not Unix newlines. If you’re still in your hex editor, try removing the 0D’s before the 0A’s.

same error, i tried it also before to change it to hex 20 spaces.

i will try now to write this two lines on my linux machine.

It is certainly mysterious. This may be a stupid question, but are you sure there isn’t some bogus copy of myRuler.glsl, with invalid text in it, that it is loading instead of the one you think it is loading?

Or is it possible your drivers are somehow fubar and unable to parse GLSL syntax? Are you sure you’re actually running with OpenGL and not DirectX?

Whatever’s wrong, it’s probably something really stupid. It usually is, when something’s this fundamentally broken. :slight_smile: I eagerly await reports of success of failure on your Linux machine.

David

no glsl copy, no directX.

i got the same error by creating this file under linux and running it on windows. i canot develop on this other computer its just used to render, so im having no graphics card in which would support shaders i think. its just a onboard chip.

but i got at least a new idea. im going to copy again this bunch of dll´s into my project, maybe this works.

It is suspicious that you get the same error on a machine that is software-only and doesn’t support shaders. Are you sure you’re not running a software-only OpenGL driver on your Windows machine?

David

hmpf, i was running this shader on my windows computer like i said.

and im running panda in openGL on windows. CG shaders works but the GLSL doesnt.