I'm really struggling with what should be a simple task. I obviously just can't get my head around it. All I want to do is pass a float value to a material/shader from my code. I see other examples doing it and it is a very common task. But I just cannot get it to work. I've written a very simple test material just to try and get this working. Here is my material. Code: Select all vertex_...
Sorry, I do actually have the uniform keyword in the shader. I'm not sure what happen when I copied and pasted to the forum. I must of chopped it off. It is actually there. The line reads. Code: Select all uniform float test, But anyway, that makes no difference. I receive the error with or without the uniform keyword.
Ah I think I see what it is. You aren't using the value in the code (Cg) so the optimizer is stripping it out and therefore it doesn't show up in the constant table. Multiply something by it so that it doesn't get optimized out and try again.
Yes you were right. I didn't realise that would happen. Thank you so much! I been pulling my hair out for hours... Couple more questions... save starting a new thread. 1. Can I set the value of "test" differently for different entities. I mean if I have 10 objects and I set each object to use this material. If I set "test" each time when assigning the material to an entity, will each entity use...
1) The Entity marries the Mesh to the Material (it's a Mesh instance), so the answer is yes. 2) No. That's how the pipeline works -- vertex shaders put vertices in the world, and fragments (pixels) occur as the triangle from those verts is rasterized into the framebuffer (assuming the fragment passes the depth test, the fragment shader will run). The fragment shader works on fragments (pixels), ...
1. OK, I was just trying this out before you replied. What I noticed is that once I set the value it seems to be fixed to that value forever. If I create a second entity and set it to the same material, but set the "test" value to something different, the second entity still has the same "test" value that I set for the first entity. I tried cloning the material, but that made no difference. This...
softock wrote: 2. Sorry I meant the vertex program, not the fragment program. Got my wires crossed. Is there anyway in the vertex program to know what vertex I'm working with? Beyond adding some form of additional vertex attribute, no. Why don't you explain what it is you intend to do? It would be easier than guessing and more helpful to you in the long run. As for the material -- I ...
Sorry I didn't want to swamp you with details, but OK, here is what I'm trying to do. I have a square mesh made up of 4 vertices. I'm passing this mesh as an entity to PagedGeometry so I am rendering dozens of them. Before I pass it to PagedGeometry however I set the material on it and want to set some values that will effect the positioning of the vertices in the mesh. I want to do this on a ...
OK well first, "uniform" means just what it says -- that value does not change during the render operation. So all of the vertices you are rendering in a given primitive will all use the same values in a uniform constant. If you want varying data per vertex, you need to add that to the vertex buffer, not the float constants. And of course at that point, you may as well just do whatever it was you...
Here is what I want to do http://www.ogre3d.org/forums/viewtopic.php?f=5&t=5 3226 That is actually my post, but I forgot my password for the account and haven't been able to recover it, so I have created a new account. I have a terrain that I'm trying to draw a footpath on. The user can place the footpath wherever they like. I'm using quads as it works well with the grid of the terrain. I ...
OK, you've convinced me. I'm going to give it a try. Since the footpath layout won't change every frame, I'm thinking that I will only need to rebuild the vertex buffer when it changes. The user won't be laying down footpaths all time, so I guess that shouldn't be a problem. I hope there won't be a large performance hit during the frame while the buffer is being rebuilt (i.e. a slight pause). The only thing...
Well, most quads are not planar -- that's why we rasterize triangles, because since they are the only geometric 3D primitive guaranteed to be planar, you can make lots of optimizations in the rasterizing process. Again, though, you can't do what you mention with uniform constants (unless you want to render one decal per pass) -- you still need to access the heightfield data on the CPU to figure out how much to adjust the verts, and...
@ causticgraphics Saw news article at @ arstechnica .... @ causticgraphics Saw news article at @ arstechnica . Questions: GI models? Material shader? Stochastic Sampling? Recursion depth? Normal Map? 5:24 AM Mar 24th from TweetDeck
Thread profile page for "Setting Material/Shader Parameters" on http://www.ogre3d.org.
This report page is a snippet summary view from a single thread "Setting Material/Shader Parameters", located on the Message Board at http://www.ogre3d.org.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity