Using GLSL Shaders in Dage

Introduction

As trying to make Dage work as versatile as possible, Dage supports OpenGL Shader Language.

Using Shaders in Dage is pretty straight-forward.

Using Shaders

First you need to load shader vertex and fragment files.

Shader01 = TShader.Create();  --Creating new shader
Shader01.LoadVertAndFrag('Shaders/Shader.Vert', 'Shaders/Shader.Frag'); -- Loading the Vert and Frag files
Shader01.Enabled = 1; -- Enabling the shader

Then you need to apply the shader to the material. Either via TMaterials.ApplyShader or TMesh.ApplyShader. TMesh's uses the same method as TMaterials's, but it iterates through all materials the mesh is using.

Mesh01 = TMesh.Create(); -- Creating testing scene
Mesh01.Load('Models/Teapot.3ds'); -- Loading sample teapot model
Mesh01.ApplyShader(Shader01.ID); -- Change all 3DS materials with this shader

Dage sends various textures to shader. It sends the materials initial base (diffuse) texture as “basetex” variable. If it finds “materialname_BUMPMAP” then it sends it as bumptex. Same goes for “materialname_SPECMAP” as “spectex”.

Dage also sends camera and light positions, but not as variables.

Demo

Links

Back to top
shaders/advanced.txt · Last modified: 2010/01/25 18:17 by rahakasvi