Author Topic: what I was doing over the break (materials)  (Read 34456 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
well I've prety much finalised the syntax o the materials table, and I have a working parser for it (and the structs needed to store the data)

you will have to/be able too (depending on how you look at it) define materials that will have diferent properties based on the environment and define multi-pass lighting behavior (usualy this is little more than telling it to use additiive alpha on the aditive lighting passes)

this is the current state of my materials table, keep in mind that if you don't want to take advantage of this you won't have to mess with it at all. and once I get materials working it won't be much longer till I get shaders working, and with the way this is set up it will be almost the most versitile shader/material system posable.

Code: [Select]
$Material: fullbright
#Instance_set{
#Instance{
$Format: ("pos" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: yes
+opp: lessequal
$Alpha: +preset:none
$Cull: 1
$Lighting: no

$Render_Step:
+Opp: arg1
+Arg1:
+type: texture
+value: 0
}Pass
}Instance
}Instance_set


$Material: diffuse
#Instance_set{
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal
$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
}Pass
}Instance
}Instance_set

$Material: glowmapped_diffuse
#Instance_set{
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal
$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
#FLP{
$Render_Step:
+Opp: add
+Arg2:
+type: texture
+value: 1
}FLP
}Pass
}Instance
}Instance_set



$Material: glowmapped_shinemapped
#Instance_set{
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal
$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult*4
+Arg1:
+type: specular
+Arg2:
+type: texture
+value: 2
$Render_Step:
+Opp: mult_add
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
#FLP{
$Render_Step:
+Opp: add
+Arg2:
+type: texture
+value: 1
}FLP
}Pass
}Instance
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal
$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
#FLP{
$Render_Step:
+Opp: add
+Arg2:
+type: texture
+value: 1
}FLP
}Pass
#Pass{
$Z_Buffer:
+read: yes
+Write: no
+opp: lessequal
$Alpha: +preset:add
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult*4
+Arg1:
+type: specular
+Arg2:
+type: texture
+value: 2
}Pass
}Instance
}Instance_set


$Material: shinemapped
#Instance_set{
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal

$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP

$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
}Pass
#Pass{
$Z_Buffer:
+read: yes
+Write: no
+opp: lessequal
$Alpha: +preset:add
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult*4
+Arg1:
+type: specular
+Arg2:
+type: texture
+value: 2
$Render_Step:
+Opp: mult_add
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
}Pass
}Instance
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal

$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP

$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
}Pass
#Pass{
$Z_Buffer:
+read: yes
+Write: no
+opp: lessequal
$Alpha: +preset:add
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult*4
+Arg1:
+type: specular
+Arg2:
+type: texture
+value: 2
}Pass
}Instance
}Instance_set

$Material: multi_pass_shinemapped ;;sometimes you want to force this, like glass
#Instance_set{
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal

$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP

$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
}Pass
#Pass{
$Z_Buffer:
+read: yes
+Write: no
+opp: lessequal
$Alpha: +preset:add
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult*4
+Arg1:
+type: specular
+Arg2:
+type: texture
+value: 2
}Pass
}Instance
}Instance_set


$Material: same_texture_shinemapped ;;uses the defuse texture as the shine texture as well
#Instance_set{
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal

$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP

$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
}Pass
#Pass{
$Z_Buffer:
+read: yes
+Write: no
+opp: lessequal
$Alpha: +preset:add
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult*4
+Arg1:
+type: specular
+Arg2:
+type: texture
+value: 0
}Pass
}Instance
}Instance_set


$Material: 1_texture_glow/shinemapped ;;uses the defuse texture as the shine texture as well
#Instance_set{
#Instance{
$Format: ("pos" "norm" "uv_1")
#Pass{
$Z_Buffer:
+read: yes
+Write: #FLP{yes}FLP #ALP{no}ALP
+opp: lessequal

$Alpha: +preset: #FLP{none}FLP #ALP{add}ALP

$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult
+Arg1:
+type: diffuse
+Arg2:
+type: texture
+value: 0
$Render_Step:
+Opp: add
+Arg2:
+type: texture
+value: 1
}Pass
#Pass{
$Z_Buffer:
+read: yes
+Write: no
+opp: lessequal
$Alpha: +preset:add
$Cull: 1
$Lighting: yes

$Render_Step:
+Opp: mult*4
+Arg1:
+type: specular
+Arg2:
+type: texture
+value: 0
}Pass
}Instance
}Instance_set


each material consists of a name and a number of instinces held within an instince set, each instance is one posable implementation of the material. the instances should be ordered from best implementation to simplest. the first instance that the user's hardware is capable of suporting is the one that is used, all others are ignored.

within the instance, you must declaire what vertex data this instance of the material will use, generaly this will involve position, normal, and one uv coordanant (I have an idea for upgradeing the model format (so that, for example, more than one UV coord can be used) that won't requier rebuilding all exsisting models) ["pos" "norm" "uv_1"], (if you don't need lighting don't includ norm, if you don't need textures don't include uv_1).
after vertex format has been specified, you must define one or more rendering passes, the fewer passes you use the better.
each pass consists of a number of render states (zbuffer, alpha blending, ect...) and up to eight render steps (you must define at least one) were you can define all sorts of behavior such as render arguments, how they will be combind, were they will be output to (current or temp, this is not render target, though I intend to add that functionality eventualy),wich UV coord set to use, and texture wrapping behavior (for example, you could have the texture mirror rather than repete)

one of the unfortunate complexities, is that you will need to define diferent behaviors for diferent environments and lighting modes. this is done via blocks, a block is a section of table that is started by #a_label{ and ended with }a_label. the only two blocks that I currently have in the table are FLP and ALP. FLP is the first lighting pass, generaly this will be the only thing you see, but when more than the maximum lights are needed an additive lighting pass is used to draw the additional data, because you have controle over how the first lighting pass is blended, there is no way to determine how the additional passes are to be drawen, so you will have to define them. generaly anything constant should be only used in the first lighting pass, for example glow mapps should only be drawen once (and my tables reflect this), in most cases you are going to want to use no blending on the first lighting pass, and additive blending one the additive ones (as my tables reflect) if you however should use a subtractive alpha blend you won't want to use addtive blending here, further, you have full access to all alpha blending options (not showen in the table but it's there) so you will need to figure out how your alpha mode should be added.
in addition to lighting modes you will also be able to specify diferent behavior for nebula, normal space, and subspace (and anything else I eventualy think of) useing a similar method.
anything between the brackets of the labels will only be parsed when that option is active, text between the bracets is erased when the option is not present so for anyone with any programming experience it's sort of like an #ifdef #endif block.

now any questions?
this might seem confuseing, but once you get the hang of it it's unbeleiveably easy and super powerful, you will no longer have to rely upon us programmers to develop new rendering modes, (multi-textureing, for example, would be a peice of cake to implement).
« Last Edit: April 16, 2005, 06:07:43 pm by 57 »
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Flipside

  • əp!sd!l£
  • 212
what I was doing over the break (materials)
I really really hope, for the sake of your coding sanity that Instince is not meant to be Instance... :nervous:

That said, abso-bloody-lutely awesome looking stuff. I get the gist of the tables, but it'll probably take a little bit of study to get full idea, but it looks good!

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
Quote
Originally posted by Flipside
I really really hope, for the sake of your coding sanity that Instince is not meant to be Instance... :nervous:


better now? :rolleyes:
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
what I was doing over the break (materials)
:blah:

*Hopes someone understands all that*
-C

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
@WMC's following post.
at what point do you get confused?
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Flipside

  • əp!sd!l£
  • 212
what I was doing over the break (materials)
:D Ignore me :)
« Last Edit: April 17, 2005, 09:59:15 am by 394 »

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
arg timewarp, @flipside:

tis ok, I fixed it :)
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
what I was doing over the break (materials)
Well, how to take a shine map and turn that into an effect, for example. If it means you have to add the specular tag, doesn't that restrict types of maps?

I guess I'm sort of confused by what this does, and how it provides a feature beyond merging everything into one big shinemap, glowmap, normal-map set if coders still have to add 'specular' or 'bump map' or whatever.
-C

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
diffuse and specular are the names of the two lighting colors, when a primitive is being drawen to screen it has two colors available, they are refered to as d0 and d1 or diffuse and specular, because that is typacly what they are used for, but if you have a vertex shader you can put anything you want to in there.

the available options for argument type are:
CURRENT (the result of the last opperation), TEMP(an off screen drawing area), DIFFUSE(a lighting color), SPECULAR(a lighting color), TEXTURE(the color of a texture at the point on the screen you are drawing), and VARIABLE (a variable on the ship). these are basicly all colors. you could for example turn lighting off and specify any two colors you wanted you would have to refer to them as diffuse and specular though.

the reason why this gives such advantage to the modders is becase it basicly gives total controle of the fixed function over to a material designer.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
what I was doing over the break (materials)
So what you're saying is that you could use VARIABLE() to make the glowmaps darken/brighten when a Sathanas charges a beam cannon?
-C

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
more or less (variable is going to requier a coder sets up a variable for it. you have to pick from a bunch of predefined variables)
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Taristin

  • Snipes
  • 213
  • BlueScalie
    • Skelkwank Shipyards
what I was doing over the break (materials)
Ugh. Can't we just have something simple in a pof editer to do this for us? I'm starting to dread this system.

If it was like the pic below, I'd be more inclined to use it.
Freelance Modeler | Amateur Artist

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
the end result will be something like that, this is how those effects will be implemented, not accessed.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

  
what I was doing over the break (materials)
I didn't understand anything you guys said, but since it's SCP, it must be ****ing fantastic. Way to go Bobb.
Carpe Diem Poste Crastinus

"When life gives you lemons...
Blind people with them..."

"Yah, dude, penises rock." Turambar

FUKOOOOV!

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
I've got it drawing now, I still have a lot of work to do, but when I get done everything involved with drawing a ship is going to be so much cleaner it isn't even funny. I just replaced about ten pages worth of realy ugly code with about half a page. I am haveing to completely rerwite all vertex buffer drawing and light management code. I will atempt to et the OGL functions myself, for once, once I have everything in d3d done, there will be two realy long boreing functions and a whole bunch of small boring ones.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
what I was doing over the break (materials)
Awesome. :)

Will you be able to work in some way of using Display Lists?
-C

 

Offline Flipside

  • əp!sd!l£
  • 212
what I was doing over the break (materials)
This is sounding really really promising, anything that optimises texture drawing code to that degree may well have a very good impact on rendering times :D

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
this is actualy what I wanted the display list code for, I'm already useing it (well the d3d side of it at least). the only major thing I need realy to get OGL working is a function that can take an enum and a value and set things like z_buffer mode, and alpha blending states, and a seperate one for manageing TMUs in a similar way. I also need to get a bunch of smaller functions made that will do things like set and activate lights, a vertex buffer renderer that doesn't do anything other than rendering buffers (ie no state changeing), but I'm going to wait untill I have d3d done because I seem to keep changeing little things.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Trivial Psychic

  • 212
  • Snoop Junkie
what I was doing over the break (materials)
When this is ready, do you expect it to overcome the ATI-Cat4.4+ D3D Shinemap bug?
The Trivial Psychic Strikes Again!

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what I was doing over the break (materials)
not imediately, but this is the last thing I have to get working before I get started on shaders, and that will not only fix the cat bug, but it will actualy allow far superior quality. man I can't wait untill I get a per pixel lighting model working in FSO.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together