Per-object textures for s3o - Page 4

Per-object textures for s3o

Requests for features in the spring code.

Moderator: Moderators

Warlord Zsinj
Imperial Winter Developer
Posts: 3742
Joined: 24 Aug 2004, 08:59

Re: Per-object textures for s3o

Post by Warlord Zsinj »

Oh, we'd need the pieces to behave like normal textures, so reflection and specularity is essential, and team colour is important.

For what we're using it for (that is, spawning dropships when you build things that drop stuff off then disappear), it may be simpler to write a more simplified lua script for spawning and removing those when needed.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Per-object textures for s3o

Post by Pressure Line »

reflect and spec are possible, but i dont know how to get assign the it to the texture map...

INCOMPLETE OR INCOMPREHENSIBLE DOCUMENTATION.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Per-object textures for s3o

Post by jK »

Pressure Line wrote:INCOMPLETE OR INCOMPREHENSIBLE DOCUMENTATION.
3D programming isn't easy, it only gives you some basic functions
and so it is _your_ job to implement stuff like reflections etc.

So it is not an incomplete or incomprehensible documentation, it is:
-> missing knowledge by the reader
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Per-object textures for s3o

Post by Pressure Line »

Code: Select all

gl.Texture

 ( [ number texNum, ] boolean enable | string name ) -> nil | boolean loaded

                          current formats:
 :${opt}:/LuaUI/images/image.png = filename
                             #12 = unitDef 12 buildpic
                           %34:1 = unitDef 34 s3o tex2 (:0->tex1,:1->tex2)
                             !56 = lua generated texture 56
                          $units = 3do textureatlas
                         $shadow = shadowmap
                       $specular = specular cube map
                     $reflection = reflection cube map

                        possible ${opt}'s are:
                             'n' = nearest
                             'l' = linear
                             'a' = aniso
                             'i' = invert
                             'g' = greyed
                             'c' = clamped
                             'b' = border
                             't' = tint (don't know how to use it, sorry)

                example: ":iac:/LuaUI/images/image.png"
where do the '$reflection' etc go then? its not explained.

edit: and is there a way to convert a string like 'fueltanks' to a number?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Per-object textures for s3o

Post by AF »

jK wrote:-> missing knowledge by the reader
caused by
jK wrote:incomplete or incomprehensible documentation
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Per-object textures for s3o

Post by jK »

Pressure Line wrote:where do the '$reflection' etc go then? its not explained.
3D programming doesn't work like that!
There is no checkbox "ActivateReflections".

IT IS YOUR JOB TO IMPLEMENT EVERYTHING!

It is only a plain cubemap, it is you part to render it on your model ...

Pressure Line wrote:edit: and is there a way to convert a string like 'fueltanks' to a number?
There are multiple ways, the cleanest way would be hashes (you have to implement those by your own, spring nor lua doesn't give you a function for that).

AF wrote:
jK wrote:-> missing knowledge by the reader
caused by
jK wrote:incomplete or incomprehensible documentation
I thought you were a programmer, then you should know that it doesn't work like that ...
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Per-object textures for s3o

Post by Pressure Line »

jK wrote:
Pressure Line wrote:where do the '$reflection' etc go then? its not explained.
3D programming doesn't work like that!
There is no checkbox "ActivateReflections".

It is only a plain cubemap, it is you part to render it on your model ...
I am aware of that. perhaps i got confused by the "current formats" line... which from the way i read it, if i put '$reflection' in there somewhere, could read from a (presumably greyscale) texture, to tell the engine "this part here is reflective, this part not so reflective" (ie exactly like the green channel in an s3o's texture2 does)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Per-object textures for s3o

Post by AF »

If your in the middle of a town you've never been in and your told to exit the town, it helps enormously if you can see the edge of town ro have documentation e.g. maps and road signs.

As a programmer you should know that APIs need to be documented. Your point goes both ways.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Per-object textures for s3o

Post by jK »

The Spring Lua API is documented, it is his job to lookup the OpenGL API ...
it won't even help much, coz it is more a technic problem and limits of Spring Lua OpenGL API.
BTW there are only a few code tutorials for 3D programming (most famous is NeHe), so you always have those problems.
And not having code examples means not that it isn't documented, you will find hundreds of papers about 3D programming technics, but they descibe the technic and not the code (similar to all science papers) ;)

And PL, you need to write a shader to get cubemaps working with spring lua opengl (with full opengl you would have different possiblities with combiners). also I already wrote such a glsl shader that copies to 100% the engine unit rendering (except shadows, but those would be easy to implement), it is part of the LUPS cloak fx.

PS: if you want a really bad example for an API wiki check this
Last edited by jK on 15 Jun 2008, 01:39, edited 1 time in total.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Per-object textures for s3o

Post by trepan »

which limitations?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Per-object textures for s3o

Post by jK »

glEnable(GL_TEXTURE_CUBE_MAP_EXT)
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Per-object textures for s3o

Post by trepan »

ah, for the non-shader case; yes, that would be required
you might be able to edit the engine shaders and fill-in
the extra textures though ;-)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Per-object textures for s3o

Post by AF »

hmm, Im glad to hear someone has documented the whole API. Last I heard the phrase "look at the C++ bindings headers" was considered documentation.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Per-object textures for s3o

Post by jK »

trepan wrote:ah, for the non-shader case; yes, that would be required
you might be able to edit the engine shaders and fill-in
the extra textures though ;-)
engine shaders are asm and with lua you can only load glsl ;)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Per-object textures for s3o

