|
|
|
Return to Panda Features in Development
by memecss » Wed Apr 07, 2010 3:09 pm
Hello,
We have just committed into the CVS a new feature for the panda3D shader system that extends the set of available inputs that can be passed to the Cg shader.
In details:
1. Panda3D data types:
This is complete list of numeric parameters that can now be passed to a Cg shader.
- Code: Select all
from pandac.PandaModules import Vec4 from pandac.PandaModules import Vec3 from pandac.PandaModules import Vec2
from pandac.PandaModules import Point4 from pandac.PandaModules import Point3 from pandac.PandaModules import Point2
from pandac.PandaModules import Mat4 from pandac.PandaModules import Mat3
# PTA means Pointer to Array from pandac.PandaModules import PTAMat4 from pandac.PandaModules import PTAMat3
# Point and Vector derive from VecBase from pandac.PandaModules import PTAVecBase4 from pandac.PandaModules import PTAVecBase3 from pandac.PandaModules import PTAVecBase2
# Pointer to 1D arrays from pandac.PandaModules import PTAFloat from pandac.PandaModules import PTADouble 2. Passing the inputs:All the parameters are passed through the well known function: - Code: Select all
setShaderInput(name,arg) 3. Relationship with Cg data types:A complete list of possible Cg data types can be found here: http://pastebin.com/WRcT9D2SOur work makes available all the numeric types and arrays of them. By numeric I mean all the parameters belonging to the following classes: - CG_PARAMETERCLASS_SCALAR - CG_PARAMETERCLASS_VECTOR - CG_PARAMETERCLASS_MATRIX Panda3d types and Cg types are connected only by their size. The size in this case represent the number of elements (scalars) contained by the data type. For example: - Code: Select all
x1 = Mat4() x2 = PTAVecBase4.empty_array(4) x3 = PTAFloat.empty_array(16)
sizeof(x1) = sizeof(x2) = sizeof(x3) = 16
In practice this means that setShaderInput(pname, element_of_size_16) can be used to set any of the Cg parameters having the same size. For example it is legal to do: - Code: Select all
//Panda3D setShaderInput(pname, x1)
//Cg uniform float4x4 pname; uniform float2x4 pname[2]; uniform float4x2 pname[2]; uniform float4 pname[4]; uniform float2 pname[8]; uniform float pname[16];
//Note: float can be changed to: double, bool, fixed, half
This gives a lot more freedom to the user. Now the user not only has access to the data types represented directly in panda3d (i.e. Mat4 -> float4x4), but also has access to the more exotic types made available by Cg (i.e. bool4x2  ) 4. Putting it all together:- Code: Select all
//Panda3d
import os import sys
#panda imports import direct.directbase.DirectStart from pandac.PandaModules import *
def main(argv): base.setBackgroundColor(0.1, 0.1, 0.1) base.camLens.setNearFar(1.0, 50.0) base.camLens.setFov(45.0)
base.disableMouse() base.accept("escape", sys.exit)
camera.setPos(0.0, -15.0, 10.0) camera.lookAt(0.0, 0.0, 0.0) root = render.attachNewNode("Root") teapot = loader.loadModel(os.path.join( os.getcwd(),"teapot.egg")) teapot.reparentTo(render); # Shader Inputs x1 = Mat4() x2 = PTAVecBase4.emptyArray(4) x3 = PTAFloat.emptyArray(16)
teapot.setShaderInput("IN.pname11",x1); teapot.setShaderInput("IN.pname12",x1); teapot.setShaderInput("IN.pname21",x2); teapot.setShaderInput("IN.pname22",x2); teapot.setShaderInput("IN.pname31",x3); teapot.setShaderInput("IN.pname32",x3); teapot.setShader(loader.loadShader("shader.sha")) run()
if __name__ == '__main__': main(sys.argv)
- Code: Select all
//Cg
struct VertexDataIN{ float4 vtx_position :POSITION; float4 vtx_normal :NORMAL; float4 vtx_color :COLOR; float2 vtx_texcoord0 :TEXCOORD0; };
struct VertexDataOUT{ float4 l_position :POSITION; float4 l_normal :TEXCOORD1; float4 l_color :COLOR; float2 l_texcoord0 :TEXCOORD0; };
void vshader(VertexDataIN IN, out VertexDataOUT OUT, uniform float4x4 mat_modelproj) { OUT.l_position = mul(mat_modelproj, IN.vtx_position); OUT.l_color = IN.vtx_color; OUT.l_normal = IN.vtx_normal; OUT.l_texcoord0 = IN.vtx_texcoord0; }
struct ShaderInputs{ uniform float4x4 pname11; uniform float2x4 pname12[2]; uniform float4x2 pname21[2]; uniform float4 pname22[4]; uniform float2 pname31[8]; uniform float pname32[16]; };
void fshader(VertexDataOUT vIN, ShaderInputs IN, out float4 o_color : COLOR) { o_color = IN.pname11[0][1]; o_color = IN.pname12[1][0]; o_color = transpose(IN.pname21[1])[1]; o_color = IN.pname22[1]; o_color = float4(IN.pname31[1],0,1); o_color = float4(IN.pname32[1],0,1,0); } 4. Conclusion:This feature will be soon documented in the Panda3D manual, in the meanwhile, if you have any doubts or suggestions on how to make the documentation clearer then this post, please let me know. 4. Notes:1. We got rid of the k_ prefix. This update is backward compatible, but the k_ prefix shouldn't be used any more.
Thanks,
Federico
Last edited by memecss on Wed Apr 07, 2010 6:39 pm, edited 1 time in total.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by treeform » Wed Apr 07, 2010 6:14 pm
In the old system all inputs Be it Vec3 or Vec4 got converted to a Mat4 first then reconvert to float3 or float4. That does not happen any more right? And if we send Vec3 we can assume it only sends float3 - or 12bytes to the graphics card?
-

