Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
0.8.4:default-material [2022/06/26 09:46] – [Fragment Shader] admin0.8.4:default-material [2023/01/31 14:02] – [Changing Shaders at DesignTime] admin
Line 304: Line 304:
   * **tex2D()**   * **tex2D()**
   * **tex2DProj()**   * **tex2DProj()**
-  * **tex3d()**+  * **tex3D()**
   * **texCube()**   * **texCube()**
   * **Texture_GetNormal()**   * **Texture_GetNormal()**
Line 403: Line 403:
 | SurfaceShader | TGorillaGLSLSurfaceShaderExec| Calls **SurfaceShader(LOCALS);** | | SurfaceShader | TGorillaGLSLSurfaceShaderExec| Calls **SurfaceShader(LOCALS);** |
 | SurfaceShader | TGorillaGLSLMergedColorOutputNode |It will compute the final **LOCALS.SumColor** depending if GORILLA_GLSL_DEFINE_LIGHTING, GORILLA_GLSL_DEFINE_SPECULARMAP, GORILLA_GLSL_DEFINE_SHADOW or GORILLA_GLSL_DEFINE_PBR are activated. | | SurfaceShader | TGorillaGLSLMergedColorOutputNode |It will compute the final **LOCALS.SumColor** depending if GORILLA_GLSL_DEFINE_LIGHTING, GORILLA_GLSL_DEFINE_SPECULARMAP, GORILLA_GLSL_DEFINE_SHADOW or GORILLA_GLSL_DEFINE_PBR are activated. |
-| SurfaceShader | TGorillaGLSLBrightnessColorNode | It will multiply **_Brightness** value with **LOCALS.SumColor**|+| SurfaceShader | TGorillaGLSLBrightnessColorNode | It will multiply **_Brightness** value with **LOCALS.SumColor** (since v0.8.4.2322)|
 | SurfaceShader | TGorillaGLSLFragColorOutputNode | It will apply material alpha value to **LOCALS.Alpha** and finally write **vec4(LOCALS.SumColor, LOCALS.Alpha)** to //o_Albedo// render target. | | SurfaceShader | TGorillaGLSLFragColorOutputNode | It will apply material alpha value to **LOCALS.Alpha** and finally write **vec4(LOCALS.SumColor, LOCALS.Alpha)** to //o_Albedo// render target. |
 | SurfaceShader | TGorillaGLSLColorClipNode | If GORILLA_GLSL_DEFINE_USE_COLORCLIP is activated, it will discard the fragment if threshold was reached. | | SurfaceShader | TGorillaGLSLColorClipNode | If GORILLA_GLSL_DEFINE_USE_COLORCLIP is activated, it will discard the fragment if threshold was reached. |
Line 1346: Line 1346:
  
  
 +==== Changing Shaders at DesignTime ====
  
 +Since 0.8.4 it's possible to modify your default shader at designtime, by using published properties *VertexShader* or *SurfaceShader*.
 +
 +Simply select your default material source and open the text editor of the property. An empty GLSL function should be visible depending on the shader used.
 +
 +For VertexShader:
 +<file glsl>
 +void VertexShader(inout TLocals DATA){
 +
 +}
 +</file>
 +
 +For SurfaceShader (Fragment/Pixel-Shader):
 +<file glsl>
 +void SurfaceShader(inout TLocals DATA){
 +
 +}
 +</file>
 +
 +You can then modify or extend the shader functionality.
 +Please have a look a the section [[Shader Variables|]] for the available fields in TLocals structure.
 +
 +**NOTICE:** //Modifying the vertex position in vertex-shader all 3 fields "DATA.Position", "DATA.TransfVertexPos" and "DATA.WorldViewProjVertPos" need to be modified. Otherwise their basis might not be equal which leads to unexpected effects!//
 +
 +In the following example we've created a wobbling effect in the vertex shader:
 +
 +<file glsl>
 +vec2 DELPHI_HASH2(vec2 n){ 
 +    return fract(sin(n)*1399763.5453123);
 +}
 +
 +float DELPHI_NOISE(vec2 st){
 +    vec2 i = floor(st);
 +    vec2 f = fract(st);
 +
 +    vec2 u = f * f * (3.0 - 2.0 * f);
 +
 +    float a = dot(DELPHI_HASH2(i + vec2(0.0,0.0)), f - vec2(0.0, 0.0));
 +    float b = dot(DELPHI_HASH2(i + vec2(1.0,0.0)), f - vec2(1.0, 0.0));
 +    float c = dot(DELPHI_HASH2(i + vec2(0.0,1.0)), f - vec2(0.0, 1.0));
 +    float d = dot(DELPHI_HASH2(i + vec2(1.0,1.0)), f - vec2(1.0, 1.0));
 +
 +    return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
 +}
 +
 +vec3 DELPHI_WOBBLE(vec3 pos, float time, float intensity){
 +    return vec3(pos.x, pos.y + (DELPHI_NOISE(vec2(pos.x, pos.z) + time) * intensity), pos.z);
 +}
 +
 +void VertexShader(inout TLocals DATA){
 +  DATA.Position.xyz = DELPHI_WOBBLE(DATA.Position.xyz, _TimeInfo.y, 0.5);
 +
 +  DATA.TransfVertexPos = _ModelMatrix * DATA.Position;
 +  DATA.WorldViewProjVertPos = _ModelViewProjectionMatrix * DATA.Position;
 +}
 +</file>
 ===== Properties ===== ===== Properties =====