demos: shadertoy in material
parent
c55305c031
commit
594b8a0136
|
@ -38,10 +38,21 @@ int main() {
|
|||
// load model
|
||||
model_t m1 = model("suzanne.obj", MODEL_NO_ANIMATIONS);
|
||||
model_t m2 = model("suzanne.obj", MODEL_NO_ANIMATIONS|MODEL_MATCAPS);
|
||||
model_t m3 = model("damagedhelmet.gltf", MODEL_NO_ANIMATIONS|MODEL_PBR);
|
||||
// model_t m3 = model("Scutum_low.fbx", MODEL_NO_ANIMATIONS|MODEL_PBR);
|
||||
// model_t m3 = model("damagedhelmet.gltf", MODEL_NO_ANIMATIONS|MODEL_PBR);
|
||||
model_t m3 = model("Scutum_low.fbx", MODEL_NO_ANIMATIONS|MODEL_PBR);
|
||||
model_t m4 = model("cube.obj", MODEL_NO_ANIMATIONS);
|
||||
// model_t m4 = model("avp/scene.gltf", MODEL_NO_ANIMATIONS|MODEL_PBR);
|
||||
// model_t m3 = model("Cerberus_LP.FBX", MODEL_NO_ANIMATIONS|MODEL_PBR);
|
||||
// model_t m3 = model("Cerberus_LP.FBX", MODEL_NO_ANIMATIONS|MODEL_PBR);
|
||||
|
||||
array(char*) list = 0;
|
||||
for each_array( vfs_list("demos/art/shadertoys/**.fs"), char*, dir ) {
|
||||
array_push(list, STRDUP(file_name(dir)));
|
||||
}
|
||||
|
||||
shadertoy_t sh = shadertoy(*list, SHADERTOY_IGNORE_MOUSE|SHADERTOY_FLIP_Y); // 0:no flags
|
||||
sh.dims.x = 1024;
|
||||
sh.dims.y = 1024;
|
||||
shadertoy_render(&sh, 0);
|
||||
|
||||
// spawn object1 (diffuse)
|
||||
object_t* obj1 = scene_spawn();
|
||||
|
@ -72,17 +83,18 @@ int main() {
|
|||
object_model(obj4, m3);
|
||||
object_scale(obj4, vec3(3,3,3));
|
||||
object_move(obj4, vec3(-10+6*3,0,-10));
|
||||
object_pivot(obj4, vec3(0,90,0));
|
||||
object_pivot(obj4, vec3(0,0,90));
|
||||
|
||||
// spawn object5 (pbr)
|
||||
// object_t* obj5 = scene_spawn();
|
||||
// object_model(obj5, m4);
|
||||
// object_scale(obj5, vec3(3,3,3));
|
||||
// object_move(obj5, vec3(-10+6*3,0,-10));
|
||||
// object_pivot(obj5, vec3(0,0,90));
|
||||
object_t* obj5 = scene_spawn();
|
||||
object_model(obj5, m4);
|
||||
object_diffuse(obj5, sh.tx);
|
||||
object_scale(obj5, vec3(3,3,3));
|
||||
object_move(obj5, vec3(-10+8*3,0,-10));
|
||||
object_pivot(obj5, vec3(0,90,0));
|
||||
|
||||
// create point light
|
||||
scene_spawn_light(); // sun
|
||||
// scene_spawn_light(); // sun
|
||||
light_t* l = scene_spawn_light();
|
||||
light_type(l, LIGHT_POINT);
|
||||
// l->diffuse = vec3(0,0,0);
|
||||
|
@ -101,6 +113,9 @@ int main() {
|
|||
// update light position
|
||||
light_teleport(l, cam.position);
|
||||
|
||||
// update shadertoy
|
||||
shadertoy_render(&sh, window_delta());
|
||||
|
||||
// draw scene
|
||||
fx_begin();
|
||||
scene_render(SCENE_FOREGROUND|SCENE_BACKGROUND|SCENE_UPDATE_SH_COEF);
|
||||
|
@ -131,5 +146,20 @@ int main() {
|
|||
}
|
||||
ui_panel_end();
|
||||
}
|
||||
|
||||
static int selected = 0;
|
||||
if( ui_panel("Shadertoy", 1)) {
|
||||
for( int i = 0; i < array_count(list); ++i ) {
|
||||
bool in_use = i == selected;
|
||||
if( ui_bool(list[i], &in_use) ) {
|
||||
sh = shadertoy( list[selected = i], SHADERTOY_IGNORE_MOUSE|SHADERTOY_FLIP_Y );
|
||||
sh.dims.x = 1024;
|
||||
sh.dims.y = 1024;
|
||||
shadertoy_render(&sh, 0);
|
||||
object_diffuse(obj5, sh.tx);
|
||||
}
|
||||
}
|
||||
ui_panel_end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371677,7 +371677,7 @@ skybox_t skybox(const char *asset, int flags) {
|
|||
if( asset ) {
|
||||
int is_panorama = vfs_size( asset );
|
||||
if( is_panorama ) { // is file
|
||||
stbi_hdr_to_ldr_gamma(1.2f);
|
||||
stbi_hdr_to_ldr_gamma(1.0f);
|
||||
image_t panorama = image( asset, IMAGE_RGBA );
|
||||
sky.cubemap = cubemap( panorama, 0 ); // RGBA required
|
||||
image_destroy(&panorama);
|
||||
|
@ -371739,7 +371739,7 @@ skybox_t skybox_pbr(const char *sky_map, const char *refl_map, const char *env_m
|
|||
if( sky_map ) {
|
||||
int is_panorama = vfs_size( sky_map );
|
||||
if( is_panorama ) { // is file
|
||||
stbi_hdr_to_ldr_gamma(1.2f);
|
||||
stbi_hdr_to_ldr_gamma(1.0f);
|
||||
image_t panorama = image( sky_map, IMAGE_RGBA );
|
||||
sky.cubemap = cubemap( panorama, 0 ); // RGBA required
|
||||
image_destroy(&panorama);
|
||||
|
|
|
@ -1658,7 +1658,7 @@ skybox_t skybox(const char *asset, int flags) {
|
|||
if( asset ) {
|
||||
int is_panorama = vfs_size( asset );
|
||||
if( is_panorama ) { // is file
|
||||
stbi_hdr_to_ldr_gamma(1.2f);
|
||||
stbi_hdr_to_ldr_gamma(1.0f);
|
||||
image_t panorama = image( asset, IMAGE_RGBA );
|
||||
sky.cubemap = cubemap( panorama, 0 ); // RGBA required
|
||||
image_destroy(&panorama);
|
||||
|
@ -1720,7 +1720,7 @@ skybox_t skybox_pbr(const char *sky_map, const char *refl_map, const char *env_m
|
|||
if( sky_map ) {
|
||||
int is_panorama = vfs_size( sky_map );
|
||||
if( is_panorama ) { // is file
|
||||
stbi_hdr_to_ldr_gamma(1.2f);
|
||||
stbi_hdr_to_ldr_gamma(1.0f);
|
||||
image_t panorama = image( sky_map, IMAGE_RGBA );
|
||||
sky.cubemap = cubemap( panorama, 0 ); // RGBA required
|
||||
image_destroy(&panorama);
|
||||
|
|
|
@ -18830,7 +18830,7 @@ skybox_t skybox(const char *asset, int flags) {
|
|||
if( asset ) {
|
||||
int is_panorama = vfs_size( asset );
|
||||
if( is_panorama ) { // is file
|
||||
stbi_hdr_to_ldr_gamma(1.2f);
|
||||
stbi_hdr_to_ldr_gamma(1.0f);
|
||||
image_t panorama = image( asset, IMAGE_RGBA );
|
||||
sky.cubemap = cubemap( panorama, 0 ); // RGBA required
|
||||
image_destroy(&panorama);
|
||||
|
@ -18892,7 +18892,7 @@ skybox_t skybox_pbr(const char *sky_map, const char *refl_map, const char *env_m
|
|||
if( sky_map ) {
|
||||
int is_panorama = vfs_size( sky_map );
|
||||
if( is_panorama ) { // is file
|
||||
stbi_hdr_to_ldr_gamma(1.2f);
|
||||
stbi_hdr_to_ldr_gamma(1.0f);
|
||||
image_t panorama = image( sky_map, IMAGE_RGBA );
|
||||
sky.cubemap = cubemap( panorama, 0 ); // RGBA required
|
||||
image_destroy(&panorama);
|
||||
|
|
Loading…
Reference in New Issue