treeform
-
- Posts: 2106
- Joined: Sat May 05, 2007 5:15 pm
- Location: SF, CA
-
by memecss » Wed Apr 07, 2010 6:30 pm
Exactly, the new system, send always the right amount of data. Remember that setShaderInput(name,float) internally becomes setShaderInput(name,Vec4). I couldn't change that function because I wanted to keep the code backward compatible.
So if you want to sent to the GPU a scalar you should do something like:
- Code: Select all
setShaderInput(name,PTAFloat) or: setShaderInput(name,[1]) # that is going to be implicitly casted into a PTAFloat.
Using directly PTA's, means passing only a pointer, and therefore better performances.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by Bradamante » Wed Apr 14, 2010 9:08 am
If I try the code at the end of the first post it gives a flat blue teapot. Is that the desired result?
- Code: Select all
teapot = loader.loadModel(os.path.join( os.getcwd(),"teapot.egg"))
will try to load the teapot from my home directory, i.e. /Users/username/teapot.egg What works is: - Code: Select all
teapot = loader.loadModel("models/teapot.egg")
iMac (2009), Mac OS X.8.1 - MacBookPro (2007), Mac OS X.8.2
@ YouTube
-

Bradamante
-
- Posts: 303
- Joined: Tue Nov 25, 2008 10:58 am
- Location: Leipzig, Germany
by memecss » Wed Apr 14, 2010 12:36 pm
Yes the final result is supposed to be a blue teapot. Not really exciting, but it is a good way to experiments the new inputs.
- Code: Select all
teapot = loader.loadModel(os.path.join( os.getcwd(),"teapot.egg"))
will try to load the teapot from my home directory, i.e. /Users/username/teapot.egg
Thanks for pointing this out. I had the models in my working directory, and I forgot to change it.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by SylHar » Mon Apr 19, 2010 3:58 am
sorry to hijack this tread a little, but I have a question somewhat related.
When/Will Panda3d cg shader will support vector arrays as argument ?
I'm doing a shader to show a polygon inside the triangles.
currently I'm doing:
- Code: Select all
uniform float4 k_bordersize,
uniform float4 k_contour0, uniform float4 k_contour1, uniform float4 k_contour2, [...] uniform float4 k_contour100, [...] get_min_value(k_contour0 , k_contour1 , l_pos, laststart, currentcontour, min_value); get_min_value(k_contour1 , k_contour2 , l_pos, laststart, currentcontour, min_value); [...] get_min_value(k_contour99, k_contour100, l_pos, laststart, currentcontour, min_value);
Unless I'm mistaken. I could do this in cg: - Code: Select all
uniform float4 k_contour[101], [...] for( i =0; i< 99; i++) { get_min_value(k_contour[i] , k_contour[i+1] , l_pos, laststart, currentcontour, min_value); }
but panda3d doesn't allow array of vector as shaderInput.
-

