Shaders... Am I missing something?

Shaders... Am I missing something?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
jamesster
Posts: 3
Joined: 22 Apr 2013, 23:37

Shaders... Am I missing something?

Post by jamesster »

I've been toying around with the Spring engine for the last couple of weeks, and for the most part the online documentation has been able to answer my questions without any major problems. Well, except for this.

I'm in need of a different shader than the default one for what I'm working on. Specifically, I need proper translucency - the default shader only allows for geometry to either be totally solid or invisible. I need to be able to make some parts of a unit only partially transparent; for example, one unit is a UFO divided into four quarter sections, two of which should be tinted to the team color but partially see-through.

So, I went to the wiki, but aside from a link to a non-existent page titled "Custom Unit Shaders" ("Normal mapping and more"), I wasn't able to find much. I did notice this on the unit textures page, though:
Blue values do not have a use, in the standard ARB shader. There are variants of the ARB shader available, where the blue value does various things. These derivative versions of Spring's ARB shader code are Open Source, so please ask around if you want to know more about these, people will be happy to share them with you.
So I signed up on the forum today and did some searching, but I still have yet to come up with any relevant results. Am I missing something here, or are these ARB shader variants just somewhat elusive?

Thanks!
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Shaders... Am I missing something?

Post by smoth »

there is a lot of talk about it but the problem comes in when you have to handle sorting I believe is the term that is bantered about. There are various discussions spread in various threads. Some attempts but ultimately failure to produce an acceptable solution.

Is it that you are looking for a way to set a shader on a unit, as in you could write it if you had the know how? Or are you inquiring if we have already built one?

I am not a very good person to tell you one direction or another beyond JK is the best engine dev to talk to about shader related things. Everyone else I would point you to is MIA or gone. There have been various attempts either hacky or ultimately bugged. So I would love to see you solve the problem sadly my gl-fu is level infant and I cannot help you in that regard but maybe I can point you to some resources.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Shaders... Am I missing something?

Post by CarRepairer »

User avatar
jamesster
Posts: 3
Joined: 22 Apr 2013, 23:37

Re: Shaders... Am I missing something?

Post by jamesster »

smoth wrote:there is a lot of talk about it but the problem comes in when you have to handle sorting I believe is the term that is bantered about. There are various discussions spread in various threads. Some attempts but ultimately failure to produce an acceptable solution.

Is it that you are looking for a way to set a shader on a unit, as in you could write it if you had the know how? Or are you inquiring if we have already built one?

I am not a very good person to tell you one direction or another beyond JK is the best engine dev to talk to about shader related things. Everyone else I would point you to is MIA or gone. There have been various attempts either hacky or ultimately bugged. So I would love to see you solve the problem sadly my gl-fu is level infant and I cannot help you in that regard but maybe I can point you to some resources.
Ah, I've run into issues with transparency sorting in other real time 3D stuff before... It's been the cause of several headaches. The screenshot there shows two objects with a transparency shader applied in Unity3D, albeit set so low they appear solid - the pole actually goes through the hole of the hoop, but because its origin is closer to the camera it's being rendered entirely on top of it. And when I poked around online for solutions, I ended up finding that there really is no proper solution. :?

And yeah, I was seeing if one already existed - I've never tried creating shaders before, so I honestly have no idea if it's something I can really do well or not.
CarRepairer wrote:Join the discussion here http://springrts.com/phpbb/viewtopic.ph ... 46#p539846
Huh, I thought for sure I'd read all the way through that topic - I guess not. Thanks for the link, lots of useful info here.

I suppose it won't kill me to make the transparent bits solid - maybe I'll do something with the diffuse texture and glow to make them appear different, somehow. I'll fiddle around with it and see what looks good.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Shaders... Am I missing something?

Post by smoth »

if you don't mind me asking, what area of the world are you in and do you have skype or mumble?
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Shaders... Am I missing something?

Post by SinbadEV »

The engine uses the Alpha Channel of Texture 2 to determine transparency and it is "1 bit" which means either "transparent" or "not transparent"... what this means is that you would need to write custom Lua GL instructions to manually override the engine functionality and draw your transparent elements ( http://springrts.com/wiki/Lua_OpenGL_Api ) not a "shader". I am nominally sure that "transparency" is outside the scope of a "shader" anyways, just by definition.
User avatar
jamesster
Posts: 3
Joined: 22 Apr 2013, 23:37

Re: Shaders... Am I missing something?

Post by jamesster »

smoth wrote:if you don't mind me asking, what area of the world are you in and do you have skype or mumble?
The USA, and yeah, I'm on Skype.
SinbadEV wrote:The engine uses the Alpha Channel of Texture 2 to determine transparency and it is "1 bit" which means either "transparent" or "not transparent"... what this means is that you would need to write custom Lua GL instructions to manually override the engine functionality and draw your transparent elements ( http://springrts.com/wiki/Lua_OpenGL_Api ) not a "shader". I am nominally sure that "transparency" is outside the scope of a "shader" anyways, just by definition.
So it's the engine itself that handles that? Hm, that's interesting - a bit different from how shaders have worked in other engines/programs I've used.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Shaders... Am I missing something?

Post by FLOZi »

Welcome to Spring. Rule #1; Sinbad doesn't really know what he's talking about. :P

Smoth is quite correct, transparency in itself is doable the issue is with sorting the render order so that transparency appears correctly under all circumstances; something the engine does not (and will not) do, and lua has no control over.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Shaders... Am I missing something?

Post by SinbadEV »

FLOZi wrote:Welcome to Spring. Rule #1; Sinbad doesn't really know what he's talking about. :P
FRAK... I always forget Rule #1. Sorry, it's just that I sound so darn convincing.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Shaders... Am I missing something?

Post by SpliFF »

@jamesster: As you seem to have guessed your answer is there in the Wikipedia article. True 3D translucency requires ray tracing. OpenGL fake translucency requires a clever sorting of rendered polygons relative to the camera. There is no generic code that makes a sort clever and all known algorigthms present suboptimal results at one end or massive slowdown at the other. Engines that do this type of sorting pay a price somewhere as FPS-loss or content/camera-restrictions and/or code/content complexity.

In other words the engines where you see a lot of this sort of thing tend to be commercial FPS generally limited to indoor scenes or cases where the modellers/map makers are aware of the issues and compensate using hacks or engine flags to make it work.

A lot of the time things that appear to be translucent may in fact be tricks (like pre-rendering the translucency to a texture or only being able to view the object from a distance or at a specific angle).

Hopefully one day Intel will release the ray tracing GPUs they keep bragging about and these silly tricks will become a thing of the past but don't hold your breath.
Post Reply

Return to “Game Development”