Tagged Questions

a computer program that runs on graphics hardware and provides a high degree of control over how scenes are rendered

learn more… | top users | synonyms (1)

18
votes
4answers
3k views

How can I draw outlines around 3D models?

How can I draw outlines around 3D models? I'm referring to something like the effects in a recent Pokemon game, which appear to have a single-pixel outline around them:
2
votes
1answer
2k views

Additive “Sprites/Default” shader

The Sprites/Default shader multiplies the color with the provided tint, while I need to add it instead. I fixed this copying the shader (taken from here) and simply changing the line return ...
1
vote
2answers
184 views

How can I render 3D dots at object vertex positions?

What is the best way to put a dot on a vertex? I have a model (a plane for example) consisting of a few thousand vertices. I want to draw a red dot at every vertex's 3D position, just like 3ds Max's ...
0
votes
1answer
627 views

How to get pixel coordinates between 0,1 from SV_POSITION [duplicate]

I am new to HLSL and Directx. I was trying to write a simple gradient Shader by modifying one of Microsoft samples. 1.I can not understand why SV_POSITION is float4? If it is pixel coordinates ...
1
vote
1answer
2k views

Shader which supports vertex colors and pixel lights?

From my question at Unity Answers: Hello everyone, I'm facing a bit of a problem here: I need a shader which has the ability to colour individual vertices and be lit pixel by pixel. Until recently, I ...
1
vote
1answer
161 views

How to enable geometry shader in OpenGL 4.2?

I'm porting my Direct3D-based engine to OpenGL and I'm using geometry shaders for rendering text characters (basically, textured billboards). D3D version works fine, but in OpenGL mode it gives only ...
2
votes
1answer
365 views

Directx 11: emulating palette swapping with shader 5.0 and c++

i'm trying to swapping the colors using a texture as index and a second one as palette. Here is the full listing of the code: #include <windows.h> #include <windowsx.h> #include ...
13
votes
1answer
2k views

How do Raymarch shaders work?

I have been looking at shaders found here shadertoy.com and most of the cool ones have noise and raymarch in common. I do not understand the source code at all but I really want to. How do these ...
7
votes
3answers
620 views

How can I create a shader that will reproduce this lighting effect on terrain?

Notice the way in which the major light source in each image reflects off the ground, as a function of the distance between the light source and the viewer (?). Is this a (bumped) specular map? ...
1
vote
1answer
99 views

rrr subcsript for float type