SylHar
-
- Posts: 222
- Joined: Wed Feb 06, 2008 12:21 pm
- Location: roanne, France
by memecss » Wed Apr 21, 2010 12:41 pm
If you download Panda3D from the CVS you'll have available arrays of vectors (PTAVecBase4) as shader inputs.
And then yes, you could do something like this:
Unless I'm mistaken. I could do this in cg: - Code: Select all
uniform float4 k_contour[101], [...] for( i =0; i< 99; i++) { get_min_value(k_contour[i] , k_contour[i+1] , l_pos, laststart, currentcontour, min_value); }
You can find more informations here:
http://www.panda3d.org/wiki/index.php/L ... der_Inputs (still under construction)
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by rdb » Fri May 21, 2010 4:02 am
Are there plans to fix the shader inputs for GLSL after these contributions? It kind of sucks that many GLSL shader inputs are broken in the CVS head now.
-
rdb
-
- Posts: 8548
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by memecss » Fri May 21, 2010 9:38 am
I don't think so. When I asked I was explicitly told not to do it. Instead I think there are plans to add inputs support for DirectX.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by treeform » Fri May 21, 2010 9:53 am
Does this break stuff that was working before?
-

treeform
-
- Posts: 2106
- Joined: Sat May 05, 2007 5:15 pm
- Location: SF, CA
-
by memecss » Fri May 21, 2010 9:54 am
No, it doesn't. The same set of inputs available before for GLSL is working.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by rdb » Fri May 21, 2010 1:19 pm
memecss wrote:I don't think so. When I asked I was explicitly told not to do it. Instead I think there are plans to add inputs support for DirectX.
Well, yay for CMU's secret agenda to push open standards off the table. 
-
rdb
-
- Posts: 8548
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by memecss » Fri May 21, 2010 1:38 pm
Actually, I am pretty sure this is Disney Imagineering's secret agenda...
EDIT:
somewhere there is a chart with the features they want ETC to develop.
Last edited by memecss on Sun May 23, 2010 2:29 pm, edited 1 time in total.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by rdb » Sun May 23, 2010 5:13 am
memecss wrote:Actually, I am pretty sure this is Disney Imagineering's secret agenda...
Oh, okay. Fair enough.
Honestly, this kind of pisses me off. Such great features were added, and then it appears that it a big part of the implementation was intentionally left out, even such an important part given that Panda3D is an open-source engine and therefore should fully support and emphasis open standards.
-
rdb
-
- Posts: 8548
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by drwr » Sun May 23, 2010 12:45 pm
Well, I don't know the whole story here; but I doubt there was any intention to leave useful features out. Panda development has always been very pragmatic: I need features X and Y, so I'll do them. Feature Z would be nice too, but I only have time to do X and Y right now.
This is, of course, both a good thing and a bad thing. It's good, because it's part of what makes Panda so useful in practice--it has actually been used to do real projects and has the features needed to make it happen. It's bad, because it means that the set of features supported may be only a subset of the available features in an interface, which can be frustrating to new users.
As to the open standards thing, I agree that it would be nice to support open standards to the extent possible. But I also see the pragmatism in keeping the DirectX layer from getting too far behind. (In addition to improving support on a wider variety of Windows PC's, having good support for two different backends helps keeps the high level interface clean.)
David
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by memecss » Mon May 24, 2010 9:56 am
Well, I don't know the whole story here; but I doubt there was any intention to leave useful features out. Panda development has always been very pragmatic: I need features X and Y, so I'll do them. Feature Z would be nice too, but I only have time to do X and Y right now. I think this is exactly what happened. Where?
Sorry I didn't mean to be mysterious. I will ask someone who still has a copy to post it.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by zhao » Thu Jun 10, 2010 11:49 am
I recently asked Federico some questions. The answers maybe useful to the general public:
1) Do these array inputs only work with advanced profiles?
As long as the profile supports them, yes they do. I think, exception made for texture arrays, they should be all supported by arbfp1 etc...
2) Is there a limit to how large an array input can be? ~256?
Yes there is. It depends on the size of the registers of the graphics card. Should be around 16k. For example 256 matrices 4x4 of floats.
3) Is it possible to index an array in the vertex shader?
Of course. You can do something like:
#define SIZE 256
int array[SIZE];
-
zhao
-
- Posts: 224
- Joined: Tue Nov 10, 2009 5:32 pm
by Bradamante » Thu Jul 29, 2010 3:59 pm
I downloaded the
"advanced shader inputs Demo (Perlin Noise applied to a sphere)"
from http://www.etc.cmu.edu/projects/pandase/downloads.html
Tested it on my Mac. It's there but it's just full screen grey flickering. Maybe good for certain recreational purposes ... but ... doesn't this work on Mac?
Also notice that
- Code: Select all
teapot = loader.loadModel(os.path.join( os.getcwd(),"plane.egg"))
doesnt work. Looks at the home directory instead of the script directory.
iMac (2009), Mac OS X.8.1 - MacBookPro (2007), Mac OS X.8.2
@ YouTube
-

