-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0076c3f
commit 3831b72
Showing
6 changed files
with
166 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
precision highp float; | ||
in vec2 vTextureCoord; | ||
out vec4 finalColor; | ||
|
||
uniform sampler2D uSampler; | ||
uniform sampler2D uMapTexture; | ||
uniform vec3 uColor; | ||
uniform float uAlpha; | ||
uniform vec2 uDimensions; | ||
|
||
uniform vec4 uInputSize; | ||
|
||
void main() { | ||
vec4 diffuseColor = texture(uSampler, vTextureCoord); | ||
vec2 lightCoord = (vTextureCoord * uInputSize.xy) / uDimensions; | ||
vec4 light = texture(uMapTexture, lightCoord); | ||
vec3 ambient = uColor.rgb * uAlpha; | ||
vec3 intensity = ambient + light.rgb; | ||
vec3 color = diffuseColor.rgb * intensity; | ||
finalColor = vec4(color, diffuseColor.a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
struct SimpleLightmapUniforms { | ||
uColor: vec3<f32>, | ||
uAlpha: f32, | ||
uDimensions: vec2<f32>, | ||
}; | ||
|
||
struct GlobalFilterUniforms { | ||
uInputSize:vec4<f32>, | ||
uInputPixel:vec4<f32>, | ||
uInputClamp:vec4<f32>, | ||
uOutputFrame:vec4<f32>, | ||
uGlobalFrame:vec4<f32>, | ||
uOutputTexture:vec4<f32>, | ||
}; | ||
|
||
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms; | ||
|
||
@group(0) @binding(1) var uSampler: texture_2d<f32>; | ||
@group(1) @binding(0) var<uniform> simpleLightmapUniforms : SimpleLightmapUniforms; | ||
@group(1) @binding(1) var uMapTexture: texture_2d<f32>; | ||
|
||
@fragment | ||
fn mainFragment( | ||
@builtin(position) position: vec4<f32>, | ||
@location(0) uv : vec2<f32>, | ||
) -> @location(0) vec4<f32> { | ||
let uColor = simpleLightmapUniforms.uColor; | ||
let uAlpha = simpleLightmapUniforms.uAlpha; | ||
let uDimensions = simpleLightmapUniforms.uDimensions; | ||
|
||
let diffuseColor: vec4<f32> = textureSample(uSampler, uSampler, uv); | ||
let lightCoord: vec2<f32> = (uv * gfu.uInputSize.xy) / simpleLightmapUniforms.uDimensions; | ||
let light: vec4<f32> = textureSample(uMapTexture, uSampler, position); | ||
let ambient: vec3<f32> = uColor * uAlpha; | ||
let intensity: vec3<f32> = ambient + light.rgb; | ||
let finalColor: vec3<f32> = diffuseColor.rgb * intensity; | ||
return vec4<f32>(finalColor, diffuseColor.a); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
export default function () | ||
{ | ||
this.addFilter('SimpleLightmapFilter', { | ||
args: [this.resources.lightmap, 0x666666], | ||
args: { lightMap: this.resources.lightmap, color: 0x666666 }, | ||
oncreate(folder) | ||
{ | ||
folder.addColor(this, 'color'); | ||
folder.add(this, 'alpha', 0, 1); | ||
|
||
this._noop = () => {}; | ||
folder.add(this, '_noop').name('<img src="./images/lightmap.png" width="220" height="13">'); | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters