• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

No Lighting with Shader

F

FroggestSpirit

Guest
I'm working on a 3D model editor for a game, and currently I have it load a .obj model, and store it into a vertex buffer that gets submitted for drawing. I have a directional light, and an ambiant light that work fine, however, if I create a new shader (the simple passthrough shader) and apply it, it draws the models completely black with no lighting. How can this be fixed?
 
M

MishMash

Guest
Are you using GameMakers built-in lighting system? If so, this itself uses a "default" shader, when you switch to a custom one using shader_set, you loose the default behaviour. This includes a number of effects such as fog, lighting, colouring;

You can find the source for GMs default shaders in:

%appdata%/GameMaker-studio/Shaders

This code can be merged in (as I believe the uniforms used are accessible in any GM shader).
 
F

FroggestSpirit

Guest
Are you using GameMakers built-in lighting system? If so, this itself uses a "default" shader, when you switch to a custom one using shader_set, you loose the default behaviour. This includes a number of effects such as fog, lighting, colouring;

You can find the source for GMs default shaders in:

%appdata%/GameMaker-studio/Shaders

This code can be merged in (as I believe the uniforms used are accessible in any GM shader).
Are they the "FShaderCommon" and "VShaderCommon"? I tried copying them into the Fragment and vertex shader portions, and got some build errors
 
M

MishMash

Guest
Well, by merging, I didn't mean just pasting them in, as they won't necessarily just "plug in".

Rather, you need to extract the important parts of your code and work them into your shader :)

There are 3 main functions:

DoDirLight
DoPointLight

and then the linking function:

DoLighting

Which returns a colour of the lighting.
 
Top