BlitzMax 3D Module Shaders

Miscellaneous Forums/General Discussion/BlitzMax 3D Module Shaders

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.


'Create a simple texel lookup 'expression'...
Local texel:TShExpr=ShTex( ShAttrib( "texcoords" ),ShParam( "Texture",SHTEX2D ) )

'...and use it to create a brush shader...
Local shader:TShader=CreateBrushShader( texel )

'set a shader parameter...
shader.SetParam "Texture",LoadTexture( "image.png" )

TShExpr here stands for 'shader expression', and ShTex, ShAttrib and ShParam all return 'TShExpr' objects. Here are some other kinds of shader expressions...

ShAdd:TShExpr( lhs:TShExpr,rhs:TShExpr ) 'add 2 values
ShSub:TShExpr( lhs:TShExpr,rhs:TShExpr ) 'subtract 2 values
ShMul:TShExpr( lhs:TShExpr,rhs:TShExpr ) 'multiply 2 values
ShTex:TShExpr( coords:TShExpr,texture:TShExpr ) 'look up a texel
ShParam:TShExpr( name$,format ) 'shader parameter
ShAttrib:TShExpr( name$,format ) 'shader attribute



Will this be handled internally, abstracted from us or will we have to write programs like this? It seems a tad against the grain of b3d style of doing things.

I think you should write an abstraction layer to glsl/hlsl that is like a basic shader. Then you can do things like,

Coord = Transform3D()
Coord.Rgb = LightCoord( LightX,LightY )

etc.

make it real easy for us to create our own shaders from scratch while still using your plugin bits of shader code that mimic the fixed function pipeline.