Giter Club home page Giter Club logo

Comments (6)

zhuxudong avatar zhuxudong commented on May 26, 2024
  • missing some qualifier in function parameter,such as 'inout':
float test(const in a, inout b, out c){}

from engine.

Sway007 avatar Sway007 commented on May 26, 2024
  • missing some qualifier in function parameter,such as 'inout':
float test(const in a, inout b, out c){}

qualifiers such as in/out/inout should be in front of parameter type, be like:
float test(in float a, inout float b, out vec2 c){}

from engine.

zhuxudong avatar zhuxudong commented on May 26, 2024

i write a simple demo, see issue below:

/**
 * @title ShaderLab Test
 * @category Material
 */

import { Camera, Logger, Material, MeshRenderer, PrimitiveMesh, Shader, WebGLEngine } from "@galacean/engine";
import { ShaderLab } from "@galacean/engine-shader-lab";
Logger.enable();
const shaderLab = new ShaderLab();

const FurShaderSource = `Shader "Fur" {
  SubShader "Default" {
    // @issue: renderState outside
    // BlendState blendState {
    //   Enabled = true;
    //   SourceColorBlendFactor = BlendFactor.SourceAlpha;
    //   DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
    //   SourceAlphaBlendFactor = BlendFactor.One;
    //   DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
    // }

    // BlendState = blendState;
    // RenderQueueType = RenderQueueType.Transparent;
    
    mat4 renderer_MVPMat;
    mat4 renderer_ModelMat;
    mat4 renderer_NormalMat;
    vec3 camera_Position;

    sampler2D _MainTex;
		sampler2D _LayerTex;
		sampler2D _NoiseTex;

    vec3 _Gravity;
    float _GravityIntensity;
    float _EdgeFade;
    float _Cutoff;
    float _CutoffEnd;
    float _FurLength;

    struct a2v {
      vec4 POSITION;
    }


    // float issue_qualifier(inout float a){
    //   return 1.0;
    // }


    v2f issue_v2f(a2v v){
      v2f o;
      gl_Position = renderer_MVPMat * v.POSITION;
      return o;
    }

    Pass "0" {
      v2f vert(a2v v) {
        // v2f o;

        // gl_Position = renderer_MVPMat * v.POSITION;

        // @issue:qualifier
        // issue_qualifier(1.0);

        // @issue: v2f outside
        return issue_v2f(v);

        // return o;
      }

      void frag(v2f i) {
        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
      }

      VertexShader = vert;
      FragmentShader = frag;
    }

  }
}`;

Logger.enable();
WebGLEngine.create({ canvas: "canvas", shaderLab }).then((engine) => {
  engine.canvas.resizeByClientSize();

  // test Shader
  const shader = Shader.create(FurShaderSource);

  const scene = engine.sceneManager.activeScene;
  const rootEntity = scene.createRootEntity();

  // camera
  const cameraEntity = rootEntity.createChild("cameraNode");
  cameraEntity.transform.setPosition(0, 0, 5);
  cameraEntity.addComponent(Camera);

  const triangle = rootEntity.createChild("plane");
  const renderer = triangle.addComponent(MeshRenderer);
  renderer.mesh = PrimitiveMesh.createSphere(engine, 2, 64);
  const material = new Material(engine, shader);
  renderer.setMaterial(material);

  engine.run();
});

from engine.

zhuxudong avatar zhuxudong commented on May 26, 2024

multi pass shader refs to: https://github.com/chenyong2github/ExtendStandard/blob/master/Assets/Shaders/Unlit_Fur.shader

from engine.

zhuxudong avatar zhuxudong commented on May 26, 2024

add playground multi-pass test case: galacean/galacean.github.io#969

from engine.

Sway007 avatar Sway007 commented on May 26, 2024
  • can't write uniform outside Multi pass

fixed by #2018

from engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.