How do int textures work in ComputeShaders?
I'm having trouble understanding how to write into a RenderTexture with an integer format (e.g. [RGInt][1]). The following code leads to a completely black texture but by my understanding, it should be...
View ArticleHLSL convert float to int losing precision
I have the following frag function in my vertex shader: (the rest of the shader is the Sprite-Default shader that ships with Unity). float4 SpriteFrag(v2f IN) : SV_Target { float4 c = tex2D (_MainTex,...
View ArticleHLSL bit shifting
I have a sprite that I am trying to enable palette swapping on. I've written a tool to iterate over the color values in the sprite and encode the colors palette index within the first(?) two bits in...
View Articleregarding Shader Optimization
I have a shader with 3 seperate effects on it. 2 of the effects are mapped using textures (named "_TeamTex" and "_MuzzleTex"). If the effects shouldn't trigger, the base texture _MainTex should be used...
View ArticleCell Shading Using 2D Renderer?
Hi! I've been messing around with ShaderLab and ShaderGraph, trying to make a 2D Cell/Toon Shader, that replicate the one in [Laigter][1]. (awesome software btw) ### Where I'm at: ### Currently I have...
View ArticleHow can I add Color property To This Shader
I want to change the color of material. Texture is working But how can i add COLOR property to change material color. Thanks. Shader "Custom/Jelly" { Properties { _MainTex ("Base (RGB)", 2D) = "white"...
View ArticleTrying to make a raymarching shader
I'm trying to make a raymarching shader in unity thats currently only meant to display a simple circle. But for some reason it just doesn't want to work and is only showing the background colour i set....
View ArticleSharing code between shader and c# - how?
Hi Everyone, With the new Unity.mathematics library we can now write more or less identical code for (compute) shaders and c#. Fantastic! But *really* great would be if I could use a single source file...
View ArticleHow to learn HLSL?
I am trying to make a custom lighting system for Unity to solve some strange problems I have had with the native lighting system. For this I have opted for a script partnered with a shader, and for...
View ArticleIs there a default / built-in vertex shader so I can avoid the boilerplate?
I'm writing a custom shader, but the crux of the code is present in the fragment function. The vertex function is pretty much just boilerplate and "wasted space". When writing a post-processing shader,...
View ArticleSplat Map with transition texture?
Hi! I have been following [catlikecoding's tutorial][1] on this terrain editor and i need help figuring out how or where i would add a texture to the shader in order to transition from one texture to...
View Articlehow to debug shader on android
is there anyone who helps me to do debugging hlsl shader on an android device? In case of window, I have been debugging it with renderdoc as below. ![alt text][1] And now, I've tried to debug it on...
View ArticleHow to not have custom node variables be global across all material instances
Hi there! I wrote a shader in HLSL but I needed to switch to Shader Graph cause I wanted easy, flexible lighting. I'm working in URP with Unity version 2020.3.25f1. However I needed to put some of the...
View ArticleHow to use the compute shader to sample the depth map under URP and calculate...
Here is my code, but the output is always weird. compute shader: #pragma kernel WaterSplash struct Particle { float3 position; float lifetime; float showScale; }; RWStructuredBuffer particleBuffer;...
View ArticleShader - Cant use TransformObjectToWorldNormal and TransformObjectToWorld
Hi i created an unlit shader and i trying to use the functions TransformObjectToWorldNormal() and TransformObjectToWorld(), and i keep having console erro of: undeclared identifier...
View Articlewhat is criteria shader requires loop unrolling?
Hello, everyone, I'm implementing Volume Rendering using [this](https://github.com/mlavik1/UnityVolumeRendering). And then, this example code uses the `tex3dlod` function to sample 3d texture. When I...
View ArticleIs there a list of Shader input struct naming conventions?
Warning: I don't know much about shaders, so please bear with me. I was trying to go through the default Unity shader, and encountered the following code: struct Input { float2 uv_MainTex; }; From a...
View ArticleNormal edge mapping with neighbouring heightmaps
Hey All! I have a question that has been dogging me for a while. I'm working on a project using extremely high resolution (5cm) Digital Surface Models (DSMs) with 5cm orthomosaics over a ~5km^2. I'm...
View ArticleDefining extra vertex data in image effect shader v2f struct?
In the vertex to fragment struct of this image effect shader, I want to add a float3 that represents the direction between the camera and the vertex. But I'm still new to shaders so I don't really know...
View ArticleSmoke simulation has many jaggers only on the emission entry.
I tried to simulate the smoke emission process with compute shader. After calculating the density of particles with NS equation, I used ray marching to display the animation for each frame. However,...
View ArticleHow do I get the depth texture from a hlsl shader? (HDRP)
I'm trying to simply sample the camera's depth texture from an hlsl shader. Supposedly all you need to do is declare a sampler2d "_CameraDepthTexture" but this has not worked for me. I've tried...
View ArticleCompute Shader cannot unroll loops,Compute shader cant untroll loops
Hey! I've been working on outsourcing neural networks onto the GPU. Since I am a beginner with hlsl (but I think I got a basic idea of hlsl etc now), this takes me so much time. While I thought I'd be...
View ArticleCanvas Image UV change on play mode (Shader Lab)
Hello everyone, i need help regarding shader so i just wanna lerp 2 image using main texture uv. its working in editor mode but its not working in play mode. anybody knows something about this ? Editor...
View ArticleNvidia HLSL extensions
Is there a way to use [Nvidia's HLSL Extensions][1] in Unity shaders? Specifically I'm interested in [timer instrumentation][2] and [shader execution reordering][3] in ray tracing shaders. I can...
View ArticleAttempting to bind Texture as UAV without Flag error.
Hey I am new to compute shaders and have been playing around with a pixelation and palletization shader, but after a bit of poking around It started erroring on the line "color =...
View ArticleHLSL Shader gives error, output parameter 'Direction' not completely initialized
I've been following a tutorial over a cel shader and I've been getting an error that only I seem to have. The error says, Shader error in 'Master': 'MainLight_float': output parameter 'Direction' not...
View ArticleUnity URP shader does not update
I have .shader file and .hlsl file which included inside the .shader. When I make any code update in thr .hlsl file, changes don't occur in the editor, even if I recompile the shader and press play it...
View ArticleBad compute shader performance using millions of threads, even with empty shader
I'm trying to create a Newton particle simulation using compute shaders. In order to visualize it I calculate every particle position and project it onto a RenderTexture. There are several examples...
View ArticleApplying a texture to the moon in a skybox shader
so, I have this Skybox shader in hlsl which I'm editing on top of where I need to properly Wrap UV so I can Apply the texture to the moon properly... I have tried a few things but all seem to distort...
View ArticlePoint cloud selection via pixel color
I currently have a custom point cloud shader for Unity. The point clouds are represented as a collection of meshes, each point being a vertex in a mesh. The shader displays a billboard/quad with...
View Article