General discussion about LÖVE, Lua, game development, puns, and unicorns.
-
badfitz66
- Prole
- Posts: 30
- Joined: Sat Jun 07, 2014 10:30 pm
Post
by badfitz66 »
with a bit of change of course. This is a basic fragment shader using GLSL
Code: Select all
#version 330
in vec2 texCoord0;
out vec4 fragColor;
uniform vec3 baseColor;
uniform sampler2D sampler;
uniform vec3 ambientLight;
struct BaseLight
{
vec3 color;
float intensity;
};
struct DirectionalLight
{
BaseLight base;
vec3 direction;
};
vec4 calcLight(BaseLight base, vec3 direction, vec3 normal)
{
}
void main()
{
vec4 totalLight = vec4(ambientLight,1);
vec4 color = vec4(baseColor, 1);
vec4 textureColor = texture(sampler, texCoord0.xy);
if(textureColor != vec4(0,0,0,0))
color *= textureColor;
fragColor = color * totalLight;
}
-
slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
-
Contact:
Post
by slime »
LÖVE's shaders are based on GLSL 1.20 (and they use a custom entry function), so that'd work in LÖVE with some tweaks:
Code: Select all
uniform vec3 baseColor;
uniform sampler2D sampler;
uniform vec3 ambientLight;
struct BaseLight
{
vec3 color;
float intensity;
};
struct DirectionalLight
{
BaseLight base;
vec3 direction;
};
vec4 calcLight(BaseLight base, vec3 direction, vec3 normal)
{
// ...
}
vec4 effect(vec4 vcolor, Image tex, vec2 texcoords, vec2 pixcoords)
{
vec4 totalLight = vec4(ambientLight, 1.0);
vec4 color = vec4(baseColor, 1.0);
vec4 textureColor = Texel(tex, texcoords);
// ...
return color * totalLight;
}
Users browsing this forum: Google [Bot] and 4 guests