would this work in Love2D?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
badfitz66
Prole
Posts: 30
Joined: Sat Jun 07, 2014 10:30 pm

would this work in Love2D?

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;
}
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: would this work in Love2D?

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;
}
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests