opengl – How to fix shadow not casted to terrain when rendering using default and terrain shader (depth shader included)?

Given that I have the TerrainShader class and DefaultShader class. Also a FBO (Frame Buffer Object) shadow map

The TerrainShader has all the terrain, light, shadow related calculations. While the DefaultShader has the generic objects light, shadow related calculations.

I have successfully cast a directional shadow map when I only use DefaultShader alone with random cube objects and a plane. Now the problem was when I move or use a terrain instead of TerrainShader, the shadow is not cast in the terrain.

Question: Am I using the FBO the correct way or I am doing it wrong.

Solution Idea (Not yet applied)

  • Merge terrain and default shader as one and create a flag if object or terrain will be rendered? (Still not sure if this is correct.)

Pseudocode (Current successful implementation)

  • Create shadow map fbo
  • Create default shader
  • Create depth shader
  • bind shadow map fbo
  • clear depth
  • render cubes & plane using depth shader (mvp)
  • unbind shadow map fb
  • clear color and depth
  • render cubes & plane using default shader

Pseudocode (with Terrain shadow not cast to terrain)

  • Create shadow map fbo
  • Create default shader
  • Create terrain shader
  • Create depth shader
  • bind shadow map fbo
  • clear depth
  • render cubes & plane using depth shader (mvp) and exclude terrain
  • unbind shadow map fb
  • clear color and depth
  • render cubes using default shader
  • render terrain using terrain shader

unity – How to use Texture2DArray with Normal map and Normal Unpack node in Shader Graph

Problem was, Normal Unpacking only works with non-SRGB textures.

In order to generate non-SRGB Texture2DArray you’d need to provide last parameter(Set texture to be linear):

Texture2DArray(int width, int height, int depth, TextureFormat textureFormat, bool mipChain, bool linear = true)

But since my Texture array includes both normal maps and albedo maps, all other textures look flatter and uglier(Since they’re linear now).

There are 2 ways of solving this issue:

  1. Use 2 texture arrays, one for normal maps(non-srgb) and another for albedo maps(srgb)

  2. Use non-srgb texture array, but convert albedo maps to srgb inside the shader. Either using cheap approximation: pow(col.rgb, 2.0) or built-in GammaToLinearSpace(col.rgb)

3D Cartoon Graphics. Default Materials in Unity, Maya, Blender etc. Do I need to learn shader coding?

If there was a Stack Exchange for CG, I would post there instead. But since there is not and I know there are a lot of knowledgeable and very helpful people here, I thought I might save a lot of time by asking you all.

I’ve been working on lots of game ideas (I am trying to do all coding AND graphics alone).
I really want my games to have a distinctive look to them but I am struggling, all my games end up looking like a mix-up of other peoples graphics. I do realise this is due to my inexperience and inconsistency in the modelling process mainly (and laziness when it comes down to UV mapping and other bits, however with that said, some small projects I have really tried to make everything to a high cartoony standard).

This is one of my games that is closest to what I want. But sometimes it just has that “default Unity look” to it (I wish I could explain better!)

enter image description here
enter image description here

Then my more recent WIP:
enter image description here

So my question is a broad one. I’ve studied top-end games (and other indie ones) to try to notice differences. I mainly see there is a kind of outline around the characters:

enter image description here
enter image description here
enter image description here

enter image description here

Things I notice are the outline thing, the shadowing on the characters, and actually the quality of the environment graphics work. The games in my screenshots (that I made) I want to continue working on them to make them look better. I realise I am not gonna fumble around in Unity and make something on a par with Legend of Zelda BOTW, but I would love to learn some of the techniques used, particularly ones that can be done in Unity.

I am wondering if I need to learn shader language or perhaps Post Processing techiniques. Or am I wasting my time in the basic Unity and do I need to study the HD Render Pipeline (etc, all the new stuff I am so far yet to look at)

Your advice and insight will be a great help to me. Many thanks

I need help converting Unity .shader to Shader Graph: Bumpy Glass

I’ve been tasked with converting an older Unity shader which does Bumpy Glass with some alpha modification, to URP. I’m assuming that means using Shader Graph. I’m a bit new to shaders in general, but managed to find various clues here and there and have come to the conclusion that creating a Custom Function is probably the easiest way (I could be wrong). Did I mention, this is targeted for WebGL?

Here is the original shader:

Shader "Custom/Glass-Seethrough Alpha" {
Properties{
    _Color("Main Color", Color) = (1,1,1,1)
    _SpecColor("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
    _Shininess("Shininess", Range(0.03, 1)) = 0.3
    _MainTex("Base (RGB)", 2D) = "white" {}
    _BumpMap("Normalmap", 2D) = "bump" {}
    _AlphaMap("Alphamap", 2D) = "black" {}
    _DistAmt("Distortion", range(0,256)) = 100
}
    SubShader{
        GrabPass { }

        Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Opaque" }
        LOD 200

        CGPROGRAM
        #pragma target 3.0
        #pragma exclude_renderers gles
        #pragma vertex vert
        #pragma surface surf BlinnPhong alpha
        #include "UnityCG.cginc"

        float4 _Color;
        float _Shininess;
        sampler2D _MainTex;
        sampler2D _BumpMap;
        sampler2D _AlphaMap;
        sampler2D _GrabTexture;
        float _DistAmt;
        float4 _GrabTexture_TexelSize;

        struct Input {
            float2 uv_MainTex;
            float2 uv_BumpMap;
            float2 uv_AlphaMap;
            float4 proj : TEXCOORD;
        };

        void vert(inout appdata_full v, out Input o) {
            UNITY_INITIALIZE_OUTPUT(Input, o);
            float4 oPos = UnityObjectToClipPos(v.vertex);
            #if UNITY_UV_STARTS_AT_TOP
                float scale = -1.0;
            #else
                float scale = 1.0;
            #endif
            o.proj.xy = (float2(oPos.x, oPos.y * scale) + oPos.w) * 0.5;
            o.proj.zw = oPos.zw;
        }

        void surf(Input IN, inout SurfaceOutput o) {
            half3 tint = tex2D(_MainTex, IN.uv_MainTex);
            half3 nor = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            half3 alpha = tex2D(_AlphaMap, IN.uv_AlphaMap);

            float2 offset = nor * _DistAmt * _GrabTexture_TexelSize.xy;
            IN.proj.xy = offset * IN.proj.z + IN.proj.xy;
            half4 col = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(IN.proj));
            half3 tinted = col * tint * _Color;

            o.Albedo = lerp(col, tinted, alpha);//tex.rgb * _Color.rgb * col.rgb;
            o.Normal = nor.rgb;
            o.Specular = _Shininess;
            o.Gloss = col.a;
            o.Alpha = alpha.r;
        }
        ENDCG
    }
    FallBack "Diffuse"

}

The idea is to have the bump map animate on, say, uv.v, to simulate water flow through a pipe, and animate the alpha map to ‘reveal’ the pipe. Here’s what it should look like:
Supposed to look like

I found this article which helped (I THINK!) with the ‘vert’ part of the shader.
Where I’m getting stuck is in the ‘surf’ part. I’ve set up a bunch of inputs, and maybe I’ve gone down the wrong rabbit hole, but I’m getting an error saying that uv_MainTex does not exist:

Here’s a shot of the work in progress:
glass shader conversion WIP

And the full text (admittedly incomplete):

half3 tint = SAMPLE_TEXTURE2D(MainTex, SS, uv_MainTex);
half3 nor = UnpackNormal(tex2D(BumpMap, uv_BumpMap));
half3 alpha = tex2D(AlphaMap, uv_AlphaMap);

float2 offset = BumpMap * DistAmt; * GrabTexture_TexelSize.xy;
proj.xy = offset * proj.z + proj.xy;
half4 col = tex2Dproj(GrabTexture, proj);
half3 tinted = col * tint * color;

Albedo = lerp(col, tinted, alpha);

But I’m getting this error that uv_MainTex does not exist.
See error message

Am I even on the right track? Am I using the wrong macros? Do I need additional SamplerStates? Or hey, has someone already made such a shader I can get and call it a day?
Thanks

opengl – GLEW compiler error when creating shader storage buffer

When building while defining a shader storage buffer like below, Visual Studio gives me the error “too few arguments for call” and multiple undeclared identifier and syntax errors on the line with glBufferData. I am using the newest version of GLEW, c++17, Visual Studio 2019 and my graphics card supports OpenGL 4.6. The same thing happens with glNamedBufferData

vector<int> data;

GLuint ssbo;
glGenBuffers(1, &ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
glBufferData(GL_SHADER_STORAGE_BUFFER, data.size() * sizeof(int), &data(0)​, GL_DYNAMIC_DRAW); 
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); // unbind

How to best select a texture pair to use in height blending when using a splatmap shader

