Page 1 of 1

would this work in Love2D?

Posted: Thu Oct 09, 2014 7:07 pm
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;
}

Re: would this work in Love2D?

Posted: Thu Oct 09, 2014 8:38 pm
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;
}