Favasoft

  • Feb 28, 2023
  • Joined Aug 10, 2022
  • 0 best answers
  • Is it possible to have Depth of Field activated in the world environment and exclude certain meshes? While we at it, can you exclude meshes from Fog as well?

  • That fixed it, thanks a bunch.

    PS: I don't know what's going on with the code formatting, looks like a forum issue

  • shader_type spatial;
    
    uniform float wave_size = 1.0;
    uniform float face_distortion = 0.5;
    uniform vec2 time_scale = vec2(0.3, 0.0);
    uniform vec2 uv_offset_scale = vec2(-0.2, -0.1);
    
    uniform sampler2D uv_offset_texture : hint_black; 
    
    void vertex() {
    	// Sample Noise
    	vec2 base_uv_offset = UV * uv_offset_scale;
    	base_uv_offset += TIME * time_scale;
    	float noise = texture(uv_offset_texture, base_uv_offset).r;
    	
    	// Calculate offset and convert from 0.0 <=> 1.0 to -1.0 <=> 1.0
    	float texture_based_offset = noise * 2.0 - 1.0;
    	// Apply amplitude and dampening
    	texture_based_offset *= wave_size;
    	texture_based_offset *= UV.x;
    	
    	VERTEX.y += texture_based_offset;
    	// Distort the face to give impression of conserving shape
    	VERTEX.z += texture_based_offset * face_distortion;
    	VERTEX.x += texture_based_offset * -face_distortion;
    }
    
    void fragment() {
    	vec2 base_uv_offset = UV * uv_offset_scale;
    	base_uv_offset += TIME * time_scale;
    	float noise = texture(uv_offset_texture, base_uv_offset).r;
    	// Display noise. Blue for valleys, green for peaks
    	ALBEDO = vec3(0.0,noise, 2.0 - noise);
    	// Display dampening. Red is full dampening, blue is none
    	//ALBEDO = vec3(1.0 - UV.x, 0.0, UV.x);
    }

    If you walk around the flag in a 3D scene the other side is empty because a plane only has front face. I tried a cube mesh but with no success.

    • For double sided faces.

      shader_type spatial;
      render_mode cull_disabled;

      or

      shader_type spatial;
      render_mode cull_front;

      for culling front faces only and naturally you'd use cull_back to only cull back faces.