Bradamante
-
- Posts: 303
- Joined: Tue Nov 25, 2008 10:58 am
- Location: Leipzig, Germany
by memecss » Sun Aug 01, 2010 2:34 am
Yeah it should work. The sphere is actually behind you when you run the app, so either move the mouse backward or forward and it will appear.
By the way the demo is not even for recreational purpose, we didn't polish the code and keys do not work as expected etc... I did it only because we needed a stupid demo fast to show for our project.
Take a look at the flocking Ralph demo instead.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by Bradamante » Tue Aug 03, 2010 6:53 am
It just doesnt work. There's a white plane in the middle of the screen. The grey background flashes like a strobe light between brighter and dark grey. I can use the mouse to turn and zoom in etc. but the thing just doesnt work.
In the bash I get these errors:
- Code: Select all
:gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (5) : error C0109: Can't open include file "vtable.cg" :gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (24) : error C1307: non constant expression for array size :gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (99) : warning C7011: implicit cast from "float4" to "float3" :gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (100) : warning C7011: implicit cast from "float4" to "float3" :gobj(error): Shader encountered an error. :gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (5) : error C0109: Can't open include file "vtable.cg" :gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (24) : error C1307: non constant expression for array size :gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (99) : warning C7011: implicit cast from "float4" to "float3" :gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (100) : warning C7011: implicit cast from "float4" to "float3"
The flocking Ralph demo crashes and gives me this error: - Code: Select all
DirectStart: Starting the game. Known pipe types: osxGraphicsPipe (all display modules loaded.) Traceback (most recent call last): File "/Users/tiloprobst/Downloads/Advanced-Shader-Inputs/Tut-AdvacedShaderInputs.py", line 175, in <module> w = World() File "/Users/tiloprobst/Downloads/Advanced-Shader-Inputs/Tut-AdvacedShaderInputs.py", line 37, in __init__ "Profile gp4vp is not supported by the hardware." AssertionError: Profile gp4vp is not supported by the hardware.
Graphics card is a 8600M GT in a 2007 MacBookPro.
iMac (2009), Mac OS X.8.1 - MacBookPro (2007), Mac OS X.8.2
@ YouTube
-

Bradamante
-
- Posts: 303
- Joined: Tue Nov 25, 2008 10:58 am
- Location: Leipzig, Germany
by memecss » Tue Aug 03, 2010 8:26 am
- Code: Select all
:gobj(error): /Users/tiloprobst/Downloads/Advanced_Shader_Inputs_Demo/Advanced_Shader_Inputs_Demo/shader.sha: (5) : error C0109: Can't open include file "vtable.cg"
You are missing a file. Run generate_noise_table.py to get it. AssertionError: Profile gp4vp is not supported by the hardware.
It doesn't crash this is an assertion error probably because the drivers of your graphics card are not updated.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by Bradamante » Wed Aug 04, 2010 3:19 pm
memecss wrote:You are missing a file. Run generate_noise_table.py to get it.
Already did that. Still gives me that error and others. It doesn't crash this is an assertion error probably because the drivers of your graphics card are not updated.
How am I supposed to do that on a Mac? Install a new OS? Somehow I doubt this would be gone if I updated to 10.6.
iMac (2009), Mac OS X.8.1 - MacBookPro (2007), Mac OS X.8.2
@ YouTube
-