Post by FLOZi »

The Spring Lua API is documented
lol.
hmm, Im glad to hear someone has documented the whole API. Last I heard the phrase "look at the C++ bindings headers" was considered documentation.
Indeed.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Per-object textures for s3o

Post by trepan »

trepan:
"...edit the engine shaders and fill-in
the extra textures though ;-)"

jK:
engine shaders are asm and with lua you can only load glsl ;)

Didn't think that "loading edited engine shaders with lua" was
implied by "edit the engine shaders". Maybe it's a translation
problem. Anyways, i'm suggesting that the base engine shaders
could be swapped out, and to use lua to provide the extra textures.
The engine shaders are in springcontent.sdz (in SVN). Looking
back at it now, it probably wouldn't work ;-)
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Per-object textures for s3o

Post by jK »

he renders those unitpieces with 100% lua (w/o your Spring.UnitRendering interface)
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Per-object textures for s3o

Post by trepan »

Maybe he should start using the UnitRendering interface then
(especially seeing as it's more efficient). And on further review,
my little trick of editing the engine shaders would probably
work, but I'd suggest not bothering with it. Supporting archaic
videos card without frag shaders isn't worth the code ;-)
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Per-object textures for s3o

Post by lurker »

Okay, looked a jK's code, and while not horrible complicated, it apparently uses a couple shaders and is incompatible with ATI. This really needs to use the UnitRendering interface if at all feasible.

Assuming I know what the UnitRendering code does. I'm trying my best to read through it.

Edit: To my eyes it looks like you can only set textures per unit, and so have to render parts-all in pure lua, making the whole bunch of code irrelevant. Someone care to explain?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Per-object textures for s3o

Post by jK »

OpenGL supports more than 5 textures (s3o uses: tex1,tex2,specular,reflection,shadow), so you can load multiple other textures (nvidias support upto 16) and use them only on your pieces instead on the whole unit.
Now you can set a DisplayList per piece, so you can set a special uniform or set a special bit to identify your piece in the shader and switch between the textures.

BTW, that's what trepan meant with modifying the engine shader, you would need to switch between those textures in the shader, therefor it needs to be modified. But with lua itself you can only load glsl shaders, so you have to convert the engine shader to glsl or you modify the asm shader in the .sdz (not possible for a mod afaik).
Post Reply

Return to “Feature Requests”