Allows custom vertex shaders. draw_3d now requires normals to be passed to it, or an empty vector if you aren't using them.
Precision qualifiers are gone. Shaders are always high precision now. shader_load looks like this:
number my_shader_obj
shader_load my_shader_obj "vertex_name" "fragment_name"
To load the default vertex/fragment shader, pass "" an empty string.
Input and output names for GLSL:
attribute vec3 in_position;
attribute vec3 in_normal;
attribute vec2 in_texcoord;
attribute vec4 in_colour;
varying vec2 texcoord;
varying vec4 colour;
For HLSL:
struct VS_INPUT
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float2 TexCoord : TEXCOORD0;
float4 Colour : TEXCOORD1;
};
struct VS_OUTPUT
{
float4 Position : POSITION0;
float2 TexCoord : TEXCOORD0;
float4 Colour : COLOR0;
};
I made a vertex shader example in git. This will be in 2.2.10. It's a lighting example:
Have this one in there too
It works with model animation now also. I previously wasn't transforming normals along with vertices for animation. I will release 2.2.10 now.
I will upload 2.2.11 sometime which has this example and fixes matrix multiply which might be crashing for some people.
This is the code for the last video I posted.
number model
model_load model "zeus.x"
model_set_animation model "ArmatureAction"
number shader
shader_load shader "lit_3d_vertex" "lit_3d_fragment"
set_3d
vector start_light_pos light_pos
vector_init start_light_pos 0 0 0 1
vector_init light_pos 0 0 0
vector m
= m (identity 4)
function draw
{
clear 100 100 255
shader_use shader
shader_set_float_vector shader "light_pos" light_pos
model_draw model 255 255 255 255
}
function run
{
identity_3d
translate_3d 0 -0.5 -5
scale_3d 0.25 0.25 0.25
= m (mul m (rotate (/ PI 120) 0 1 0))
= light_pos (mul m (translate 1000 0 0) start_light_pos)
vector_erase light_pos 3
}