Bradamante
-
- Posts: 303
- Joined: Tue Nov 25, 2008 10:58 am
- Location: Leipzig, Germany
by memecss » Fri Aug 06, 2010 11:49 am
How am I supposed to do that on a Mac? Install a new OS? Somehow I doubt this would be gone if I updated to 10.6.
The drivers of your graphics card have nothing to do with your OS.
Try to set to false basic-shaders-only in your Config.prc file. That could fix the problem. Otherwise just go on your graphics card vendor website and download updated drivers for your model.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by Bradamante » Fri Aug 06, 2010 6:25 pm
memecss wrote:The drivers of your graphics card have nothing to do with your OS.
Oh really? On the Mac it does. Drivers are only provided through Apple's OS updates. I can not just go on the NVidia website and get new drivers! memecss wrote:Try to set to false basic-shaders-only in your Config.prc file. That could fix the problem.
I guess I should be more precise. The noise/sphere demo does generally work, but there is a grey flickering. The whole screen just flickers in grey tones. I can't provide screenshots of that. I could make a video, yeah.
The instancing/flocking Ralph demo crashes with the errors mentioned above.
- Code: Select all
File "/Users/tiloprobst/Downloads/Advanced-Shader-Inputs/Tut-AdvacedShaderInputs.py", line 175, in <module> w = World() File "/Users/tiloprobst/Downloads/Advanced-Shader-Inputs/Tut-AdvacedShaderInputs.py", line 37, in __init__ "Profile gp4vp is not supported by the hardware." AssertionError: Profile gp4vp is not supported by the hardware.
iMac (2009), Mac OS X.8.1 - MacBookPro (2007), Mac OS X.8.2
@ YouTube
-

Bradamante
-
- Posts: 303
- Joined: Tue Nov 25, 2008 10:58 am
- Location: Leipzig, Germany
by memecss » Fri Aug 06, 2010 10:39 pm
Oh really? On the Mac it does. Drivers are only provided through Apple's OS updates. I can not just go on the NVidia website and get new drivers!
If on a mac the graphics card drivers can be updated only from the Software Update (software not OS...) it doesn't mean they are part of the OS. It does not make any sense to update the OS to get updated graphics card drivers.
By the way download the CG toolkit 2.0 it will solve the problem with the profile error.
Moreover download the OpenGL Extensions Viewer and look in the report tab if you have the extension GL_EXT_texture_array.
I deleted vtable.cg and it gave the same error you posted above and for the flickering I have no idea, there is no reason for that. You can delete - Code: Select all
base.setBackgroundColor(0.9, 0.9, 0.9)
and see if it solves the problem. We tested it on windows and linux and we never had flickering.
EDIT:
You can still download the drivers from the NVIDIA website:
http://www.nvidia.com/object/GeForce_Ma ... .2f16.html
but I don't think the drivers are your problem, the problem is that you don't have CG 2.0 on your mac.
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by Bradamante » Sat Aug 07, 2010 4:46 am
memecss wrote:If on a mac the graphics card drivers can be updated only from the Software Update (software not OS...) it doesn't mean they are part of the OS. It does not make any sense to update the OS to get updated graphics card drivers.
Well sure it doesnt make sense but thats the way it is. Driver or ROM updates hardly ever appear in Apples Software Update. Major graphics card driver updates are only in OS X releases like 10.5.x or 10.6.x. For example, websites reported that Apple together with Valve is working on the drivers and that the updates will be rolled out propably starting with 10.6.5. The percentage of Mac users actively updating their graphics card should be in the 0 - per mille range.
Those are the drivers specifically for Mac Pros with the GF GTX 285.
My current CG toolkit version is 2.1 (February 2009). I could download newer versions but I bet you it wont change a thing.
Do you have a link for the Extension Viewer on NVidias website? Dont find it there. Google has links for v3.31, but thats not NVidia.
Updated to the latest CG kit ... Error for Instanced Ralph:
- Code: Select all
Traceback (most recent call last): File "/Applications/Panda3D_Mare_Ceti/samples/Advanced-Shader-Inputs/Tut-AdvacedShaderInputs.py", line 175, in <module> w = World() File "/Applications/Panda3D_Mare_Ceti/samples/Advanced-Shader-Inputs/Tut-AdvacedShaderInputs.py", line 37, in __init__ "Profile gp4vp is not supported by the hardware." AssertionError: Profile gp4vp is not supported by the hardware.
iMac (2009), Mac OS X.8.1 - MacBookPro (2007), Mac OS X.8.2
@ YouTube
-