I'm a little confused with this construction: float sdcolor = MyColor.r; // MyColor has float4 type float rcolor = sdcolor.rrr; // .ggg or .bbb isn't working return float4(rcolor , rcolor , rcolor , ...
0
votes
1answer
141 views

Why divide by w makes the pixel shader look better?

I'm writing a shader in HLSL (Direct3D11 with SharpDX) and after some computations I was trying to make a test and print the depth z of a specific point in my pixel shader, like this: myZ = ...
3
votes
1answer
396 views

Spritebatch Vertex shader world matrix change after each draw

I have a spritebatch where I draw some textures transformed in 3d space. The easy way was just Begin with the transformation matrix, draw, and end it right after. But that is silly, so I'm trying ...
0
votes
1answer
819 views

problem using glm::lookAt and glm::perspective

I'm trying to change the code from the 22th tutorial at http://ogldev.atspace.co.uk/, using the GLM library, but the result seems wrong. The problem is shown in the below picture: While it should be: ...
1
vote
0answers
96 views

Can't understand the Schlick model formula

I'm trying to implement the Schlick shading model in the fragment shader. I took the formulas from Karsten Schwenk's "a survey of shading models for real-time rendering": First of all I don't ...
-1
votes
1answer
222 views

is instanced rendering faster? [closed]

Is instanced rendering used in GLSL faster than doing something like this.. for(int i=0; i<10; i++) { glDrawArrays(GL_POINTS, 0, 3000); } Suppose I want to render 'grass', which is the best ...
1
vote
1answer
179 views

ShaderBytecode Compiler one technique multiple passes

I have an effect code with a basic structure like technique TechniqueName { pass FirstPass { Profile = fx_4_0 VertexShader = RenderFirstVS GeometryShader = null ...
0
votes
0answers
31 views

Strauss model : no specular component [duplicate]

I implemented the Strauss model with the metalness, transparency and smoothness parameters, taking the formulas from the book "Programming vertex geometry and pixel shaders", this is how I implemented ...
0
votes
1answer
90 views

How can I avoid applying textures to a fragment in a shader when the surface normal is (0, 1, 0)?

I have a small GLSL shader with a vertex shader and a fragment shader. I want to avoid applying textures to faces that have a normal equal to (0, 1, 0). Is this possible? These are my shaders: ...
1
vote
1answer
163 views

Separate shader programs or branch in shader? [duplicate]

I have a bunch of point lights and directional lights. Instead of checking the light type in the fragment shader and then branch for either point light calculation or directional light calculation, is ...
5
votes
2answers
320 views

How can I optimize a parallax effect consisting of multiple transparent layers?

I have a parallax effect in MonoGame consisting of multiple semi-transparent layers of textures. The effect is simple, but rendering multiple transparent layers on top of each other is rather slow. ...
1
vote
1answer
108 views

What causes still objects have lines in them when lighting is being changed? [duplicate]

First, here is what I'm talking about (I changed the contrast to make it more visable, since it's not really visible in still images): Ingore the chat box, I was spamming buttons to see which one ...
4
votes
1answer
1k views

Faking 2d light using shader (Unity, Shaderlab)

Since the concept was difficult to explain in words for someone who's not quite familiar with shader, I described it in pictures. I'm currently using Unity and it seems Shaderlab is the best choice ...
0
votes
0answers
151 views

How can I compute spotlight attenuation when I only have a spotlight cutoff angle?

I am trying to compute the spot light attenuation, though I don't have a spotCosCutoff (cosine of the spotlight cutoff angle) predefined variable in the shader so I have to compute it myself. This is ...
0
votes
0answers
178 views

When should I set a texture as a shader resource in order to read it?

I'm writing a Direct3D 11 HLSL shader with SharpDX. What I want to do is write the depth to a texture in one pass and read it in the next one. After declaring the texture, do I have to set the depth ...
2
votes
0answers
263 views

Ashikhmin-Shirley model implementation: ugly result

I am trying to implement the Ashikhmin-Shirley model using these formulas: This is the GLSL 1.2 fragment shader code: uniform vec4 materialAmbient, materialDiffuse, materialSpecular; uniform ...
18
votes
2answers
1k views

How would one construct a realistic “infrared vision” effect?

How would you go about constructing a realistic infrared vision effect with shaders? By realistic I mean one that looks realistic, like this example. I have an idea about making a texture to ...
3
votes
1answer
266 views

Is multipass rendering possible with SpriteBatch?

I'm trying to implement a bloom effect. This requires three shader passes: a brightness threshold, a horizontal blur, and a vertical blur. It also requires resizes, but these are irrelevant to the ...
1
vote
1answer
147 views

How do I draw an isoline in a shader with a triangle topology?

I have some problems with my displacment. So I would like to have a simple little isoline starting in every triangles face center of the mash pointing in the direction of the corresponding faces ...
0
votes
1answer
152 views

HLSL postprocessing for day to night (DTN)

I am trying to implement a "day-to-night"-filter (as commonly used in cinema) for a 2D game (XNA) by using a full screen HLSL pixel shader. The aim is to transform any bright and colorful image into a ...
0
votes
3answers
97 views

how do I modify Texture2DArray values in shader

I'm using HLSL Shader Model 5.0. I'm using a Texture2D with the vertex positions for a mesh. In the Shader I'm trying to displace patchepositions along the normal of the patches I'd like to actualize ...
3
votes
2answers
454 views

When is the Z coordinate normalized in GLSL?

I thought that whenever you transform an object to world space, then view space and finally screen space, the last matrix you apply(the projection matrix) normalizes the z values between 0 and 1. ...
3
votes
1answer
242 views

Multiple pixel shader passes

I currently have a pixel shader that calculates the texture and I have another that calculates the light. I want another shader that does both. What I would ideally like to do is instead of creating a ...
0
votes
3answers
159 views

directional lightning

I have managed to get a point light working, but I am facing problem with directional lightning. Fragment shader uniform vec4 lightColour ; uniform vec3 lightPos ; uniform float lightRadius ; ...
2
votes
1answer
327 views

Is this GLSL equivalent to this HLSL?

I was wondering if the both shader codes are equivalent. So the question is, is this GLSL vNormal = mat3(FUSEE_ITMV[0].xyz, FUSEE_ITMV[1].xyz, FUSEE_ITMV[2].xyz) * fuNormal; Equivalent to this ...
1
vote
0answers
50 views

Approximating Subdivision Surfaces with Gregory Patches for Hardware Tessellation

I'm trying to implement the approach (http://research.microsoft.com/en-us/um/people/cloop/sga09.pdf). Unfortunately I'm not quite clear regarding the formulas in chapter 3, I am hoping to get some ...
2
votes
0answers
78 views

Framebuffer Heightmap Performance Problems

I am using a framebuffer to procedurally create heightmaps with perlin noise in GLSL shaders. There are two main problems that I am experiencing with this. I have a quadtree for the terrain and in the ...
2
votes
2answers
371 views

How can I remove branches from a fragment shader function?

I have a fragment shader, when I've carefully managed to remove most branching decisions, as I have found out through research here that they are bad. But I have one function that I just can't work ...
1
vote
1answer
380 views

What is the difference between shader uniforms and attributes in OpenGL?

I don't fully understand the differences between uniforms and attributes. To be honest, I probably haven't even used attributes. Can uniforms change for each vertex? I mean to calculate the vertex's ...
0
votes
0answers
146 views

Unity3D object fill shader

I've been researching this for a while, and had no luck yet. I figured I'd ask here to see if anyone had any good ideas. Essentially what I want is a shader that can make only part of an object ...
0
votes
1answer
342 views

Difference between texture.Load() and texture.Sample() methods in DirectX?

The question is simply that: What is the difference between texture.Load() and texture.Sample() in DirectX? I've used a Texture2D to store the depth in a pass of a DirectX Shader (with SharpDX), and ...
0
votes
0answers
679 views

How do I use UsePass in a shader in Unity when the pass does not have a name?

I'm trying to use passes from a given built-in shader in Unity. The docs say that the syntax is UsePass "Name". The problem is that built-in shaders don't have names on their passes. How could I do ...
0
votes
2answers
130 views

Alpha interpolation in a pixel shader

How does the interpolation in a fragment shader work when it comes to the alpha parameter? I'm programming a shader with SharpDX, DirectX11. My idea is to interpolate 2 3d points of a segment, so ...
1
vote
1answer
190 views

Fragment shader seems to floor() imprecisely

I'm trying to interpolate coordinates in my fragment shader. Unfortunately if close to the upper edge the interpolated value of fVertexInteger seems to be rounded up instead of beeing floored. This ...
1
vote
1answer
89 views

How can I find a position between 4 vertices in a fragment shader?

I'm creating a shader with SharpDX (DirectX11 in C#) that takes a segment (2 points) from the output of a Vertex Shader and then passes them to a Geometry Shader, which converts this line into a ...
1
vote
3answers
159 views

What is the minimum of shader I need to use to run basic calculation on GPU?

I read, that the Hull Shader, Domain Shader, Geometry Shader and Pixel Shader can be used optional. So, is the Vertex Shader optional too? If no: What does a basic Vertex Shader look like? Just like a ...
4
votes
2answers
215 views

Shadowmap first phase and shaders

I am using OpenGL 3.3 and am tryin to implement shadow mapping using cube maps. I have a framebuffer with a depth attachment and a cube map texture. My question is how to design the shaders for the ...
4
votes
1answer
137 views

PCF shadow shader math causing artifacts

For a while now I used PCSS for my shadow technique of choice until I discovered a type of percentage closer filtering. This method creates really smooth shadows and with hopes of improving ...
14
votes
1answer
655 views

Rendering oily/polluted water?

Any shader wizards out there have an idea of how to achieve an oily/polluted water effect, similar to this: Ideally, the water would not be uniformly oily, but instead the oil could be generated ...
0
votes
2answers
135 views

Accesing depth buffer from shader

I read this presentation and on 6th slide I found that is not need to use multiple render targets and depth can be taken directly from depth buffer. From which version of DirectX or OpenGL can be ...
-1
votes
1answer
425 views

What's wrong with this Open GL ES 2.0. Shader?

I just can't understand this. The code works perfectly on the emulator(Which is supposed to give more problems than phones…), but when I try it on a LG-E610 it doesn't compile the vertex shader. This ...