shaderlib: Implement place_texture() and provide an example, replace mix.gdshader example; implements #17
This commit is contained in:
parent
8b5a1cc37d
commit
1aa217776c
8 changed files with 48 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
|||
|
||||
# Example Images
|
||||
|
||||
- swamp.jpg by [clfr21](https://pixabay.com/de/users/clfr21-6530007/)
|
||||
- overlay.jpg by [Humusak](https://pixabay.com/de/users/humusak-137455/)
|
||||
- swamp.jpg by [clfr21 on Pixabay](https://pixabay.com/de/users/clfr21-6530007/)
|
||||
- grass.png by [GDJ on Pixabay](https://pixabay.com/users/gdj-1086657/)
|
||||
|
|
BIN
examples/grass.png
Normal file
BIN
examples/grass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 150 KiB |
|
@ -2,16 +2,16 @@
|
|||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://8101nnc8cx4o"
|
||||
path="res://.godot/imported/overlay.jpg-b6d13e0def59877969c9eda02fa4244e.ctex"
|
||||
uid="uid://c1mh1d2f3u4ju"
|
||||
path="res://.godot/imported/grass.png-30af7213ed2d70b810b4ae788314a9e9.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://examples/overlay.jpg"
|
||||
dest_files=["res://.godot/imported/overlay.jpg-b6d13e0def59877969c9eda02fa4244e.ctex"]
|
||||
source_file="res://examples/grass.png"
|
||||
dest_files=["res://.godot/imported/grass.png-30af7213ed2d70b810b4ae788314a9e9.ctex"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
//!load ./swamp.jpg
|
||||
|
||||
//!load+ img2 ./overlay.jpg
|
||||
uniform sampler2D img2: repeat_enable, filter_nearest;
|
||||
|
||||
void fragment() {
|
||||
COLOR = mix(COLOR, texture(img2, UV), .2);
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 896 KiB |
14
examples/place_texture.gdshader
Normal file
14
examples/place_texture.gdshader
Normal file
|
@ -0,0 +1,14 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
#include "res://shaderlib/transform.gdshaderinc"
|
||||
|
||||
//!load ./swamp.jpg
|
||||
//!load+ img2 ./grass.png
|
||||
|
||||
uniform sampler2D img2: repeat_disable, filter_nearest;
|
||||
|
||||
void fragment() {
|
||||
vec4 grass = place_texture(img2, UV, TEXTURE_PIXEL_SIZE, vec2(0, .47), vec2(1));
|
||||
grass.rgb += (vec3(0.03, 0.07, 0.11) - ((UV.y - .8) * 0.15)); // color correction
|
||||
COLOR.rgb = mix(COLOR.rgb, grass.rgb, grass.a);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue