🔒 Locked
GLSL fixed function shader needed!
Advertisement
Original Post
Hi all, i need a GLSL vertex/[fragment] shader that has all the features of the fixed function pipeline, without extra uniforms. I just like to modify the vertex position to program my hardware skinning and dont like to mess with all the light calculations. Is already something like that out there or shall i go on downloading ShaderGen? Thanks a lot for any help!!
Hi.
I can't remember seeing any GLSL implementation of the fixed function pipeline, except for in 3D Labs' ShaderGen software's screenshot. That doesn't mean there isn't one, I just havn't found it. Here's a CG implementation from NVIDIA, you could try that.
http://developer.nvidia.com/object/cg_fixed_function.html
What do you mean by extra uniforms? You need to use uniforms at least for telling the GPU which textures to use, GLSL has no built-in texture state (unfortunately).
Deavik: Even tho fixed function is not constant, it can quite easily be implemented with GLSL. GLSL's got if's and for's and a nice built-in state (which lacks textures, tho).
-Riku
I can't remember seeing any GLSL implementation of the fixed function pipeline, except for in 3D Labs' ShaderGen software's screenshot. That doesn't mean there isn't one, I just havn't found it. Here's a CG implementation from NVIDIA, you could try that.
http://developer.nvidia.com/object/cg_fixed_function.html
What do you mean by extra uniforms? You need to use uniforms at least for telling the GPU which textures to use, GLSL has no built-in texture state (unfortunately).
Deavik: Even tho fixed function is not constant, it can quite easily be implemented with GLSL. GLSL's got if's and for's and a nice built-in state (which lacks textures, tho).
-Riku
Quote:
Original post by RichardoX
Deavik: Even tho fixed function is not constant, it can quite easily be implemented with GLSL. GLSL's got if's and for's and a nice built-in state (which lacks textures, tho).
But you covered that with your previous point, the OP doesn't want extra uniforms :). And anyway, are the loops really that good on current hardware? It would be faster to generate the shaders you need at runtime, IMO. And that puts us back to having a ton of shaders (or lots of preprocessor directives) which the OP doesn't want.
Unfortunately, you can't avoid "extra uniforms" if you want texturing. IMO, texture bindings could be in the built-in uniform state. I guess Draghi does not want to change his CPU side rendering code, just make a minor tweak to the shader functionality.
I don't know exactly how is the fixed functionality implemented, but I would guess that it is "just a shader" that is set some kind of default. The fixed functionality has to do the similar if's and loops in the GPU and I can't see why it would be any worse to do these conditionals, etc in a non-default shader. However, I think that it's not necessarily bad to have loops and if's in your shaders if you're trying to make a general-purpose all-around shader. It should be "fast enough". It may at some point prove to be worth writing multiple dedicated special shaders instead of one monolithic shader program.
I may be wrong about how the fixed pipeline actually works. Has anyone made any benchmarks in fixed function/shader rendering?
If I remember correctly, everything but the texture bindings can be accessed through the GLSL built-in uniform state, so pretty much everything except textures can be done without modifications to the CPU side code.
Draghi, what exactly are you trying to do? Your question sounds like whatever you're doing, there might be a better way of doing it than hacking shaders.
-Riku
I don't know exactly how is the fixed functionality implemented, but I would guess that it is "just a shader" that is set some kind of default. The fixed functionality has to do the similar if's and loops in the GPU and I can't see why it would be any worse to do these conditionals, etc in a non-default shader. However, I think that it's not necessarily bad to have loops and if's in your shaders if you're trying to make a general-purpose all-around shader. It should be "fast enough". It may at some point prove to be worth writing multiple dedicated special shaders instead of one monolithic shader program.
I may be wrong about how the fixed pipeline actually works. Has anyone made any benchmarks in fixed function/shader rendering?
If I remember correctly, everything but the texture bindings can be accessed through the GLSL built-in uniform state, so pretty much everything except textures can be done without modifications to the CPU side code.
Draghi, what exactly are you trying to do? Your question sounds like whatever you're doing, there might be a better way of doing it than hacking shaders.
-Riku
First, i want to thank all of you for trying to help me!
@zedzeek: thanks ill check that
@devaik: youre right! i dont want additional (extra) uniforms. But the shader hasnt to be exactly like the fixed function pipeline. it just has to support all counts and types of light, textures on and off and it should look nice :)
@RichardoX: A bit of all, the shader should run like normal when no additional uniforms are given. I only want to add some vertex position calculations.
AFAIK the minor difference between a shader and the fixed function pipeline is that the pipeline is hard wired, while the shader is completely been calculated on the gpu. So the pipeline should win the benchmark ;)
My problem: I made an engine that runs in a plugin and renders single objects within the main program. OpenGL gets initialized in the main program. Lights and textures are set in the main program as well. So my objects need to stay in the right light when they are put in the main program environment. The objects are bone animated ones and i cant get enough performance with the current software skinning. To implement a hardware skinning i need to calculate the vertex positions within the gpu. I want to do that without destroying the lights and textures.
To prevent me swiching the shader on and off for every single object that is being rendered, it would be nice when the shader runs without additional uniforms and looks like the fixed function pipeline. So i can leave the shader swiched on for the main program too. But this isnt a must.
@zedzeek: thanks ill check that
@devaik: youre right! i dont want additional (extra) uniforms. But the shader hasnt to be exactly like the fixed function pipeline. it just has to support all counts and types of light, textures on and off and it should look nice :)
@RichardoX: A bit of all, the shader should run like normal when no additional uniforms are given. I only want to add some vertex position calculations.
AFAIK the minor difference between a shader and the fixed function pipeline is that the pipeline is hard wired, while the shader is completely been calculated on the gpu. So the pipeline should win the benchmark ;)
My problem: I made an engine that runs in a plugin and renders single objects within the main program. OpenGL gets initialized in the main program. Lights and textures are set in the main program as well. So my objects need to stay in the right light when they are put in the main program environment. The objects are bone animated ones and i cant get enough performance with the current software skinning. To implement a hardware skinning i need to calculate the vertex positions within the gpu. I want to do that without destroying the lights and textures.
To prevent me swiching the shader on and off for every single object that is being rendered, it would be nice when the shader runs without additional uniforms and looks like the fixed function pipeline. So i can leave the shader swiched on for the main program too. But this isnt a must.
Quote:
Original post by Draghi
AFAIK the minor difference between a shader and the fixed function pipeline is that the pipeline is hard wired, while the shader is completely been calculated on the gpu. So the pipeline should win the benchmark ;)
bzzzzt! wrong.
Hardware hasn't had a fixed function pipeline for years, ATI haven't had one since the R300 core and the last NV core to have one was the GFFX (a strange hybrid piece of technology). Everything is shaders now, the FFP is just emulated with driver written shaders.
Quote:
Original post by Draghi
thanks for the tip! but the downloadable shader collection didnt contain the fixed function mimic shader.. or i wasnt able to find it in the list :)
Sorry about that. My previous post was made from work and they block zip files so I couldn't check.
As MARS_999 says, get a copy of the Orange Book. It's very good.
"I just like to modify the vertex position to program my hardware skinning and dont like to mess with all the light calculations."
What do you mean by that? You mean move the vertices around? or resize them? AFAIK if you resize them you will have to recalculate the normals for each vertex. But I am assuming you just want to use OpenGL's built in lighting model for this mesh? All the data you send to OpenGL on the CPU side for lighting is available to you in GLSL with built in variables. So you can calculate the same OpenGL light model if you want...
What do you mean by that? You mean move the vertices around? or resize them? AFAIK if you resize them you will have to recalculate the normals for each vertex. But I am assuming you just want to use OpenGL's built in lighting model for this mesh? All the data you send to OpenGL on the CPU side for lighting is available to you in GLSL with built in variables. So you can calculate the same OpenGL light model if you want...
Quote:
Original post by MARS_999
AFAIK if you resize them you will have to recalculate the normals for each vertex.
Correct, thats also the case on rotations :) but its not a big deal..
With the help of ShaderGen a made an own fixed function mimic shader that does all light types depending on the given attributes. Fog is also included. The effects look like the fixed function to 99%. The vertex shader is 240 lines now and thats already pretty close to the limit.
But as you mentioned, i was not able to find out if a light or texture or fog is enabled or not within the shader! :(
Theres no way to find that out without additional uniforms huh? I really cant understand why they didnt add a simple 'bool active' to the parameters.
Quote:
Original post by Draghi
But as you mentioned, i was not able to find out if a light or texture or fog is enabled or not within the shader! :(
Why wouldn't you know ahead of time if you want to use fog, textures, or lighting before the shader is called? And if you know ahead of time you want these fx's then you can either
1. add in bool values to turn on/off these fx's by sending a bool value to the shaders (not sure but you may need a newer card to do a lot of if/else statements)
2. or you can code seperate shaders one for each condition you need and call that one in the cpu side to coincide with what you need.
unless I am missing the point this is a few ways to do it...
Quote:
Original post by Draghi
My problem: I made an engine that runs in a plugin and renders single objects within the main program. OpenGL gets initialized in the main program. Lights and textures are set in the main program as well. So my objects need to stay in the right light when they are put in the main program environment.
To prevent me swiching the shader on and off for every single object that is being rendered, it would be nice when the shader runs without additional uniforms and looks like the fixed function pipeline. So i can leave the shader swiched on for the main program too. But this isnt a must.
I have no access to the main program. :/ When I swich the shader on and off only for my objects, i could do it with bool uniforms.. but that would be less effective.
you might not have acccess to the main program but you can still query opengl for the current state of things and select your shader based on that.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement