gecko0307 / dagon-tutorials

Code for Dagon engine tutorials
Boost Software License 1.0
9 stars 1 forks source link

Shader #4

Open infinityplusb opened 2 years ago

infinityplusb commented 2 years ago

I was wondering if you had an example of how to use Shaders? I've tried adding an existing one to a new Material, but it doesn't seem to be showing.

infinityplusb commented 2 years ago

As an example, I created

Material rayleighSkyMaterial;

then further down the scene in afterLoad() I added

auto waterShader = New!WaterShader(game.deferredRenderer.gbuffer, assetManager, assetManager);
waterShader.waterColor = Color4f(0.05f, 0.2f, 0.0f, 1.0f);
rayleighSkyMaterial = addMaterial();
rayleighSkyMaterial.shader = waterShader;

then I add the Material like

Entity NPC_1 = addEntity();
NPC_1.drawable = aOBJNPC.mesh;
NPC_1.position = Vector3f(10, 2 ,20 + i * 2);
NPC_1.material = rayleighSkyMaterial;

But it still comes out with a blank material.