Hi Ive been Experimenting for the past couple weeks with 2DSprite Shader's and now want to try 3DObject Shader's
I used a similar approach to sprites but with Objects instead, but not getting any shaders working.
Is this the correct method??
The shaders are not written by me they are from Cliff Mellangard and his great tutorial on shaders.
unfortunately im finding lots of shaders but no AppGameKit implementation code
AGK Code Used in my Experiments
SetWindowTitle( "test" )
SetWindowSize( 640, 480, 0 )
// set display properties
SetVirtualResolution( 640, 480 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetPrintColor(0,0,0)
//SetSpriteShader(SpriteID,ShaderID)
CreateObjectBox(1,50,50,50)
SetObjectPosition(1,0,0,0)
//Loads the two shaders Vertex and Pixel/Fragment
ShaderID=LoadShader("vertex.vs", "pixel.ps" )
//If this next line is removed it defaults to internal shader
//Link Object to shaders
SetObjectShader(1,ShaderID)
//Positions the camera
SetCameraPosition(1,0,-100,100)
SetCameraLookAt(1,0,0,0,0)
POS#=0
do
//Some code to rotate the cube
POS#=POS#+.5
IF POS#>360 THEN POS#=0
SetObjectRotation(1,pos#,POS#,0)
Print( ScreenFPS() )
Sync()
loop
VERTEX Shader
// combined model/view/projection matrix
uniform mat4 agk_WorldViewProj;
// Per-vertex position information
attribute vec4 position;
// vertex color
uniform vec4 agk_ObjColor;
// Only used to send dat to the pixel/fragment shader
varying vec4 vertex_color;
void main()
{
vertex_color = agk_ObjColor;
gl_Position = agk_WorldViewProj * position;
}
Pixel/Fragment Shader
// gets this from the vertex shader
varying vec4 vertex_color;
void main()
{
gl_FragColor = vertex_color;
}
Thnks Any help Would be great.