In my project, I’m implementing a shader to combine up to 4 textures in a terrain using a splatmap texture (https://en.wikipedia.org/wiki/Texture_splatting).

I want to combine the splatmap blending with the height blending technique, described in: http://untitledgam.es/2017/01/height-blending-shader/. This technique basically defines a function to interpolate between two textures more realistically based on height information.

The problem is, in order to use height blending, I need to know which pair of textures I’ll be interpolating, while in the splatmap I actually have four different texture sets (channels, R G B and A).

So what I want to achieve is a shader that will select the pair of textures for which the splatmap channel information is strongest, and interpolate between the two while discarding others. My “naïve” attempt was something along the lines of (simplified version, pseudo-code and only for illustrative purposes):

uniform sampler2D tex1;
uniform sampler2D tex2;
uniform sampler2D splat;

void fragment_shader() {
    sampler2D sampler;
    if (splat.r > splat.g) {
      sampler = tex1;
    } else {
      sampler = tex2;
    }
}

The problem, I realized, is that I can’t store samplers inside a variable like this due to limitations in GLSL. So I’m looking for a soultion that would be similar to this. Particularly, I would want to avoid a solution where I’m sampling all four textures for every texture lookup. That is because I will be using some expensive techniques inside the shader which require several texture lookups, and I don’t want to increase the computation cost 2x.

unreal 4 – Shader compilation process

Iam wondering how the shader compiling process carried out by the game engines, For instance, if hit the apply and save button from Unreal Engine4 material editor, it does take a while to finish all the shader compiling process. Indeed, the duration fully up to how complex the shader is, eventually, the complied file stored inside the harddrive But what’s the precise process when compiling a shader?

opengl – GLSL Help needed to render textures using fragment shader (or procedural textures)

Recently, I have been making a 3D game.
I was messing with my shader files, when I ran into a problem. The “texture” I made for the fragment shader just renders on top of the object, and does not rotate with it or repeat on individual faces, but looks alright when I pass the gl_Vertex colors into gl_FragColor.

Here is the images to tell you what I am talking about
IMG1

While the vertex colors rotate with the object:
IMG2

I am pretty clueless as I’ve never really messed with GLSL shaders at all… I’ve researched a bit but I don’t know what this is called, so I didn’t get any good answers.

Here’s what I know:

  • Fragment shaders mess with all colors on screen and affects colors of specified objects
  • Vertex shaders well, mess with vertex point of the specified object you choose to start the shader for.

Here’s my code for Fragment:

#version 120

uniform float u_time;
uniform vec2 u_resolution;

varying vec4 verpos;

varying vec4 normals;

varying vec4 colors;

in vec2 f_TC;

void main(void)
{
    vec2 st = gl_FragCoord.xy/u_resolution;
    
    // gl_FragColor = vec4(f_TC, 0.0, 1.0);
    
    gl_FragColor = vec4(verpos.xyz, 1.0);
    
    // gl_FragColor = vec4(verpos.xyzw);
    // gl_FragColor = vec4(color, 1.0);
}

And for Vertex:

#version 120

vec4 a = gl_Vertex;
varying vec4 verpos;
varying vec4 normals;
varying vec4 colors;

attribute vec2 in_TC;
out vec2 f_TC;

void main(void) 
{
    // gl_Position = ;

    gl_Position = gl_ModelViewProjectionMatrix * a;
    verpos = gl_Vertex;
    normals = vec4(gl_Normal, 1.0);
    colors = gl_Color;
    f_TC = in_TC;
}

Here is my code to draw the cube:

public void drawCube() throws IOException {
        
        GL11.glBegin(GL11.GL_TRIANGLES);
        // GL11.glColor3f(toRatio(155), toRatio(202), toRatio(222));
        
        //FRONT QUAD
        
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(-10 * x,  10 * x, 10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, 10 * x, 10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, -10 * x, 10 * x);        
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, -10 * x, 10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, 10 *x, 10 * x);
        
        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(10 * x, -10 * x, 10 * x);
        
        GL11.glEnd();
        
        GL11.glBegin(GL11.GL_TRIANGLES);
        
        //BACK QUAD
        
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(-10 * x,  10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, 10 * x, -10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, -10 * x, -10 * x);  
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, -10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, 10 *x, -10 * x);
        
        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(10 * x, -10 * x, -10 * x);
        
        GL11.glEnd();
        
        GL11.glBegin(GL11.GL_TRIANGLES);
        
        //LEFT QUAD
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(-10 * x, 10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(-10 * x, 10 * x, 10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, -10 * x, -10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, -10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(-10 * x, 10 * x, 10 * x);
        
        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(-10 * x, -10 * x, 10 * x);
        
        GL11.glEnd();
        
        GL11.glBegin(GL11.GL_TRIANGLES);
        
        //RIGHT QUAD
        
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(10 * x, 10 * x, 10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, 10 * x, -10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(10 * x, -10 * x, 10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(10 * x, -10 * x, 10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, 10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(10 * x, -10 * x, -10 * x);
        
        GL11.glEnd();
        
        GL11.glBegin(GL11.GL_TRIANGLES);
        
        //TOP QUAD
        
        //debugColor();
        
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(-10 * x,  10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x,  10 * x, -10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x,  10 * x, 10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, 10 * x, 10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, 10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(10 * x, 10 * x, 10 * x);
        
        GL11.glEnd();
        
        GL11.glBegin(GL11.GL_TRIANGLES);
        
        //BOTTOM QUAD
        
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(-10 * x,  -10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x,  -10 * x, -10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x,  -10 * x, 10 * x);
        
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-10 * x, -10 * x, 10 * x);
        
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(10 * x, -10 * x, -10 * x);
        
        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(10 * x, -10 * x, 10 * x);
        
        
        GL11.glEnd();
        
    }

My code to load images:

package me.pale.texture;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.newdawn.slick.opengl.*;

public class IMG {
    
    Texture texture;
    
    public IMG (String file) {
        
        try {
            texture = TextureLoader.getTexture("PNG", new FileInputStream("res/" + file + ".png"));
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        texture.bind();
        
    }

    public Texture getTexture() {
        return texture;
    }

}

And here’s my entire MainLoop class:

package me.pale.main;

import java.io.File;

import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.util.glu.GLU;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
import org.newdawn.slick.util.ResourceLoader;

import me.pale.input.Input;
import me.pale.model.Model;
import me.pale.model.RGB;
import me.pale.shader.RegShader;

public class MainLoop extends RGB{
    
    float a = 0;
    
    float() verts = new float() {
            
        0.0f, 0.5f, 0.0f,
        -0.5f, -0.5f, 0.0f,
        0.5f, -0.5f, 0.0f
            
    };
    
    String vertex = "res/vertex.txt";
    String frag = "res/fragment.txt";
    
    File vertexShad = new File(this.getClass().getResource("/vertex.glsl").toString());
    File fragShad = new File(this.getClass().getResource("/fragment.glsl").toString());
    
    float rot = 0;
    float DX = 0;
    float DY = 0;
    
    Input i = new Input();
    
    RegShader shader;
    
    Model cube = new Model();
    
    Texture tex;
    
    public void init() throws LWJGLException, Exception {
        

        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.create();
        
        shader = new RegShader();
        
        tex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/test.png"));
        
        Display.sync(60);
        
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        // GL11.glOrtho(-640/2, 640/2, -480/2, 480/2, -200, 500);
        
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        
        GL11.glClearColor(0, 0, 0, 0);
        
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        
        GL11.glEnable(GL11.GL_NORMALIZE);
        //GL11.glEnable(GL11.GL_BLEND);
        //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        
        GLU.gluPerspective(90.0f, 1.333f, 1.0f, 650.0f);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LESS);
        GL11.glLoadIdentity();
        
        GL11.glTranslatef(0.0f, 0.0f, -500.0f);
        
        tex.bind();
        
        while (!Display.isCloseRequested()) {
            
            // Clear the screen and depth buffer
            // GL11.glEnable(GL11.GL_DEPTH_TEST);
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);  
            
            GL11.glClearColor(1.0f, 1.0f, 0.2f, 1.0f);
             
            // set the color of the quad (R,G,B,A)
            // GL11.glColor3f(toRatio(12), toRatio(202), toRatio(222));
            input();
            
            shader.start();
            
            a+=0.001f;
            
            if (a > 360) {
                a = 0;
            }
            
            int uniform1 = GL20.glGetUniformLocation(shader.getProgID(), "u_time");
            
            GL20.glUniform1f(GL20.glGetUniformLocation(shader.getProgID(), "u_time"), a);
            
            int res = GL20.glGetUniformLocation(shader.getProgID(), "u_resolution");
            
            GL20.glUniform2f(GL20.glGetUniformLocation(shader.getProgID(), "u_resolution"), 640.0f, 480.0f);
            
            GL11.glPushMatrix();
            
            GL11.glRotatef(DX += Mouse.getDX(), 0, 1, 0);
            GL11.glRotatef(DY += Mouse.getDY(), 1, 0, 0);
            
            // GL11.glRotatef(rot += 0.05f, 1, 1, 1);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
           
            cube.drawCube();
            
            GL11.glLoadIdentity();
            
            GL11.glPopMatrix();
            
            shader.halt();
            
            Display.update();
            
        }
        
        shader.wash();
        Display.destroy();
        
    }
    
    public void input() {
        
        if (Keyboard.getEventKey() == Keyboard.KEY_A) {
            
            if (Keyboard.getEventKeyState()) {
                
                GL11.glTranslatef(0.3f, 0, 0);
                
            }
            
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_D) {
            
            if (Keyboard.getEventKeyState()) {
                
                GL11.glTranslatef(-0.3f, 0, 0);
                
            }
            
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_W) {
            
            if (Keyboard.getEventKeyState()) {
                
                GL11.glTranslatef(0, 0, 0.3f);
                
            }
            
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_S) {
            
            if (Keyboard.getEventKeyState()) {
                
                GL11.glTranslatef(0, 0, -0.3f);
                
            }
            
        }
        
        if (i.isLMBDown()) {
            
            System.out.println("MOUSEX: " + i.getMouseX() + ", MOUSEY: " + i.getMouseY());
            
        }
        
        while (Keyboard.next()) {
            
            if (Keyboard.getEventKey() == Keyboard.KEY_B) {
                
                if (Keyboard.getEventKeyState()) {
                    
                    System.out.println("Key B Pressed.");
                    
                }
                
            }
            
            if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
                
                Display.destroy();
                System.exit(0);
                
            }
            
        }
        
    }
    
    public static void main(String() args) throws Exception {
        
        MainLoop ml = new MainLoop();
        ml.init();
        
    }

}

Any help appreciated

Yes, I am using old methods and no VBOs and VAOs

I grabbed some code from This Link to help with trying to render textures but it wont work.

The main thing I need is how to grab the texture coordinates. The texcoords are declared in the model using GL11.glTexCoord2f();, not using Arraylists

~ Pale_Gray

opengl – GLSL Shader texture or procedural textures just rendering on top of object (LWJGL 2)

Recently, I have been making a 3D game.
I was messing with my shader files, when I ran into a problem. The “texture” I made for the fragment shader just renders on top of the object, and does not rotate with it or repeat on individual faces, but looks alright when I pass the gl_Vertex colors into gl_FragColor.

Here is the images to tell you what I am talking about
IMG1

While the vertex colors rotate with the object:
IMG2

I am pretty clueless as I’ve never really messed with GLSL shaders at all… I’ve researched a bit but I don’t know what this is called, so I didn’t get any good answers.

Here’s what I know:

  • Fragment shaders mess with all colors on screen
  • Vertex shaders well, mess with vertex point of the specified object you choose to start the shader for.

Should I Multiply the vertex positions with the texture? Should I add them? Do I have to do alot of matrices code to make this work? Does this deal with view and model matrices?

Here’s my code for Fragment:

#version 120 core

uniform float u_time;
uniform vec2 u_resolution;

varying vec4 verpos;

varying vec4 normals;

float plot(vec2 st) {
    return smoothstep(0.02, 0.0, abs(st.y - st.x));
}

void main(void)
{
    vec2 st = gl_FragCoord.xy/u_resolution;

    float y = st.x;
    
    vec3 color = vec3(y);
    
    float pct = plot(st);
    color = (1.0-pct) * color + pct * vec3(1.0, 0.0, 0.0);
    
    //gl_FragColor = vec4(color, 1.0);
    
    // gl_FragColor = vec4(verpos.xyzw);
    gl_FragColor = verpos;
}

And for Vertex:

#version 120 core

vec4 a = gl_Vertex;
varying vec4 verpos;
varying vec4 normals;

void main(void) 
{
    gl_Position = gl_ModelViewProjectionMatrix * a;
    verpos = gl_Vertex;
    normals = vec4(gl_Normal, 1.0);
}

Any help appreciated

Yes, I am using old methods and no VBOs and VAOs

~ Pale_Gray

SSS shader error (object goes pink) in Unity for Android

I am trying to get a manageable and not laggy SSS shader for an Android app made in unity, the problem is that while i run the game on the computer, everything works. Once i build the app and send it to the Android, the model turns pink as the shader is never detected.
Also, the camera in order to have the SSS visible has a shader attached to it as a script, everything works on the PC but when it transfers to apk the model goes pink.
Any help?>