Bradamante
-
- Posts: 303
- Joined: Tue Nov 25, 2008 10:58 am
- Location: Leipzig, Germany
by memecss » Sat Aug 07, 2010 2:04 pm
I have no idea why the gp4vp is not supported on Mac. I tested it by myself on my Mac and it seems like the only profile supported is arbvp1.
Here is the program to check if a profile is supported:
- Code: Select all
#include <iostream> #ifdef __APPLE__ # include <OpenGL/gl.h> # include <OpenGL/glu.h> # include <GLUT/glut.h> #else # include <GL/gl.h> # include <GL/glu.h> # include <GL/glut.h> #endif
#include <Cg/cgGL.h>
int main(int argc, char** argv) { glutInit(&argc, argv); glutCreateWindow(argv[0]); CGprofile profile = cgGetProfile(argv[1]);
std::cout << "Cg profile \"" << argv[1] << "\" is " << ((cgGLIsProfileSupported(profile))? "" : "NOT ") << "supported." << std::endl; }
And here is the makefile: - Code: Select all
entry: make main
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin) GL_LIBS = -framework Carbon -framework OpenGL -framework GLUT CG_LIBS = -framework Cg else GL_LIBS = -lGL -lGLU -lglut CG_LIBS = -lCg -lCgGL -lpthread endif
LFLAGS = $(GL_LIBS) $(CG_LIBS)
main: cgIsProfileSupported.cpp g++ $(LFLAGS) -o cgIsProfileSupported cgIsProfileSupported.cpp ### CLEAN ### clean: rm -fv cgIsProfileSupported
you can do something like: make && ./cgIsProfileSupported gp4vp
By the way try to remove the assert at line 36 in Tut-Advanced-Shader-Inputs.py
-
memecss
-
- Posts: 148
- Joined: Mon Jan 25, 2010 8:29 pm
- Location: ETC, Carnegie Mellon University - Pittsburgh
by Tom_L » Fri Aug 20, 2010 9:53 am
Whatever I try, the old way doesn't work for me. I didn't get around to trying a CVS version, so I'm stuck with the 1.7.0 release of panda3d. The manual is very explicit how it should work:
A constant vector that was stored using setShaderInput. Parameter anything would match data supplied by the call setShaderInput("anything", Vec4(x,y,z,w))
but this:
- Code: Select all
test = Vec4(0.5,0.0,0.0,0.0) self.tom.actor.setShaderInput("dt",test) self.tom.actor.setShader(Shader.load("cgshader.sha"))
doesn't work with the shader: - Code: Select all
//Cg /* lesson2.sha */
void vshader(float4 vtx_position : POSITION, float2 vtx_texcoord0 : TEXCOORD0, uniform float4x4 mat_modelproj, out float4 l_position : POSITION, out float2 l_texcoord0 : TEXCOORD0) { l_position= mul(mat_modelproj, vtx_position); l_texcoord0=vtx_texcoord0; }
void fshader(float2 l_texcoord0 : TEXCOORD0, uniform sampler2D tex_0 : TEXUNIT0, uniform float4 dt, out float4 o_color : COLOR) { float4 texColor=tex2D(tex_0, l_texcoord0); o_color= float4(texColor.r,texColor.g,texColor.b,0.0); }
The shader is a modified snippet from the glow sample. this is what I get when trying to run it: - Code: Select all
:gobj(error): cgshader.sha: invalid parameter name (uniform in float4 dt) :gobj(error): Shader encountered an error.
It would be very nice if the manual was a bit more verbose on that topic.
Thanks if anyone can point me to where I went wrong with my code..
-
Tom_L
-
- Posts: 16
- Joined: Wed Aug 18, 2010 1:07 am
- Location: Berlin
by Tom_L » Fri Aug 20, 2010 10:00 am
darn.. just a minute after I posted the above, I found out that adding k_ to the parameter in the shader definition does the trick. Too bad that is not mentioned in the manual..
Also it pisses me off that GLSL is unusable atm, because that's the way I wanted to go. The mentioning of a possible DirectX route struck the same chord with me..
-
Tom_L
-
- Posts: 16
- Joined: Wed Aug 18, 2010 1:07 am
- Location: Berlin
Return to Panda Features in Development
Who is online
Users browsing this forum: No registered users and 0 guests
| | |